Java Code Examples for com.akaxin.proto.core.UserProto#SimpleUserProfile

The following examples show how to use com.akaxin.proto.core.UserProto#SimpleUserProfile . 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
/**
 * 获取用户群组中,不存在的好友用户
 *
 * @param command
 * @return
 */
public CommandResponse nonMembers(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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();
		if (pageNum == 0 && pageSize == 0) {
			pageNum = 1;
			pageSize = 100;
		}
		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);
		}

		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) {
		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
/**
 * 获取用户群组中,不存在的好友用户
 *
 * @param command
 * @return
 */
public CommandResponse nonMembers(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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();
		if (pageNum == 0 && pageSize == 0) {
			pageNum = 1;
			pageSize = 100;
		}
		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);
		}

		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) {
		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
/**
 * 获取用户群组中,不存在的好友用户
 *
 * @param command
 * @return
 */
public CommandResponse nonMembers(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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();
		if (pageNum == 0 && pageSize == 0) {
			pageSize = 100;
		}
		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);
		}

		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) {
		if (e instanceof ZalyException) {
			errCode = ((ZalyException) e).getErrCode();
		} else {
			errCode = ErrorCode2.ERROR_SYSTEMERROR;
		}
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode(errCode);
}