use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpPluginService method delete.
/**
* 删除扩展,直接从数据库中删除数据
*
* @param command
* @return
*/
public CommandResponse delete(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
HaiPluginDeleteProto.HaiPluginDeleteRequest request = HaiPluginDeleteProto.HaiPluginDeleteRequest.parseFrom(command.getParams());
String pluginId = request.getPluginId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(pluginId)) {
if (SitePluginDao.getInstance().deletePlugin(Integer.valueOf(pluginId))) {
errorCode = ErrorCode2.SUCCESS;
}
} else {
errorCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
use of com.akaxin.common.command.CommandResponse 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.common.command.CommandResponse 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.common.command.CommandResponse 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.common.command.CommandResponse in project openzaly by akaxincom.
the class HttpSiteConfigService method getConfig.
/**
* 获取站点配置信息
*
* @param command
* @return
*/
public CommandResponse getConfig(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errorCode = ErrorCode2.ERROR;
try {
LogUtils.requestDebugLog(logger, command, "");
Map<Integer, String> configMap = SiteConfig.getConfigMap();
ConfigProto.SiteBackConfig config = ConfigProto.SiteBackConfig.newBuilder().putAllSiteConfig(configMap).build();
HaiSiteGetConfigProto.HaiSiteGetConfigResponse response = HaiSiteGetConfigProto.HaiSiteGetConfigResponse.newBuilder().setSiteConfig(config).build();
commandResponse.setParams(response.toByteArray());
errorCode = ErrorCode2.SUCCESS;
} catch (Exception e) {
errorCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errorCode);
}
Aggregations