Java Code Examples for com.akaxin.proto.site.ApiGroupProfileProto#ApiGroupProfileRequest

The following examples show how to use com.akaxin.proto.site.ApiGroupProfileProto#ApiGroupProfileRequest . 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: ApiGroupService.java    From wind-im with Apache License 2.0 4 votes vote down vote up
/**
 * 获取群资料信息,一般由以下几部分组成 <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 2
Source File: ApiGroupService.java    From openzaly with Apache License 2.0 4 votes vote down vote up
/**
 * 获取群资料信息,一般由以下几部分组成 <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 openzaly with Apache License 2.0 4 votes vote down vote up
/**
 * 获取群资料信息,一般由以下几部分组成 <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);
}