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);
}
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);
}
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);
}
Aggregations