use of com.akaxin.site.storage.bean.GroupMemberBean in project openzaly by akaxincom.
the class ApiGroupService method profile.
/**
* 获取群资料信息,一般由以下几部分组成 <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);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupProfileProto.ApiGroupProfileRequest request = ApiGroupProfileProto.ApiGroupProfileRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = 1;
int pageSize = GroupConfig.GROUP_MIN_MEMBER_COUNT;
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(groupId)) {
GroupProfileBean groupBean = UserGroupDao.getInstance().getGroupProfile(groupId);
if (groupBean != null && StringUtils.isNotBlank(groupBean.getGroupId())) {
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;
}
} 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.site.storage.bean.GroupMemberBean in project openzaly by akaxincom.
the class SQLiteUserGroupDao method getGroupMember.
public GroupMemberBean getGroupMember(String siteUserId, String groupId) throws SQLException {
long startTime = System.currentTimeMillis();
String sql = "SELECT site_user_id,user_role FROM " + USER_GROUP_TABLE + " WHERE site_user_id=? AND site_group_id=?;";
PreparedStatement preStatement = SQLiteJDBCManager.getConnection().prepareStatement(sql);
preStatement.setString(1, siteUserId);
preStatement.setString(2, groupId);
ResultSet rs = preStatement.executeQuery();
GroupMemberBean member = new GroupMemberBean();
if (rs.next()) {
member.setUserId(rs.getString(1));
member.setUserRole(rs.getInt(2));
}
long endTime = System.currentTimeMillis();
LogUtils.dbDebugLog(logger, startTime, member.toString(), sql + siteUserId + "," + groupId);
return member;
}
use of com.akaxin.site.storage.bean.GroupMemberBean 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);
}
use of com.akaxin.site.storage.bean.GroupMemberBean in project openzaly by akaxincom.
the class HttpGroupService method nonmembers.
public CommandResponse nonmembers(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupNonmembersProto.HaiGroupNonmembersRequest request = HaiGroupNonmembersProto.HaiGroupNonmembersRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
LogUtils.requestDebugLog(logger, command, request.toString());
List<GroupMemberBean> memberList = UserGroupDao.getInstance().getNonGroupMemberList(groupId, pageNum, pageSize);
HaiGroupNonmembersProto.HaiGroupNonmembersResponse.Builder responseBuilder = HaiGroupNonmembersProto.HaiGroupNonmembersResponse.newBuilder();
for (GroupMemberBean member : memberList) {
GroupProto.GroupMemberRole memberRole = GroupProto.GroupMemberRole.NONMEMBER;
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.addGroupMember(groupMember);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.site.storage.bean.GroupMemberBean in project openzaly by akaxincom.
the class HttpGroupService method members.
/**
* 获取群成员列表
*
* @param command
* @return
*/
public CommandResponse members(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupMembersProto.HaiGroupMembersRequest request = HaiGroupMembersProto.HaiGroupMembersRequest.parseFrom(command.getParams());
String groupId = request.getGroupId();
int pageNum = request.getPageNumber();
int pageSize = request.getPageSize();
if (pageNum == 0 && pageSize == 0) {
pageNum = 1;
pageSize = GroupConfig.GROUP_MAX_MEMBER_COUNT;
}
LogUtils.requestDebugLog(logger, command, request.toString());
List<GroupMemberBean> memberList = UserGroupDao.getInstance().getGroupMemberList(groupId, pageNum, pageSize);
HaiGroupMembersProto.HaiGroupMembersResponse.Builder responseBuilder = HaiGroupMembersProto.HaiGroupMembersResponse.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.addGroupMember(groupMember);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations