use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.
the class HttpPluginService method profile.
/**
* 获取扩展的信息
*
* @param command
* @return
*/
public CommandResponse profile(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiPluginProfileProto.HaiPluginProfileRequest request = HaiPluginProfileProto.HaiPluginProfileRequest.parseFrom(command.getParams());
String pluginId = request.getPluginId();
LogUtils.requestDebugLog(logger, command, request.toString());
PluginBean bean = SitePluginDao.getInstance().getPluginProfile(Integer.valueOf(pluginId));
if (bean != null) {
HaiPluginProfileProto.HaiPluginProfileResponse response = HaiPluginProfileProto.HaiPluginProfileResponse.newBuilder().setPlugin(getPluginProfile(bean)).build();
commandResponse.setParams(response.toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.
the class HttpPluginService method update.
/**
* 更新扩展的信息
*
* @param command
* @return
*/
public CommandResponse update(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiPluginUpdateProto.HaiPluginUpdateRequest request = HaiPluginUpdateProto.HaiPluginUpdateRequest.parseFrom(command.getParams());
LogUtils.requestDebugLog(logger, command, request.toString());
PluginBean bean = new PluginBean();
bean.setId(Integer.valueOf(request.getPlugin().getId()));
bean.setName(request.getPlugin().getName());
bean.setIcon(request.getPlugin().getIcon());
bean.setUrlPage(request.getPlugin().getUrlPage());
bean.setApiUrl(request.getPlugin().getApiUrl());
bean.setAuthKey(request.getPlugin().getAuthKey());
bean.setAllowedIp(request.getPlugin().getAllowedIp());
bean.setSort(request.getPlugin().getOrder());
bean.setPosition(request.getPlugin().getPositionValue());
bean.setPermissionStatus(request.getPlugin().getPermissionStatusValue());
if (SitePluginDao.getInstance().updatePlugin(bean)) {
errorCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.
the class HttpPluginService method list.
/**
* 分页获取扩展的列表
*
* @param command
* @return
*/
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiPluginListProto.HaiPluginListRequest request = HaiPluginListProto.HaiPluginListRequest.parseFrom(command.getParams());
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<PluginBean> pluginList = SitePluginDao.getInstance().getAllPluginList(pageNum, pageSize);
if (pluginList != null) {
HaiPluginListProto.HaiPluginListResponse.Builder responseBuilder = HaiPluginListProto.HaiPluginListResponse.newBuilder();
for (PluginBean bean : pluginList) {
responseBuilder.addPlugin(getPluginProfile(bean));
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errorCode = ErrorCode2.SUCCESS;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.
the class SQLitePluginDao method queryAllPluginList.
/**
* 分页查询所有的扩展,管理后台使用
*
* @param pageNum
* @param pageSize
* @return
* @throws SQLException
*/
public List<PluginBean> queryAllPluginList(int pageNum, int pageSize) 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 + " ORDER BY sort LIMIT ?,?;";
int startNum = (pageNum - 1) * pageSize;
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setInt(1, startNum);
preStatement.setInt(2, 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, startNum, pageSize);
return pluginList;
}
use of com.akaxin.site.storage.bean.PluginBean in project openzaly by akaxincom.
the class SQLitePluginDao method queryPluginProfile.
public PluginBean queryPluginProfile(int pluginId) throws SQLException {
long startTime = System.currentTimeMillis();
PluginBean pluginBean = new PluginBean();
String sql = //
"SELECT id," + //
"name," + //
"icon," + //
"url_page," + //
"api_url," + //
"auth_key," + //
"allowed_ip," + //
"position," + //
"sort," + //
"display_mode," + //
"permission_status" + " FROM " + PLUGIN_TABLE + " WHERE id=?;";
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setInt(1, pluginId);
ResultSet rs = preStatement.executeQuery();
if (rs.next()) {
pluginBean.setId(rs.getInt(1));
pluginBean.setName(rs.getString(2));
pluginBean.setIcon(rs.getString(3));
pluginBean.setUrlPage(rs.getString(4));
pluginBean.setApiUrl(rs.getString(5));
pluginBean.setAuthKey(rs.getString(6));
pluginBean.setAllowedIp(rs.getString(7));
pluginBean.setPosition(rs.getInt(8));
pluginBean.setSort(rs.getInt(9));
pluginBean.setDisplayMode(rs.getInt(10));
pluginBean.setPermissionStatus(rs.getInt(11));
}
LogUtils.dbDebugLog(logger, startTime, pluginBean.toString(), sql, pluginId);
return pluginBean;
}
Aggregations