use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiFriendService method mute.
public CommandResponse mute(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendMuteProto.ApiFriendMuteRequest request = ApiFriendMuteProto.ApiFriendMuteRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneEmpty(siteUserId, siteFriendId)) {
boolean mute = UserFriendDao.getInstance().getFriendMute(siteUserId, siteFriendId);
ApiFriendSettingProto.ApiFriendSettingResponse response = ApiFriendSettingProto.ApiFriendSettingResponse.newBuilder().setMessageMute(mute).build();
commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
} 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 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.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiFriendService method list.
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendListProto.ApiFriendListRequest request = ApiFriendListProto.ApiFriendListRequest.parseFrom(command.getParams());
String currentUserId = command.getSiteUserId();
String siteUserId = request.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(currentUserId)) {
List<SimpleUserBean> friendBeanList = UserFriendDao.getInstance().getUserFriends(siteUserId);
ApiFriendListProto.ApiFriendListResponse.Builder responseBuilder = ApiFriendListProto.ApiFriendListResponse.newBuilder();
for (SimpleUserBean friendBean : friendBeanList) {
UserProto.SimpleUserProfile friend = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(String.valueOf(friendBean.getUserId())).setUserName(String.valueOf(friendBean.getUserName())).setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build();
responseBuilder.addList(friend);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
} 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 ApiGroupService method updateProfile.
/**
* 用户更新群资料<br>
* 群主/管理员权限限制
*
* @param command
* @return
*/
public CommandResponse updateProfile(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest request = ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getProfile().getId();
String photoId = request.getProfile().getIcon();
String groupName = request.getProfile().getName();
String groupNotice = request.getProfile().getGroupNotice();
// 新的群群主
String newGroupOwner = request.getNewGroupOwner();
// 是否可以邀请群聊(除了群主以外的其他群成员)
boolean closeInviteGroupChat = request.getCloseInviteGroupChat();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(groupId)) {
String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(groupMasterId)) {
GroupProfileBean gprofileBean = new GroupProfileBean();
gprofileBean.setGroupId(groupId);
gprofileBean.setGroupName(groupName);
gprofileBean.setGroupPhoto(photoId);
gprofileBean.setGroupNotice(groupNotice);
gprofileBean.setCreateUserId(newGroupOwner);
gprofileBean.setCloseInviteGroupChat(closeInviteGroupChat);
if (StringUtils.isNotEmpty(groupName)) {
if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
if (UserGroupDao.getInstance().updateGroupIGC(gprofileBean)) {
errCode = ErrorCode2.SUCCESS;
}
}
} else {
errCode = ErrorCode2.ERROR_NOPERMISSION;
}
} 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 ApiGroupService method nonMembers.
/**
* 获取用户群组中,不存在的好友用户
*
* @param command
* @return
*/
public CommandResponse nonMembers(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupNonMembersProto.ApiGroupNonMembersRequest request = ApiGroupNonMembersProto.ApiGroupNonMembersRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
if (pageNum == 0 && pageSize == 0) {
pageSize = 100;
}
List<SimpleUserBean> userFriendList = UserGroupDao.getInstance().getUserFriendNonGroupMemberList(siteUserId, groupId, pageNum, pageSize);
ApiGroupNonMembersProto.ApiGroupNonMembersResponse.Builder responseBuilder = ApiGroupNonMembersProto.ApiGroupNonMembersResponse.newBuilder();
for (SimpleUserBean friendBean : userFriendList) {
UserProto.SimpleUserProfile friendProfile = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(friendBean.getUserId()).setUserName(String.valueOf(friendBean.getUserName())).setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build();
responseBuilder.addProfile(friendProfile);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations