Java Code Examples for com.akaxin.proto.core.UserProto#UserProfile
The following examples show how to use
com.akaxin.proto.core.UserProto#UserProfile .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiFriendService.java From wind-im with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 2
Source File: ApiGroupService.java From wind-im with Apache License 2.0 | 4 votes |
/** * 获取群资料信息,一般由以下几部分组成 <br> * 1.群资料GroupProfile <br> * 2.群主基本资料GroupMaster,群主通过GroupProfile获取 <br> * 3.群成员人数以及排在最前列的四位用户 <br> * 4.无权限限制 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String groupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, groupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(groupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId); if (groupBean == null || StringUtils.isEmpty(groupBean.getGroupId())) { throw new ZalyException(ErrorCode2.ERROR_GROUP_QUERY_PROFILE); } SimpleUserBean ownerProfileBean = UserProfileDao.getInstance() .getSimpleProfileById(groupBean.getCreateUserId()); logger.debug("get groupId={},groupOwner={}", groupId, ownerProfileBean.toString()); int groupMembersCount = UserGroupDao.getInstance().getGroupMemberCount(groupId); logger.debug("get groupId={},groupMembers={}", groupId, groupMembersCount); List<GroupMemberBean> groupMemberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize); UserProto.UserProfile ownerProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(ownerProfileBean.getUserId())) .setUserPhoto(String.valueOf(ownerProfileBean.getUserPhoto())) .setUserName(String.valueOf(ownerProfileBean.getUserName())).build(); GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()) .setName(String.valueOf(groupBean.getGroupName())) .setIcon(String.valueOf(groupBean.getGroupPhoto())).build(); ApiGroupProfileProto.ApiGroupProfileResponse.Builder responseBuilder = ApiGroupProfileProto.ApiGroupProfileResponse .newBuilder(); responseBuilder.setOwner(ownerProfile); responseBuilder.setProfile(groupProfile); responseBuilder.setGroupMemberCount(groupMembersCount); for (GroupMemberBean memberBean : groupMemberList) { UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(memberBean.getUserId())) .setUserPhoto(String.valueOf(memberBean.getUserPhoto())) .setUserName(String.valueOf(memberBean.getUserName())).build(); GroupProto.GroupMemberProfile groupMemberProfile = GroupProto.GroupMemberProfile.newBuilder() .setProfile(memberProfile).build(); responseBuilder.addGroupLastestMember(groupMemberProfile); } // 是否可以邀请群聊(除了群主以外) responseBuilder.setCloseInviteGroupChat(groupBean.isCloseInviteGroupChat()); ApiGroupProfileProto.ApiGroupProfileResponse response = responseBuilder.build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }
Example 3
Source File: ApiGroupService.java From wind-im with Apache License 2.0 | 4 votes |
/** * 获取群成员 <br> * 无权限控制 * * @param command * @return */ public CommandResponse members(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String siteGroupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(siteGroupId, 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; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }
Example 4
Source File: ApiFriendService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 5
Source File: ApiGroupService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 获取群资料信息,一般由以下几部分组成 <br> * 1.群资料GroupProfile <br> * 2.群主基本资料GroupMaster,群主通过GroupProfile获取 <br> * 3.群成员人数以及排在最前列的四位用户 <br> * 4.无权限限制 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String groupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, groupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(groupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId); if (groupBean == null || StringUtils.isEmpty(groupBean.getGroupId())) { throw new ZalyException(ErrorCode2.ERROR_GROUP_QUERY_PROFILE); } SimpleUserBean ownerProfileBean = UserProfileDao.getInstance() .getSimpleProfileById(groupBean.getCreateUserId()); logger.debug("get groupId={},groupOwner={}", groupId, ownerProfileBean.toString()); int groupMembersCount = UserGroupDao.getInstance().getGroupMemberCount(groupId); logger.debug("get groupId={},groupMembers={}", groupId, groupMembersCount); List<GroupMemberBean> groupMemberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize); UserProto.UserProfile ownerProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(ownerProfileBean.getUserId())) .setUserPhoto(String.valueOf(ownerProfileBean.getUserPhoto())) .setUserName(String.valueOf(ownerProfileBean.getUserName())).build(); GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()) .setName(String.valueOf(groupBean.getGroupName())) .setIcon(String.valueOf(groupBean.getGroupPhoto())).build(); ApiGroupProfileProto.ApiGroupProfileResponse.Builder responseBuilder = ApiGroupProfileProto.ApiGroupProfileResponse .newBuilder(); responseBuilder.setOwner(ownerProfile); responseBuilder.setProfile(groupProfile); responseBuilder.setGroupMemberCount(groupMembersCount); for (GroupMemberBean memberBean : groupMemberList) { UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(memberBean.getUserId())) .setUserPhoto(String.valueOf(memberBean.getUserPhoto())) .setUserName(String.valueOf(memberBean.getUserName())).build(); GroupProto.GroupMemberProfile groupMemberProfile = GroupProto.GroupMemberProfile.newBuilder() .setProfile(memberProfile).build(); responseBuilder.addGroupLastestMember(groupMemberProfile); } // 是否可以邀请群聊(除了群主以外) responseBuilder.setCloseInviteGroupChat(groupBean.isCloseInviteGroupChat()); ApiGroupProfileProto.ApiGroupProfileResponse response = responseBuilder.build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }
Example 6
Source File: ApiGroupService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 获取群成员 <br> * 无权限控制 * * @param command * @return */ public CommandResponse members(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String siteGroupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(siteGroupId, 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; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }
Example 7
Source File: ApiFriendService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 查询好友的资料信息,点击好友头像查看使用 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); ErrorCode2 errCode = ErrorCode2.ERROR; try { ApiFriendProfileProto.ApiFriendProfileRequest request = ApiFriendProfileProto.ApiFriendProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String globalOrSiteFriendId = request.getSiteUserId();// 等待查询的站点用户ID || globalUserId String userIdPubk = request.getUserIdPubk(); // 等待查询的用户公钥,优先级高 LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAllEmpty(userIdPubk, globalOrSiteFriendId)) { errCode = ErrorCode2.ERROR_PARAMETER; return commandResponse.setErrCode2(errCode); } // 1.如果是siteUserId UserFriendBean userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, globalOrSiteFriendId); // 2.如果不是则认为是globalUserId if (null == userBean || StringUtils.isNotEmpty(userBean.getSiteUserId())) { String siteFriendId = UserProfileDao.getInstance().getSiteUserIdByGlobalUserId(globalOrSiteFriendId); if (StringUtils.isNotEmpty(siteFriendId)) { userBean = UserProfileDao.getInstance().getFriendProfileById(siteUserId, siteFriendId); } } if (userBean != null && StringUtils.isNotBlank(userBean.getSiteUserId())) { UserProto.UserProfile.Builder friendProfileBuilder = UserProto.UserProfile.newBuilder(); friendProfileBuilder.setSiteUserId(userBean.getSiteUserId()); friendProfileBuilder.setUserIdPubk(userBean.getUserIdPubk()); if (StringUtils.isNotEmpty(userBean.getAliasName())) { friendProfileBuilder.setUserName(userBean.getAliasName()); if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setNickName(userBean.getUserName()); } } else { if (StringUtils.isNotEmpty(userBean.getUserName())) { friendProfileBuilder.setUserName(userBean.getUserName()); friendProfileBuilder.setNickName(userBean.getUserName()); } } if (StringUtils.isNotEmpty(userBean.getSiteLoginId())) { friendProfileBuilder.setSiteLoginId(userBean.getSiteLoginId()); } if (StringUtils.isNotEmpty(userBean.getUserPhoto())) { friendProfileBuilder.setUserPhoto(userBean.getUserPhoto()); } friendProfileBuilder.setUserStatusValue(userBean.getUserStatus()); UserProto.UserProfile friendProfile = friendProfileBuilder.build(); // 查关系 UserProto.UserRelation userRelation = UserFriendDao.getInstance().getUserRelation(siteUserId, userBean.getSiteUserId()); ApiFriendProfileProto.ApiFriendProfileResponse response = ApiFriendProfileProto.ApiFriendProfileResponse .newBuilder().setProfile(friendProfile).setRelation(userRelation) .setUserIdPubk(userBean.getUserIdPubk()).build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } } catch (Exception e) { errCode = ErrorCode2.ERROR_SYSTEMERROR; LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode2(errCode); }
Example 8
Source File: ApiGroupService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 获取群资料信息,一般由以下几部分组成 <br> * 1.群资料GroupProfile <br> * 2.群主基本资料GroupMaster,群主通过GroupProfile获取 <br> * 3.群成员人数以及排在最前列的四位用户 <br> * 4.无权限限制 * * @param command * @return */ public CommandResponse profile(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String groupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, groupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(groupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId); if (groupBean == null || StringUtils.isEmpty(groupBean.getGroupId())) { throw new ZalyException(ErrorCode2.ERROR_GROUP_QUERY_PROFILE); } SimpleUserBean ownerProfileBean = UserProfileDao.getInstance() .getSimpleProfileById(groupBean.getCreateUserId()); logger.debug("get groupId={},groupOwner={}", groupId, ownerProfileBean.toString()); int groupMembersCount = UserGroupDao.getInstance().getGroupMemberCount(groupId); logger.debug("get groupId={},groupMembers={}", groupId, groupMembersCount); List<GroupMemberBean> groupMemberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize); UserProto.UserProfile ownerProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(ownerProfileBean.getUserId())) .setUserPhoto(String.valueOf(ownerProfileBean.getUserPhoto())) .setUserName(String.valueOf(ownerProfileBean.getUserName())).build(); GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder().setId(groupBean.getGroupId()) .setName(String.valueOf(groupBean.getGroupName())) .setIcon(String.valueOf(groupBean.getGroupPhoto())).build(); ApiGroupProfileProto.ApiGroupProfileResponse.Builder responseBuilder = ApiGroupProfileProto.ApiGroupProfileResponse .newBuilder(); responseBuilder.setOwner(ownerProfile); responseBuilder.setProfile(groupProfile); responseBuilder.setGroupMemberCount(groupMembersCount); for (GroupMemberBean memberBean : groupMemberList) { UserProto.UserProfile memberProfile = UserProto.UserProfile.newBuilder() .setSiteUserId(String.valueOf(memberBean.getUserId())) .setUserPhoto(String.valueOf(memberBean.getUserPhoto())) .setUserName(String.valueOf(memberBean.getUserName())).build(); GroupProto.GroupMemberProfile groupMemberProfile = GroupProto.GroupMemberProfile.newBuilder() .setProfile(memberProfile).build(); responseBuilder.addGroupLastestMember(groupMemberProfile); } // 是否可以邀请群聊(除了群主以外) responseBuilder.setCloseInviteGroupChat(groupBean.isCloseInviteGroupChat()); ApiGroupProfileProto.ApiGroupProfileResponse response = responseBuilder.build(); commandResponse.setParams(response.toByteArray()); errCode = ErrorCode2.SUCCESS; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }
Example 9
Source File: ApiGroupService.java From openzaly with Apache License 2.0 | 4 votes |
/** * 获取群成员 <br> * 无权限控制 * * @param command * @return */ public CommandResponse members(Command command) { CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES); IErrorCode errCode = ErrorCode2.ERROR; try { ApiGroupMembersProto.ApiGroupMembersRequest request = ApiGroupMembersProto.ApiGroupMembersRequest .parseFrom(command.getParams()); String siteUserId = command.getSiteUserId(); String siteGroupId = request.getGroupId(); int pageNum = 1; int pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT; LogUtils.requestDebugLog(logger, command, request.toString()); if (StringUtils.isAnyEmpty(siteUserId, siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_PARAMETER); } if (!checkGroupStatus(siteGroupId)) { throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED); } List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(siteGroupId, 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; } catch (Exception e) { if (e instanceof ZalyException) { errCode = ((ZalyException) e).getErrCode(); } else { errCode = ErrorCode2.ERROR_SYSTEMERROR; } LogUtils.requestErrorLog(logger, command, e); } return commandResponse.setErrCode(errCode); }