Search in sources :

Example 26 with ErrorCode2

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

the class HttpGroupService method addMember.

/**
 * 添加群成员
 *
 * @param command
 * @return
 */
public CommandResponse addMember(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupAddMemberProto.HaiGroupAddMemberRequest request = HaiGroupAddMemberProto.HaiGroupAddMemberRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getGroupId();
        ProtocolStringList addMemberList = request.getGroupMemberList();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNoneBlank(groupId) && addMemberList != null) {
            if (UserGroupDao.getInstance().addGroupMember(siteUserId, groupId, addMemberList)) {
                errCode = ErrorCode2.SUCCESS;
            }
        } else {
            errCode = ErrorCode2.ERROR_PARAMETER;
        }
    } 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) HaiGroupAddMemberProto(com.akaxin.proto.plugin.HaiGroupAddMemberProto) ProtocolStringList(com.google.protobuf.ProtocolStringList)

Example 27 with ErrorCode2

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

the class HttpGroupService method profile.

/**
 * 获取群资料
 *
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest.parseFrom(command.getParams());
        String groupId = request.getGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);
        if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
            GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName())).setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
            HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse.newBuilder();
            responseBuilder.setProfile(groupProfile);
            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) GroupProto(com.akaxin.proto.core.GroupProto) HaiGroupProfileProto(com.akaxin.proto.plugin.HaiGroupProfileProto) CommandResponse(com.akaxin.common.command.CommandResponse) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean)

Example 28 with ErrorCode2

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

the class HttpGroupService method list.

/**
 * 分页获取站点群列表
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiGroupListProto.HaiGroupListRequest request = HaiGroupListProto.HaiGroupListRequest.parseFrom(command.getParams());
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleGroupBean> groupList = UserGroupDao.getInstance().getGroupList(pageNum, pageSize);
        if (groupList != null) {
            HaiGroupListProto.HaiGroupListResponse.Builder responseBuilder = HaiGroupListProto.HaiGroupListResponse.newBuilder();
            for (SimpleGroupBean bean : groupList) {
                responseBuilder.addGroupProfile(getSimpleGroupProfile(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 : HaiGroupListProto(com.akaxin.proto.plugin.HaiGroupListProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) SimpleGroupBean(com.akaxin.site.storage.bean.SimpleGroupBean) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 29 with ErrorCode2

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

the class HttpPluginService method add.

/**
 * 申请添加好友
 *
 * @param command
 * @return
 */
public CommandResponse add(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiPluginAddProto.HaiPluginAddRequest request = HaiPluginAddProto.HaiPluginAddRequest.parseFrom(command.getParams());
        LogUtils.requestDebugLog(logger, command, request.toString());
        PluginBean bean = new PluginBean();
        bean.setName(request.getPlugin().getName());
        bean.setIcon(request.getPlugin().getIcon());
        bean.setUrlPage(request.getPlugin().getUrlPage());
        bean.setApiUrl(request.getPlugin().getApiUrl());
        bean.setAllowedIp(request.getPlugin().getAllowedIp());
        bean.setPosition(request.getPlugin().getPositionValue());
        bean.setDisplayMode(PluginProto.PluginDisplayMode.NEW_PAGE_VALUE);
        bean.setPermissionStatus(request.getPlugin().getPermissionStatusValue());
        bean.setAddTime(System.currentTimeMillis());
        // 随机生成64位的字符串
        bean.setAuthKey(StringHelper.generateRandomString(16));
        if (SitePluginDao.getInstance().addPlugin(bean)) {
            errorCode = ErrorCode2.SUCCESS;
        }
    } catch (Exception e) {
        errorCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errorCode);
}
Also used : HaiPluginAddProto(com.akaxin.proto.plugin.HaiPluginAddProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) PluginBean(com.akaxin.site.storage.bean.PluginBean)

Example 30 with ErrorCode2

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

the class HttpUICService method info.

/**
 * 获取UIC信息
 *
 * @param command
 * @return
 */
public CommandResponse info(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUicInfoProto.HaiUicInfoRequest request = HaiUicInfoProto.HaiUicInfoRequest.parseFrom(command.getParams());
        int id = request.getId();
        String uic = request.getUic();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (id > 0 && StringUtils.isNotBlank(uic)) {
            UicBean bean = SiteUicDao.getInstance().getUicInfo(uic);
            if (bean != null) {
                HaiUicInfoProto.HaiUicInfoResponse response = HaiUicInfoProto.HaiUicInfoResponse.newBuilder().setUicInfo(getUicInfo(bean)).build();
                commandResponse.setParams(response.toByteArray());
                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) UicBean(com.akaxin.site.storage.bean.UicBean) HaiUicInfoProto(com.akaxin.proto.plugin.HaiUicInfoProto)

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