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