use of com.akaxin.site.storage.bean.GroupProfileBean in project openzaly by akaxincom.
the class ApiGroupService method updateProfile.
/**
* 用户更新群资料<br>
* 群主/管理员权限限制
*
* @param command
* @return
*/
public CommandResponse updateProfile(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest request = ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getProfile().getId();
String photoId = request.getProfile().getIcon();
String groupName = request.getProfile().getName();
String groupNotice = request.getProfile().getGroupNotice();
// 新的群群主
String newGroupOwner = request.getNewGroupOwner();
// 是否可以邀请群聊(除了群主以外的其他群成员)
boolean closeInviteGroupChat = request.getCloseInviteGroupChat();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(groupId)) {
String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(groupMasterId)) {
GroupProfileBean gprofileBean = new GroupProfileBean();
gprofileBean.setGroupId(groupId);
gprofileBean.setGroupName(groupName);
gprofileBean.setGroupPhoto(photoId);
gprofileBean.setGroupNotice(groupNotice);
gprofileBean.setCreateUserId(newGroupOwner);
gprofileBean.setCloseInviteGroupChat(closeInviteGroupChat);
if (StringUtils.isNotEmpty(groupName)) {
if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
if (UserGroupDao.getInstance().updateGroupIGC(gprofileBean)) {
errCode = ErrorCode2.SUCCESS;
}
}
} else {
errCode = ErrorCode2.ERROR_NOPERMISSION;
}
} 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.GroupProfileBean in project openzaly by akaxincom.
the class ApiGroupService method addMember.
/**
* 添加群成员,支持群成员拉取好友进群,因此无群主权限限制<br>
* 无管理员权限限制 -> 添加群资料中是否允许添加成员
*
* @param command
* @return
*/
public CommandResponse addMember(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupAddMemberProto.ApiGroupAddMemberRequest request = ApiGroupAddMemberProto.ApiGroupAddMemberRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
ProtocolStringList addMemberList = request.getUserListList();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(groupId) && addMemberList != null) {
GroupProfileBean bean = UserGroupDao.getInstance().getGroupProfile(groupId);
// 先校验权限
if (checkAddMemberPermission(siteUserId, bean)) {
int currentSize = UserGroupDao.getInstance().getGroupMemberCount(groupId);
int maxSize = SiteConfig.getMaxGroupMemberSize();
if (currentSize + addMemberList.size() <= maxSize) {
if (UserGroupDao.getInstance().addGroupMember(siteUserId, groupId, addMemberList)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_GROUP_MAXMEMBERCOUNT;
}
} else {
errCode = ErrorCode2.ERROR_GROUP_INVITE_CHAT_CLOSE;
}
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.site.storage.bean.GroupProfileBean in project openzaly by akaxincom.
the class ApiGroupService method create.
/**
* 用户创建群,并添加初始群成员 <br>
* 无权限限制
*
* @param command
* @return
*/
public CommandResponse create(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupCreateProto.ApiGroupCreateRequest request = ApiGroupCreateProto.ApiGroupCreateRequest.parseFrom(command.getParams());
String groupName = request.getGroupName();
ProtocolStringList groupMemberIds = request.getSiteUserIdsList();
String createUserId = command.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotEmpty(createUserId) && groupMemberIds != null) {
if (groupMemberIds.size() >= 3) {
if (!groupMemberIds.contains(createUserId)) {
groupMemberIds.add(createUserId);
}
GroupProfileBean groupBean = UserGroupDao.getInstance().createGroup(createUserId, groupName, groupMemberIds);
if (StringUtils.isNotEmpty(groupBean.getGroupId())) {
GroupProto.GroupProfile.Builder groupProfileBuilder = GroupProto.GroupProfile.newBuilder();
groupProfileBuilder.setId(String.valueOf(groupBean.getGroupId()));
groupProfileBuilder.setName(String.valueOf(groupBean.getGroupName()));
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_MEMBERLESS3;
}
} 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.GroupProfileBean 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.GroupProfileBean in project openzaly by akaxincom.
the class HttpGroupService method updateProfile.
/**
* 更新群资料
*
* @param command
* @return
*/
public CommandResponse updateProfile(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
HaiGroupUpdateProfileProto.HaiGroupUpdateProfileRequest request = HaiGroupUpdateProfileProto.HaiGroupUpdateProfileRequest.parseFrom(command.getParams());
String groupId = request.getProfile().getId();
String photoId = request.getProfile().getIcon();
String groupName = request.getProfile().getName();
String groupNotice = request.getProfile().getGroupNotice();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(groupId)) {
GroupProfileBean gprofileBean = new GroupProfileBean();
gprofileBean.setGroupId(groupId);
gprofileBean.setGroupName(groupName);
gprofileBean.setGroupPhoto(photoId);
gprofileBean.setGroupNotice(groupNotice);
if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations