com.akaxin.proto.core.GroupProto Java Examples

The following examples show how to use com.akaxin.proto.core.GroupProto. 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: HttpGroupService.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private GroupProto.SimpleGroupProfile getSimpleGroupProfile(SimpleGroupBean bean) {
	GroupProto.SimpleGroupProfile.Builder sgpBuilder = GroupProto.SimpleGroupProfile.newBuilder();

	if (StringUtils.isNotBlank(bean.getGroupId())) {
		sgpBuilder.setGroupId(bean.getGroupId());
	}

	if (StringUtils.isNotBlank(bean.getGroupName())) {
		sgpBuilder.setGroupName(bean.getGroupName());
	}

	if (StringUtils.isNotBlank(bean.getGroupPhoto())) {
		sgpBuilder.setGroupIcon(bean.getGroupPhoto());
	}

	return sgpBuilder.build();
}
 
Example #2
Source File: UserGroupDao.java    From wind-im with Apache License 2.0 6 votes vote down vote up
public boolean addGroupMember(String siteUserId, String groupId, List<String> userIdList) {
	try {
		// 1.获取当前,群消息最大游标
		long maxPointer = messageDao.queryMaxGroupPointer(groupId);
		// 2.设置个人默认游标
		// 3.增加群成员
		for (String memberId : userIdList) {
			messageDao.updateGroupPointer(groupId, memberId, null, maxPointer);
			int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
			if (!groupDao.addGroupMember(memberId, groupId, status)) {
				return false;
			}
		}
		// 添加完用户,向群消息中添加GroupMsgNotice
		new GroupNotice().addGroupMemberNotice(siteUserId, groupId, userIdList);
		return true;
	} catch (Exception e) {
		logger.error("add group member error.", e);
	}
	return false;
}
 
Example #3
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public boolean addDefaultGroupMember(String defaultGroupId, String siteUserId) {
	try {
		// 1.获取当前,群消息最大游标
		long maxPointer = messageDao.queryMaxGroupPointer(defaultGroupId);
		// 2.设置个人默认游标
		// 3.增加群成员
		messageDao.updateGroupPointer(defaultGroupId, siteUserId, null, maxPointer);
		int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
		if (!groupDao.addGroupMember(siteUserId, defaultGroupId, status)) {
			return false;
		}
		// 添加完用户,向群消息中添加GroupMsgNotice
		new GroupNotice().addDefaultGroupMemberNotice(defaultGroupId, siteUserId);
		return true;
	} catch (Exception e) {
		logger.error("add group member error.", e);
	}
	return false;
}
 
Example #4
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public boolean addGroupMember(String siteUserId, String groupId, List<String> userIdList) {
	try {
		// 1.获取当前,群消息最大游标
		long maxPointer = messageDao.queryMaxGroupPointer(groupId);
		// 2.设置个人默认游标
		// 3.增加群成员
		for (String memberId : userIdList) {
			messageDao.updateGroupPointer(groupId, memberId, null, maxPointer);
			int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
			if (!groupDao.addGroupMember(memberId, groupId, status)) {
				return false;
			}
		}
		// 添加完用户,向群消息中添加GroupMsgNotice
		new GroupNotice().addGroupMemberNotice(siteUserId, groupId, userIdList);
		return true;
	} catch (Exception e) {
		logger.error("add group member error.", e);
	}
	return false;
}
 
Example #5
Source File: HttpGroupService.java    From wind-im with Apache License 2.0 6 votes vote down vote up
private GroupProto.SimpleGroupProfile getSimpleGroupProfile(SimpleGroupBean bean) {
	GroupProto.SimpleGroupProfile.Builder sgpBuilder = GroupProto.SimpleGroupProfile.newBuilder();

	if (StringUtils.isNotBlank(bean.getGroupId())) {
		sgpBuilder.setGroupId(bean.getGroupId());
	}

	if (StringUtils.isNotBlank(bean.getGroupName())) {
		sgpBuilder.setGroupName(bean.getGroupName());
	}

	if (StringUtils.isNotBlank(bean.getGroupPhoto())) {
		sgpBuilder.setGroupIcon(bean.getGroupPhoto());
	}

	return sgpBuilder.build();
}
 
Example #6
Source File: HttpGroupService.java    From openzaly with Apache License 2.0 6 votes vote down vote up
private GroupProto.SimpleGroupProfile getSimpleGroupProfile(SimpleGroupBean bean) {
	GroupProto.SimpleGroupProfile.Builder sgpBuilder = GroupProto.SimpleGroupProfile.newBuilder();

	if (StringUtils.isNotBlank(bean.getGroupId())) {
		sgpBuilder.setGroupId(bean.getGroupId());
	}

	if (StringUtils.isNotBlank(bean.getGroupName())) {
		sgpBuilder.setGroupName(bean.getGroupName());
	}

	if (StringUtils.isNotBlank(bean.getGroupPhoto())) {
		sgpBuilder.setGroupIcon(bean.getGroupPhoto());
	}

	return sgpBuilder.build();
}
 
Example #7
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public boolean addGroupMember(String siteUserId, String groupId, List<String> userIdList) {
	try {
		// 1.获取当前,群消息最大游标
		long maxPointer = messageDao.queryMaxGroupPointer(groupId);
		// 2.设置个人默认游标
		// 3.增加群成员
		for (String memberId : userIdList) {
			messageDao.updateGroupPointer(groupId, memberId, null, maxPointer);
			int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
			if (!groupDao.addGroupMember(memberId, groupId, status)) {
				return false;
			}
		}
		// 添加完用户,向群消息中添加GroupMsgNotice
		new GroupNotice().addGroupMemberNotice(siteUserId, groupId, userIdList);
		return true;
	} catch (Exception e) {
		logger.error("add group member error.", e);
	}
	return false;
}
 
Example #8
Source File: ApiGroupService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
/**
 * 获取用户群列表 <br>
 * 无权限限制
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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().getUserGroupList(siteUserId);
			ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse
					.newBuilder();
			for (SimpleGroupBean groupBean : groupBeanList) {
				GroupProto.SimpleGroupProfile.Builder groupProfileBuilder = GroupProto.SimpleGroupProfile
						.newBuilder();
				groupProfileBuilder.setGroupId(groupBean.getGroupId());
				if (StringUtils.isNotEmpty(groupBean.getGroupName())) {
					groupProfileBuilder.setGroupName(groupBean.getGroupName());
				}
				if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) {
					groupProfileBuilder.setGroupIcon(groupBean.getGroupPhoto());
				}
				responseBuilder.addList(groupProfileBuilder.build());
			}
			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.setErrCode(errCode);
}
 
Example #9
Source File: HttpGroupService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
/**
 * /hai/group/profile : 获取群组资料
 * 
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest
				.parseFrom(command.getParams());
		String groupId = request.getGroupId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);

		if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
			GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder()
					.setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName()))
					.setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
			HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse
					.newBuilder();
			responseBuilder.setProfile(groupProfile);
			commandResponse.setParams(responseBuilder.build().toByteArray());
			errCode = ErrorCode2.SUCCESS;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}
 
Example #10
Source File: ApiGroupService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
/**
 * 获取用户群列表 <br>
 * 无权限限制
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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().getUserGroupList(siteUserId);
			ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse
					.newBuilder();
			for (SimpleGroupBean groupBean : groupBeanList) {
				GroupProto.SimpleGroupProfile.Builder groupProfileBuilder = GroupProto.SimpleGroupProfile
						.newBuilder();
				groupProfileBuilder.setGroupId(groupBean.getGroupId());
				if (StringUtils.isNotEmpty(groupBean.getGroupName())) {
					groupProfileBuilder.setGroupName(groupBean.getGroupName());
				}
				if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) {
					groupProfileBuilder.setGroupIcon(groupBean.getGroupPhoto());
				}
				responseBuilder.addList(groupProfileBuilder.build());
			}
			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.setErrCode(errCode);
}
 
Example #11
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public GroupProfileBean createGroup(String createUserId, String groupName, List<String> userIds) {
	GroupProfileBean bean = new GroupProfileBean();
	try {
		bean.setCreateTime(System.currentTimeMillis());
		bean.setGroupName(groupName);
		bean.setCreateUserId(createUserId);
		// 群头像使用默认
		// bean.setGroupPhoto(GROUP_DEFAULT_ICON);
		bean.setGroupStatus(GroupProto.GroupStatus.GROUP_NORMAL_VALUE);
		// 1.创建群资料
		bean = groupDao.addGroupProfile(bean);
		// 2.添加群成员入库
		if (bean != null) {
			for (String memberId : userIds) {
				int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
				if (createUserId.equals(memberId)) {
					status = GroupProto.GroupMemberRole.OWNER_VALUE;
				}
				groupDao.addGroupMember(memberId, bean.getGroupId(), status);
			}
			// 3.群消息中发送通知
			new GroupNotice().addGroupMemberNotice(createUserId, bean.getGroupId(), userIds);
		}
	} catch (Exception e) {
		// 事务回滚,删除操作
		// 删除1.群资料
		// 删除2.群成员
		logger.error("create group error.", e);
	}
	return bean;
}
 
Example #12
Source File: SiteUserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public List<GroupMemberBean> queryNonGroupMemberList(String groupId, int pageNum, int pageSize)
		throws SQLException {
	long startTime = System.currentTimeMillis();
	List<GroupMemberBean> membersList = new ArrayList<GroupMemberBean>();
	int startNum = (pageNum - 1) * pageSize;
	String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + SQLConst.SITE_USER_PROFILE
			+ " WHERE site_user_id NOT IN (SELECT DISTINCT site_user_id FROM " + SQLConst.SITE_USER_GROUP
			+ " WHERE site_group_id=?) LIMIT ?,?;";

	Connection conn = null;
	PreparedStatement pst = null;
	ResultSet rs = null;
	try {
		conn = DatabaseConnection.getSlaveConnection();
		pst = conn.prepareStatement(sql);
		pst.setString(1, groupId);
		pst.setInt(2, startNum);
		pst.setInt(3, pageSize);

		rs = pst.executeQuery();
		while (rs.next()) {
			GroupMemberBean member = new GroupMemberBean();
			member.setUserId(rs.getString(1));
			member.setUserName(rs.getString(2));
			member.setUserPhoto(rs.getString(3));
			member.setUserStatus(rs.getInt(4));
			member.setUserRole(GroupProto.GroupMemberRole.NONMEMBER_VALUE);
			membersList.add(member);
		}
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, pst, rs);
	}

	LogUtils.dbDebugLog(logger, startTime, membersList.toString(), sql, groupId, startNum, pageSize);
	return membersList;
}
 
Example #13
Source File: SiteUserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public boolean insertGroupMember(String siteUserId, String groupId, int status) throws SQLException {
	long startTime = System.currentTimeMillis();
	String sql = "INSERT INTO " + USER_GROUP_TABLE
			+ "(site_user_id,site_group_id,user_role,add_time) VALUES(?,?,?,?);";

	int result = 0;
	Connection conn = null;
	PreparedStatement ps = null;
	try {
		conn = DatabaseConnection.getConnection();
		ps = conn.prepareStatement(sql);
		ps.setString(1, siteUserId);
		ps.setString(2, groupId);
		ps.setInt(3, GroupProto.GroupMemberRole.OWNER_VALUE);
		ps.setLong(4, System.currentTimeMillis());

		result = ps.executeUpdate();
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, ps);
	}

	LogUtils.dbDebugLog(logger, startTime, result, sql, siteUserId, groupId,
			GroupProto.GroupMemberRole.OWNER_VALUE);
	return result > 0;
}
 
Example #14
Source File: HttpGroupService.java    From openzaly with Apache License 2.0 5 votes vote down vote up
/**
 * /hai/group/profile : 获取群组资料
 * 
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest
				.parseFrom(command.getParams());
		String groupId = request.getGroupId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);

		if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
			GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder()
					.setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName()))
					.setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
			HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse
					.newBuilder();
			responseBuilder.setProfile(groupProfile);
			commandResponse.setParams(responseBuilder.build().toByteArray());
			errCode = ErrorCode2.SUCCESS;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}
 
Example #15
Source File: SiteUserGroupDao.java    From wind-im with Apache License 2.0 5 votes vote down vote up
public boolean insertGroupMember(String siteUserId, String groupId, int status) throws SQLException {
	long startTime = System.currentTimeMillis();
	String sql = "INSERT INTO " + USER_GROUP_TABLE
			+ "(site_user_id,site_group_id,user_role,add_time) VALUES(?,?,?,?);";

	int result = 0;
	Connection conn = null;
	PreparedStatement ps = null;
	try {
		conn = DatabaseConnection.getConnection();
		ps = conn.prepareStatement(sql);
		ps.setString(1, siteUserId);
		ps.setString(2, groupId);
		ps.setInt(3, GroupProto.GroupMemberRole.OWNER_VALUE);
		ps.setLong(4, System.currentTimeMillis());

		result = ps.executeUpdate();
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, ps);
	}

	LogUtils.dbDebugLog(logger, startTime, result, sql, siteUserId, groupId,
			GroupProto.GroupMemberRole.OWNER_VALUE);
	return result > 0;
}
 
Example #16
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public GroupProfileBean createGroup(String createUserId, String groupName, List<String> userIds) {
	GroupProfileBean bean = new GroupProfileBean();
	try {
		bean.setCreateTime(System.currentTimeMillis());
		bean.setGroupName(groupName);
		bean.setCreateUserId(createUserId);
		// 群头像使用默认
		// bean.setGroupPhoto(GROUP_DEFAULT_ICON);
		bean.setGroupStatus(GroupProto.GroupStatus.GROUP_NORMAL_VALUE);
		// 1.创建群资料
		bean = groupDao.addGroupProfile(bean);
		// 2.添加群成员入库
		if (bean != null) {
			for (String memberId : userIds) {
				int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
				if (createUserId.equals(memberId)) {
					status = GroupProto.GroupMemberRole.OWNER_VALUE;
				}
				groupDao.addGroupMember(memberId, bean.getGroupId(), status);
			}
			// 3.群消息中发送通知
			new GroupNotice().addGroupMemberNotice(createUserId, bean.getGroupId(), userIds);
		}
	} catch (Exception e) {
		// 事务回滚,删除操作
		// 删除1.群资料
		// 删除2.群成员
		logger.error("create group error.", e);
	}
	return bean;
}
 
Example #17
Source File: SiteUserGroupDao.java    From wind-im with Apache License 2.0 5 votes vote down vote up
public List<GroupMemberBean> queryNonGroupMemberList(String groupId, int pageNum, int pageSize)
		throws SQLException {
	long startTime = System.currentTimeMillis();
	List<GroupMemberBean> membersList = new ArrayList<GroupMemberBean>();
	int startNum = (pageNum - 1) * pageSize;
	String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + SQLConst.SITE_USER_PROFILE
			+ " WHERE site_user_id NOT IN (SELECT DISTINCT site_user_id FROM " + SQLConst.SITE_USER_GROUP
			+ " WHERE site_group_id=?) LIMIT ?,?;";

	Connection conn = null;
	PreparedStatement pst = null;
	ResultSet rs = null;
	try {
		conn = DatabaseConnection.getSlaveConnection();
		pst = conn.prepareStatement(sql);
		pst.setString(1, groupId);
		pst.setInt(2, startNum);
		pst.setInt(3, pageSize);

		rs = pst.executeQuery();
		while (rs.next()) {
			GroupMemberBean member = new GroupMemberBean();
			member.setUserId(rs.getString(1));
			member.setUserName(rs.getString(2));
			member.setUserPhoto(rs.getString(3));
			member.setUserStatus(rs.getInt(4));
			member.setUserRole(GroupProto.GroupMemberRole.NONMEMBER_VALUE);
			membersList.add(member);
		}
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, pst, rs);
	}

	LogUtils.dbDebugLog(logger, startTime, membersList.toString(), sql, groupId, startNum, pageSize);
	return membersList;
}
 
Example #18
Source File: UserGroupDao.java    From wind-im with Apache License 2.0 5 votes vote down vote up
public GroupProfileBean createGroup(String createUserId, String groupName, List<String> userIds) {
	GroupProfileBean bean = new GroupProfileBean();
	try {
		bean.setCreateTime(System.currentTimeMillis());
		bean.setGroupName(groupName);
		bean.setCreateUserId(createUserId);
		// 群头像使用默认
		// bean.setGroupPhoto(GROUP_DEFAULT_ICON);
		bean.setGroupStatus(GroupProto.GroupStatus.GROUP_NORMAL_VALUE);
		// 1.创建群资料
		bean = groupDao.addGroupProfile(bean);
		// 2.添加群成员入库
		if (bean != null) {
			for (String memberId : userIds) {
				int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
				if (createUserId.equals(memberId)) {
					status = GroupProto.GroupMemberRole.OWNER_VALUE;
				}
				groupDao.addGroupMember(memberId, bean.getGroupId(), status);
			}
			// 3.群消息中发送通知
			new GroupNotice().addGroupMemberNotice(createUserId, bean.getGroupId(), userIds);
		}
	} catch (Exception e) {
		// 事务回滚,删除操作
		// 删除1.群资料
		// 删除2.群成员
		logger.error("create group error.", e);
	}
	return bean;
}
 
Example #19
Source File: UserGroupDao.java    From wind-im with Apache License 2.0 5 votes vote down vote up
private boolean addGroupMember(String siteGroupId, String siteUserId) throws SQLException {
	// 1.获取当前,群消息最大游标
	long maxPointer = messageDao.queryMaxGroupPointer(siteGroupId);
	// 2.设置个人默认游标
	// 3.增加群成员
	messageDao.updateGroupPointer(siteGroupId, siteUserId, null, maxPointer);
	int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
	return groupDao.addGroupMember(siteUserId, siteGroupId, status);
}
 
Example #20
Source File: ApiGroupService.java    From wind-im with Apache License 2.0 5 votes vote down vote up
/**
 * 获取用户群列表 <br>
 * 无权限限制
 *
 * @param command
 * @return
 */
