Search in sources :

Example 31 with ErrorCode2

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

the class HttpUserService method relationList.

/**
 * 分页获取用户列表,同时附带与当前用户之间关系
 *
 * @param command
 * @return
 */
public CommandResponse relationList(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errorCode = ErrorCode2.ERROR;
    try {
        HaiUserRelationListProto.HaiUserRelationListRequest request = HaiUserRelationListProto.HaiUserRelationListRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        List<SimpleUserRelationBean> pageList = UserProfileDao.getInstance().getUserRelationPageList(siteUserId, pageNum, pageSize);
        if (pageList != null) {
            HaiUserRelationListProto.HaiUserRelationListResponse.Builder responseBuilder = HaiUserRelationListProto.HaiUserRelationListResponse.newBuilder();
            for (SimpleUserRelationBean bean : pageList) {
                UserProto.UserRelationProfile.Builder userProfileBuilder = UserProto.UserRelationProfile.newBuilder();
                UserProto.SimpleUserProfile.Builder supBuilder = UserProto.SimpleUserProfile.newBuilder();
                supBuilder.setSiteUserId(bean.getUserId());
                if (StringUtils.isNotBlank(bean.getUserId())) {
                    supBuilder.setUserName(String.valueOf(bean.getUserName()));
                }
                if (StringUtils.isNotBlank(bean.getUserPhoto())) {
                    supBuilder.setUserPhoto(bean.getUserPhoto());
                }
                supBuilder.setUserStatusValue(bean.getUserStatus());
                userProfileBuilder.setProfile(supBuilder);
                userProfileBuilder.setRelationValue(bean.getRelation());
                responseBuilder.addUserProfile(userProfileBuilder.build());
            }
            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 : SimpleUserRelationBean(com.akaxin.site.storage.bean.SimpleUserRelationBean) CommandResponse(com.akaxin.common.command.CommandResponse) ErrorCode2(com.akaxin.common.constant.ErrorCode2) HaiUserRelationListProto(com.akaxin.proto.plugin.HaiUserRelationListProto)

Example 32 with ErrorCode2

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

the class HttpUserService method update.

/**
 * 更新用户信息
 *
 * @param command
 * @return
 */
public CommandResponse update(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiUserUpdateProto.HaiUserUpdateRequest request = HaiUserUpdateProto.HaiUserUpdateRequest.parseFrom(command.getParams());
        String siteUserId = request.getUserProfile().getSiteUserId();
        String userName = request.getUserProfile().getUserName();
        String userPhoto = request.getUserProfile().getUserPhoto();
        String userIntro = request.getUserProfile().getSelfIntroduce();
        LogUtils.requestDebugLog(logger, command, request.toString());
        // 过滤参数
        if (StringUtils.isNoneBlank(siteUserId)) {
            UserProfileBean bean = new UserProfileBean();
            bean.setSiteUserId(siteUserId);
            bean.setUserName(userName);
            bean.setUserPhoto(userPhoto);
            bean.setSelfIntroduce(userIntro);
            if (UserProfileDao.getInstance().updateUserProfile(bean)) {
                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) HaiUserUpdateProto(com.akaxin.proto.plugin.HaiUserUpdateProto) UserProfileBean(com.akaxin.site.storage.bean.UserProfileBean)

Example 33 with ErrorCode2

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

the class HttpUserService method sealUp.

/**
 * <pre>
 * 		禁封/解禁 用户身份
 * </pre>
 *
 * @param command
 * @return
 */
public CommandResponse sealUp(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiUserSealUpProto.HaiUserSealUpRequest request = HaiUserSealUpProto.HaiUserSealUpRequest.parseFrom(command.getParams());
        String siteUserId = request.getSiteUserId();
        UserProto.UserStatus userStatus = request.getStatus();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId)) {
            if (UserProfileDao.getInstance().updateUserStatus(siteUserId, userStatus.getNumber())) {
                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) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) HaiUserSealUpProto(com.akaxin.proto.plugin.HaiUserSealUpProto)

Example 34 with ErrorCode2

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

the class AbstractRequest method executeMethodByReflect.

private CommandResponse executeMethodByReflect(Command command) {
    CommandResponse response = null;
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        String methodName = command.getMethod();
        Method m = this.getClass().getDeclaredMethod(methodName, command.getClass());
        response = (CommandResponse) m.invoke(this, command);
    } catch (Exception e) {
        LogUtils.requestErrorLog(logger, command, e);
    }
    if (response == null) {
        response = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES).setErrCode2(errCode);
    }
    return response;
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) Method(java.lang.reflect.Method)

Example 35 with ErrorCode2

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

the class HttpFriendService method apply.

/**
 * 提供扩展服务中添加好友的功能
 *
 * @param command
 * @return
 */
public CommandResponse apply(Command command) {
    CommandResponse commandResponse = new CommandResponse();
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        HaiFriendApplyProto.HaiFriendApplyRequest request = HaiFriendApplyProto.HaiFriendApplyRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        String applyReason = request.getApplyReason();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isBlank(siteUserId)) {
            errCode = ErrorCode2.ERROR_PARAMETER;
        } else if (siteUserId.equals(siteFriendId)) {
            errCode = ErrorCode2.ERROR2_FRIEND_APPLYSELF;
        } else {
            int applyTimes = UserFriendDao.getInstance().getApplyCount(siteFriendId, siteUserId);
            if (applyTimes >= 5) {
                errCode = ErrorCode2.ERROR2_FRIEND_APPLYCOUNT;
            } else {
                if (UserFriendDao.getInstance().saveFriendApply(siteUserId, siteFriendId, applyReason)) {
                    errCode = ErrorCode2.SUCCESS;
                }
            }
        }
        if (ErrorCode2.SUCCESS.equals(errCode)) {
            logger.debug("user apply friend notice. to siteUserId={}", siteFriendId);
            new User2Notice().applyFriendNotice(siteFriendId);
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : HaiFriendApplyProto(com.akaxin.proto.plugin.HaiFriendApplyProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) User2Notice(com.akaxin.site.business.impl.notice.User2Notice) CommandResponse(com.akaxin.common.command.CommandResponse)

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