use of com.akaxin.common.command.CommandResponse 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.command.CommandResponse 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.command.CommandResponse 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);
}
use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiGroupService method list.
/**
* 获取用户群列表 <br>
* 无权限限制
*
* @param command
* @return
*/
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupListProto.ApiGroupListRequest request = ApiGroupListProto.ApiGroupListRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(siteUserId)) {
List<SimpleGroupBean> groupBeanList = UserGroupDao.getInstance().getUserGroups(siteUserId);
ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse.newBuilder();
for (SimpleGroupBean groupBean : groupBeanList) {
GroupProto.SimpleGroupProfile groupProfile = GroupProto.SimpleGroupProfile.newBuilder().setGroupId(String.valueOf(groupBean.getGroupId())).setGroupName(String.valueOf(groupBean.getGroupName())).setGroupIcon(String.valueOf(groupBean.getGroupPhoto())).build();
responseBuilder.addList(groupProfile);
}
ApiGroupListProto.ApiGroupListResponse response = responseBuilder.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.command.CommandResponse in project openzaly by akaxincom.
the class ApiGroupService method members.
/**
* 获取群成员 <br>
* 无权限控制
*
* @param command
* @return
*/
public CommandResponse members(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = 1;
int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT;
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(groupId)) {
List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize);
ApiGroupMembersProto.ApiGroupMembersResponse.Builder responseBuilder = ApiGroupMembersProto.ApiGroupMembersResponse.newBuilder();
for (GroupMemberBean member : memberList) {
GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.forNumber(member.getUserRole());
UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder().setSiteUserId(member.getUserId()).setUserName(String.valueOf(member.getUserName())).setUserPhoto(String.valueOf(member.getUserPhoto())).build();
GroupProto.GroupMemberProfile groupMember = GroupProto.GroupMemberProfile.newBuilder().setRole(memberRole).setProfile(memberProfile).build();
responseBuilder.addList(groupMember);
}
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);
}
Aggregations