public CommandResponse list(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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().getUserGroupList(siteUserId);
			ApiGroupListProto.ApiGroupListResponse.Builder responseBuilder = ApiGroupListProto.ApiGroupListResponse
					.newBuilder();
			for (SimpleGroupBean groupBean : groupBeanList) {
				GroupProto.SimpleGroupProfile.Builder groupProfileBuilder = GroupProto.SimpleGroupProfile
						.newBuilder();
				groupProfileBuilder.setGroupId(groupBean.getGroupId());
				if (StringUtils.isNotEmpty(groupBean.getGroupName())) {
					groupProfileBuilder.setGroupName(groupBean.getGroupName());
				}
				if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) {
					groupProfileBuilder.setGroupIcon(groupBean.getGroupPhoto());
				}
				responseBuilder.addList(groupProfileBuilder.build());
			}
			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.setErrCode(errCode);
}
 
Example #21
Source File: HttpGroupService.java    From wind-im with Apache License 2.0 5 votes vote down vote up
/**
 * /hai/group/profile : 获取群组资料
 * 
 * @param command
 * @return
 */
public CommandResponse profile(Command command) {
	CommandResponse commandResponse = new CommandResponse();
	ErrorCode2 errCode = ErrorCode2.ERROR;
	try {
		HaiGroupProfileProto.HaiGroupProfileRequest request = HaiGroupProfileProto.HaiGroupProfileRequest
				.parseFrom(command.getParams());
		String groupId = request.getGroupId();
		LogUtils.requestDebugLog(logger, command, request.toString());

		GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);

		if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
			GroupProto.GroupProfile groupProfile = GroupProto.GroupProfile.newBuilder()
					.setId(groupBean.getGroupId()).setName(String.valueOf(groupBean.getGroupName()))
					.setIcon(String.valueOf(groupBean.getGroupPhoto())).build();
			HaiGroupProfileProto.HaiGroupProfileResponse.Builder responseBuilder = HaiGroupProfileProto.HaiGroupProfileResponse
					.newBuilder();
			responseBuilder.setProfile(groupProfile);
			commandResponse.setParams(responseBuilder.build().toByteArray());
			errCode = ErrorCode2.SUCCESS;
		}
	} catch (Exception e) {
		errCode = ErrorCode2.ERROR_SYSTEMERROR;
		LogUtils.requestErrorLog(logger, command, e);
	}
	return commandResponse.setErrCode2(errCode);
}
 
Example #22
Source File: SiteUserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public boolean insertGroupMember(String siteUserId, String groupId, int status) throws SQLException {
	long startTime = System.currentTimeMillis();
	String sql = "INSERT INTO " + USER_GROUP_TABLE
			+ "(site_user_id,site_group_id,user_role,add_time) VALUES(?,?,?,?);";

	int result = 0;
	Connection conn = null;
	PreparedStatement ps = null;
	try {
		conn = DatabaseConnection.getConnection();
		ps = conn.prepareStatement(sql);
		ps.setString(1, siteUserId);
		ps.setString(2, groupId);
		ps.setInt(3, GroupProto.GroupMemberRole.OWNER_VALUE);
		ps.setLong(4, System.currentTimeMillis());

		result = ps.executeUpdate();
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, ps);
	}

	LogUtils.dbDebugLog(logger, startTime, result, sql, siteUserId, groupId,
			GroupProto.GroupMemberRole.OWNER_VALUE);
	return result > 0;
}
 
Example #23
Source File: SiteUserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public List<GroupMemberBean> queryNonGroupMemberList(String groupId, int pageNum, int pageSize)
		throws SQLException {
	long startTime = System.currentTimeMillis();
	List<GroupMemberBean> membersList = new ArrayList<GroupMemberBean>();
	int startNum = (pageNum - 1) * pageSize;
	String sql = "SELECT site_user_id,user_name,user_photo,user_status FROM " + SQLConst.SITE_USER_PROFILE
			+ " WHERE site_user_id NOT IN (SELECT DISTINCT site_user_id FROM " + SQLConst.SITE_USER_GROUP
			+ " WHERE site_group_id=?) LIMIT ?,?;";

	Connection conn = null;
	PreparedStatement pst = null;
	ResultSet rs = null;
	try {
		conn = DatabaseConnection.getSlaveConnection();
		pst = conn.prepareStatement(sql);
		pst.setString(1, groupId);
		pst.setInt(2, startNum);
		pst.setInt(3, pageSize);

		rs = pst.executeQuery();
		while (rs.next()) {
			GroupMemberBean member = new GroupMemberBean();
			member.setUserId(rs.getString(1));
			member.setUserName(rs.getString(2));
			member.setUserPhoto(rs.getString(3));
			member.setUserStatus(rs.getInt(4));
			member.setUserRole(GroupProto.GroupMemberRole.NONMEMBER_VALUE);
			membersList.add(member);
		}
	} catch (Exception e) {
		throw e;
	} finally {
		DatabaseConnection.returnConnection(conn, pst, rs);
	}

	LogUtils.dbDebugLog(logger, startTime, membersList.toString(), sql, groupId, startNum, pageSize);
	return membersList;
}
 
Example #24
Source File: UserGroupDao.java    From openzaly with Apache License 2.0 5 votes vote down vote up
private boolean addGroupMember(String siteGroupId, String siteUserId) throws SQLException {
	// 1.获取当前,群消息最大游标
	long maxPointer = messageDao.queryMaxGroupPointer(siteGroupId);
	// 2.设置个人默认游标
	// 3.增加群成员
	messageDao.updateGroupPointer(siteGroupId, siteUserId, null, maxPointer);
	int status = GroupProto.GroupMemberRole.MEMBER_VALUE;
	return groupDao.addGroupMember(siteUserId, siteGroupId, status);
}
 
Example #25
Source File: ApiGroupService.java    From wind-im with Apache License 2.0 4 votes vote down vote up
/**
 * 获取群成员 <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 #26
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 #27
Source File: ApiGroupService.java    From wind-im with Apache License 2.0 4 votes vote down vote up
/**
 * 用户创建群,并添加初始群成员 <br>
 * 无权限限制
 *
 * @param command
 * @return
 */
public CommandResponse create(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode errCode = ErrorCode2.ERROR;
	try {
		ApiGroupCreateProto.ApiGroupCreateRequest request = ApiGroupCreateProto.ApiGroupCreateRequest
				.parseFrom(command.getParams());
		String siteUserId = command.getSiteUserId();// group owner
		String groupName = request.getGroupName();
		ProtocolStringList groupMembers = request.getSiteUserIdsList();
		List<String> groupMemberIds = Lists.newArrayList(groupMembers);// copy a new list
		LogUtils.requestDebugLog(logger, command, request.toString());

		if (StringUtils.isAnyEmpty(siteUserId, groupName) || groupMemberIds == null) {
			throw new ZalyException(ErrorCode2.ERROR_PARAMETER);
		}

		if (!SiteConfig.allowCreateGroups(siteUserId)) {
			throw new ZalyException(ErrorCode2.ERROR2_GROUP_NOTALLOW);
		}
		// 检查用户是否被封禁,或者不存在
		for (String groupMemberId : groupMemberIds) {
			SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId);
			if (bean == null || bean.getUserStatus() == 1) {
				groupMemberIds.remove(groupMemberId);
			}
		}

		if (!groupMemberIds.contains(siteUserId)) {
			groupMemberIds.add(siteUserId);
		}

		if (groupMemberIds.size() < 3) {
			throw new ZalyException(ErrorCode2.ERROR_GROUP_MEMBERLESS3);
		}

		GroupProfileBean groupBean = UserGroupDao.getInstance().createGroup(siteUserId, groupName, groupMemberIds);
		if (groupBean != null && StringUtils.isNotEmpty(groupBean.getGroupId())) {
			GroupProto.GroupProfile.Builder groupProfileBuilder = GroupProto.GroupProfile.newBuilder();
			groupProfileBuilder.setId(groupBean.getGroupId());
			if (StringUtils.isNotEmpty(groupBean.getGroupName())) {
				groupProfileBuilder.setName(groupBean.getGroupName());
			}
			if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) {
				groupProfileBuilder.setIcon(String.valueOf(groupBean.getGroupPhoto()));
			}

			ApiGroupCreateProto.ApiGroupCreateResponse response = ApiGroupCreateProto.ApiGroupCreateResponse
					.newBuilder().setProfile(groupProfileBuilder.build()).build();
			commandResponse.setParams(response.toByteArray());
			errCode = ErrorCode2.SUCCESS;
		} else {
			errCode = ErrorCode2.ERROR_GROUP_WHEN_CREATE;
		}

	} 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 #28
