Search in sources :

Example 11 with PluginBean

use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.

the class SQLitePluginDao method queryPluginList.

/**
 * 按照位置,分页查询
 *
 * @param pageNum
 * @param pageSize
 * @param position
 * @return
 * @throws SQLException
 */
public List<PluginBean> queryPluginList(int pageNum, int pageSize, int position) throws SQLException {
    long startTime = System.currentTimeMillis();
    List<PluginBean> pluginList = new ArrayList<PluginBean>();
    String sql = // 
    "SELECT id," + // 
    "name," + // 
    "icon," + // 
    "url_page," + // 
    "api_url," + // 
    "sort," + // 
    "position," + // 
    "permission_status" + " FROM " + PLUGIN_TABLE + // 
    " WHERE " + "position=? ORDER BY sort LIMIT ?,?;";
    int startNum = (pageNum - 1) * pageSize;
    PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
    preStatement.setInt(1, position);
    preStatement.setInt(2, startNum);
    preStatement.setInt(3, pageSize);
    ResultSet rs = preStatement.executeQuery();
    while (rs.next()) {
        PluginBean bean = new PluginBean();
        bean.setId(rs.getInt(1));
        bean.setName(rs.getString(2));
        bean.setIcon(rs.getString(3));
        bean.setUrlPage(rs.getString(4));
        bean.setApiUrl(rs.getString(5));
        bean.setSort(rs.getInt(6));
        bean.setPosition(rs.getInt(7));
        bean.setPermissionStatus(rs.getInt(8));
        pluginList.add(bean);
    }
    LogUtils.dbDebugLog(logger, startTime, pluginList.size(), sql, position, startNum, pageSize);
    return pluginList;
}
Also used : ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) PluginBean(com.akaxin.site.storage.bean.PluginBean)

Aggregations

PluginBean (com.akaxin.site.storage.bean.PluginBean)11 CommandResponse (com.akaxin.common.command.CommandResponse)7 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)7 ByteString (com.google.protobuf.ByteString)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 ApiPluginProxyProto (com.akaxin.proto.site.ApiPluginProxyProto)2 ArrayList (java.util.ArrayList)2 PluginProto (com.akaxin.proto.core.PluginProto)1 HaiPluginAddProto (com.akaxin.proto.plugin.HaiPluginAddProto)1 HaiPluginListProto (com.akaxin.proto.plugin.HaiPluginListProto)1 HaiPluginProfileProto (com.akaxin.proto.plugin.HaiPluginProfileProto)1 HaiPluginUpdateProto (com.akaxin.proto.plugin.HaiPluginUpdateProto)1 ApiPluginListProto (com.akaxin.proto.site.ApiPluginListProto)1 ApiPluginPageProto (com.akaxin.proto.site.ApiPluginPageProto)1