Search in sources :

Example 61 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 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 62 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 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)

Example 63 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class HttpSiteConfigService method updateConfig.

/**
 * 更新站点配置相关操作
 *
 * @param command
 * @return
 */
public CommandResponse updateConfig(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiSiteUpdateConfigProto.HaiSiteUpdateConfigRequest request = HaiSiteUpdateConfigProto.HaiSiteUpdateConfigRequest.parseFrom(command.getParams());
        Map<Integer, String> configMap = request.getSiteConfig().getSiteConfigMap();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (configMap != null) {
            // update db config
            if (SiteConfigDao.getInstance().updateSiteConfig(configMap)) {
                errorCode = ErrorCode2.SUCCESS;
                SiteConfig.updateConfig();
                SiteConfigHelper.updateConfig();
            }
            // update log level
            if (configMap.get(ConfigProto.ConfigKey.LOG_LEVEL_VALUE) != null) {
                String loglev = configMap.get(ConfigProto.ConfigKey.LOG_LEVEL_VALUE);
                Level level = Level.toLevel(loglev);
                AkxLog4jManager.setLogLevel(level);
            }
        } 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) HaiSiteUpdateConfigProto(com.akaxin.proto.plugin.HaiSiteUpdateConfigProto) Level(org.apache.log4j.Level) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 64 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class HttpUICService method create.

/**
 * 生成UIC(用户邀请码)
 *
 * @param command
 * @return
 */
public CommandResponse create(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUicCreateProto.HaiUicCreateRequest request = HaiUicCreateProto.HaiUicCreateRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        int num = request.getUicNumber();
        int successCount = 0;
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && num > 0) {
            UicBean bean = new UicBean();
            bean.setStatus(UicStatus.UNUSED_VALUE);
            bean.setCreateTime(System.currentTimeMillis());
            if (SiteUicDao.getInstance().batchAddUic(bean, num)) {
                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 : HaiUicCreateProto(com.akaxin.proto.plugin.HaiUicCreateProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) UicBean(com.akaxin.site.storage.bean.UicBean)

Example 65 with ErrorCode2

use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.

the class HttpUICService method list.

/**
 * 分页获取UIC
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiUicListProto.HaiUicListRequest request = HaiUicListProto.HaiUicListRequest.parseFrom(command.getParams());
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        int status = request.getStatusValue();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<UicBean> uicList = SiteUicDao.getInstance().getUicList(pageNum, pageSize, status);
        if (uicList != null) {
            HaiUicListProto.HaiUicListResponse.Builder responseBuilder = HaiUicListProto.HaiUicListResponse.newBuilder();
            for (UicBean bean : uicList) {
                responseBuilder.addUicInfo(getUicInfo(bean));
            }
            commandResponse.setParams(responseBuilder.build().toByteArray());
            errCode = ErrorCode2.SUCCESS;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) UicBean(com.akaxin.site.storage.bean.UicBean) HaiUicListProto(com.akaxin.proto.plugin.HaiUicListProto)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)68 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)68 UserProto (com.akaxin.proto.core.UserProto)12 PluginBean (com.akaxin.site.storage.bean.PluginBean)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 ByteString (com.google.protobuf.ByteString)5 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 FileProto (com.akaxin.proto.core.FileProto)2 HaiSiteUpdateConfigProto (com.akaxin.proto.plugin.HaiSiteUpdateConfigProto)2 ApiFriendSettingProto (com.akaxin.proto.site.ApiFriendSettingProto)2 ApiGroupUpdateSettingProto (com.akaxin.proto.site.ApiGroupUpdateSettingProto)2 User2Notice (com.akaxin.site.business.impl.notice.User2Notice)2