Search in sources :

Example 66 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) HaiPluginDeleteProto(com.akaxin.proto.plugin.HaiPluginDeleteProto)

Example 67 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiPluginProfileProto(com.akaxin.proto.plugin.HaiPluginProfileProto) CommandResponse(com.akaxin.common.command.CommandResponse) PluginBean(com.akaxin.site.storage.bean.PluginBean)

Example 68 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiPluginUpdateProto(com.akaxin.proto.plugin.HaiPluginUpdateProto) CommandResponse(com.akaxin.common.command.CommandResponse) PluginBean(com.akaxin.site.storage.bean.PluginBean)

Example 69 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) PluginBean(com.akaxin.site.storage.bean.PluginBean) HaiPluginListProto(com.akaxin.proto.plugin.HaiPluginListProto)

Example 70 with CommandResponse

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);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiSiteUpdateConfigProto(com.akaxin.proto.plugin.HaiSiteUpdateConfigProto) HaiSiteGetConfigProto(com.akaxin.proto.plugin.HaiSiteGetConfigProto) ConfigProto(com.akaxin.proto.core.ConfigProto) HaiSiteGetConfigProto(com.akaxin.proto.plugin.HaiSiteGetConfigProto) CommandResponse(com.akaxin.common.command.CommandResponse)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)82 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)68 UserProto (com.akaxin.proto.core.UserProto)12 PluginBean (com.akaxin.site.storage.bean.PluginBean)7 ByteString (com.google.protobuf.ByteString)7 GroupProto (com.akaxin.proto.core.GroupProto)6 GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)6 SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)6 UserProfileBean (com.akaxin.site.storage.bean.UserProfileBean)6 UserDeviceBean (com.akaxin.site.storage.bean.UserDeviceBean)5 Command (com.akaxin.common.command.Command)4 DeviceProto (com.akaxin.proto.core.DeviceProto)4 ProtocolStringList (com.google.protobuf.ProtocolStringList)4 ConfigProto (com.akaxin.proto.core.ConfigProto)3 GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)3 UserGroupBean (com.akaxin.site.storage.bean.UserGroupBean)3 RedisCommand (com.akaxin.common.command.RedisCommand)2 ImStcPsnProto (com.akaxin.proto.client.ImStcPsnProto)2 CoreProto (com.akaxin.proto.core.CoreProto)2 FileProto (com.akaxin.proto.core.FileProto)2