Search in sources :

Example 1 with User2Notice

use of com.akaxin.site.business.impl.notice.User2Notice in project openzaly by akaxincom.

the class ApiFriendService method applyResult.

/**
 * 是否同意用户的好友申请结果
 *
 * @param command
 * @return
 */
public CommandResponse applyResult(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendApplyResultProto.ApiFriendApplyResultRequest request = ApiFriendApplyResultProto.ApiFriendApplyResultRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        boolean result = request.getApplyResult();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(siteFriendId) && !siteUserId.equals(siteFriendId)) {
            if (UserFriendDao.getInstance().agreeApply(siteUserId, siteFriendId, result)) {
                errCode = ErrorCode2.SUCCESS;
            }
            if (ErrorCode2.SUCCESS.equals(errCode) && result) {
                new User2Notice().addFriendTextMessage(siteUserId, siteFriendId);
                logger.debug("client={} siteUserId={} add friend notice to siteUserId={}", command.getClientIp(), siteFriendId);
            }
        } 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) User2Notice(com.akaxin.site.business.impl.notice.User2Notice) CommandResponse(com.akaxin.common.command.CommandResponse) ApiFriendApplyResultProto(com.akaxin.proto.site.ApiFriendApplyResultProto)

Example 2 with User2Notice

use of com.akaxin.site.business.impl.notice.User2Notice 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)

Example 3 with User2Notice

use of com.akaxin.site.business.impl.notice.User2Notice 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)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)3 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)3 User2Notice (com.akaxin.site.business.impl.notice.User2Notice)3 UserProto (com.akaxin.proto.core.UserProto)1 HaiFriendApplyProto (com.akaxin.proto.plugin.HaiFriendApplyProto)1 ApiFriendApplyProto (com.akaxin.proto.site.ApiFriendApplyProto)1 ApiFriendApplyResultProto (com.akaxin.proto.site.ApiFriendApplyResultProto)1