Source File: ApiGroupService.java    From openzaly with Apache License 2.0 4 votes vote down vote up
/**
 * 获取群成员 <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 #29
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 #30
Source File: ApiGroupService.java    From openzaly with Apache License 2.0 4 votes vote down vote up
/**
 * 用户创建群,并添加初始群成员 <br>
 * 无权限限制
 *
 * @param command
 * @return
 */
public CommandResponse create(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode errCode = ErrorCode2.ERROR;
	try {
		ApiGroupCreateProto.ApiGroupCreateRequest request = ApiGroupCreateProto.ApiGroupCreateRequest
				.parseFrom(command.getParams());
		String siteUserId = command.getSiteUserId();// group owner
		String groupName = request.getGroupName();
		ProtocolStringList groupMembers = request.getSiteUserIdsList();
		List<String> groupMemberIds = Lists.newArrayList(groupMembers);// copy a new list
		LogUtils.requestDebugLog(logger, command, request.toString());

		if (StringUtils.isAnyEmpty(siteUserId, groupName) || groupMemberIds == null) {
			throw new ZalyException(ErrorCode2.ERROR_PARAMETER);
		}

		// 检查用户是否被封禁,或者不存在
		for (String groupMemberId : groupMemberIds) {
			SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(groupMemberId);
			if (bean == null || bean.getUserStatus() == 1) {
				groupMemberIds.remove(groupMemberId);
			}
		}

		if (!groupMemberIds.contains(siteUserId)) {
			groupMemberIds.add(siteUserId);
		}

		if (groupMemberIds.size() < 3) {
			throw new ZalyException(ErrorCode2.ERROR_GROUP_MEMBERLESS3);
		}

		GroupProfileBean groupBean = UserGroupDao.getInstance().createGroup(siteUserId, groupName, groupMemberIds);
		if (groupBean != null && StringUtils.isNotEmpty(groupBean.getGroupId())) {
			GroupProto.GroupProfile.Builder groupProfileBuilder = GroupProto.GroupProfile.newBuilder();
			groupProfileBuilder.setId(groupBean.getGroupId());
			if (StringUtils.isNotEmpty(groupBean.getGroupName())) {
				groupProfileBuilder.setName(groupBean.getGroupName());
			}
			if (StringUtils.isNotEmpty(groupBean.getGroupPhoto())) {
				groupProfileBuilder.setIcon(String.valueOf(groupBean.getGroupPhoto()));
			}

			ApiGroupCreateProto.ApiGroupCreateResponse response = ApiGroupCreateProto.ApiGroupCreateResponse
					.newBuilder().setProfile(groupProfileBuilder.build()).build();
			commandResponse.setParams(response.toByteArray());
			errCode = ErrorCode2.SUCCESS;
		} else {
			errCode = ErrorCode2.ERROR_GROUP_WHEN_CREATE;
		}

	} 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);
}