Search in sources :

Example 41 with ErrorCode2

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

the class ApiFriendService method applyList.

/**
 * 获取用户的好友申请列表
 *
 * @param command
 * @return
 */
public CommandResponse applyList(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        String siteUserId = command.getSiteUserId();
        LogUtils.requestDebugLog(logger, command, "");
        if (StringUtils.isNotBlank(siteUserId)) {
            List<ApplyUserBean> applyUserList = UserFriendDao.getInstance().getApplyUserList(siteUserId);
            ApiFriendApplyListProto.ApiFriendApplyListResponse.Builder responseBuilder = ApiFriendApplyListProto.ApiFriendApplyListResponse.newBuilder();
            for (ApplyUserBean applyUser : applyUserList) {
                if (StringUtils.isNotEmpty(applyUser.getUserId())) {
                    UserProto.UserProfile.Builder userProfileBuilder = UserProto.UserProfile.newBuilder();
                    userProfileBuilder.setSiteUserId(applyUser.getUserId());
                    userProfileBuilder.setUserName(String.valueOf(applyUser.getUserName()));
                    userProfileBuilder.setUserPhoto(String.valueOf(applyUser.getUserPhoto()));
                    UserProto.ApplyUserProfile applyUserProfile = UserProto.ApplyUserProfile.newBuilder().setApplyUser(userProfileBuilder.build()).setApplyReason(String.valueOf(applyUser.getApplyReason())).build();
                    responseBuilder.addList(applyUserProfile);
                }
            }
            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) ApplyUserBean(com.akaxin.site.storage.bean.ApplyUserBean) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 42 with ErrorCode2

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

the class ApiFriendService method setting.

/**
 * 获取好友的设置信息
 *
 * @param command
 * @return
 */
public CommandResponse setting(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendSettingProto.ApiFriendSettingRequest request = ApiFriendSettingProto.ApiFriendSettingRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, siteFriendId)) {
            UserFriendBean bean = UserFriendDao.getInstance().getFriendSetting(siteUserId, siteFriendId);
            if (bean != null) {
                ApiFriendSettingProto.ApiFriendSettingResponse response = ApiFriendSettingProto.ApiFriendSettingResponse.newBuilder().setMessageMute(bean.isMute()).build();
                commandResponse.setParams(response.toByteArray());
                errCode = ErrorCode2.SUCCESS;
            } else {
                // 数据库执行错误
                errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
            }
        } else {
            errCode = ErrorCode2.ERROR_PARAMETER;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ApiFriendSettingProto(com.akaxin.proto.site.ApiFriendSettingProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) UserFriendBean(com.akaxin.site.storage.bean.UserFriendBean)

Example 43 with ErrorCode2

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

the class ApiFriendService method updateMute.

/**
 * 对用户设置消息免打扰功能
 *
 * @param command
 * @return
 */
public CommandResponse updateMute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendUpdateMuteProto.ApiFriendUpdateMuteRequest request = ApiFriendUpdateMuteProto.ApiFriendUpdateMuteRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        boolean messageMute = request.getMute();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneBlank(siteUserId, siteFriendId)) {
            if (UserFriendDao.getInstance().updateFriendMute(siteUserId, siteFriendId, messageMute)) {
                errCode = ErrorCode2.SUCCESS;
            } else {
                errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
            }
        } 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) ApiFriendUpdateMuteProto(com.akaxin.proto.site.ApiFriendUpdateMuteProto)

Example 44 with ErrorCode2

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

the class ApiFriendService method apply.

/**
 * A请求添加B好友
 *
 * @param command
 * @return
 */
public CommandResponse apply(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendApplyProto.ApiFriendApplyRequest request = ApiFriendApplyProto.ApiFriendApplyRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        String applyReason = request.getApplyReason();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isEmpty(siteUserId)) {
            errCode = ErrorCode2.ERROR_PARAMETER;
        } else if (siteUserId.equals(siteFriendId)) {
            errCode = ErrorCode2.ERROR2_FRIEND_APPLYSELF;
        } else if (StringUtils.isNotBlank(siteUserId) && !siteUserId.equals(siteFriendId)) {
            UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, siteFriendId);
            if (UserProto.UserRelation.RELATION_FRIEND == userRelation) {
                errCode = ErrorCode2.ERROR2_FRIEND_IS;
            } 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("api.friend.apply 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 : ApiFriendApplyProto(com.akaxin.proto.site.ApiFriendApplyProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserProto(com.akaxin.proto.core.UserProto) User2Notice(com.akaxin.site.business.impl.notice.User2Notice) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 45 with ErrorCode2

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

the class ApiGroupService method mute.

public CommandResponse mute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupMuteProto.ApiGroupMuteRequest request = ApiGroupMuteProto.ApiGroupMuteRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteGroupId = request.getSiteGroupId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteGroupId, siteUserId)) {
            UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, siteGroupId);
            if (bean != null) {
                ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse.newBuilder().setMessageMute(bean.isMute()).build();
                commandResponse.setParams(response.toByteArray());
                errCode = ErrorCode2.SUCCESS;
            } else {
                errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
            }
        } 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) UserGroupBean(com.akaxin.site.storage.bean.UserGroupBean) ApiGroupMuteProto(com.akaxin.proto.site.ApiGroupMuteProto) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupSettingProto(com.akaxin.proto.site.ApiGroupSettingProto)

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