use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiGroupService method setting.
/**
* 获取个人对群的设置
*
* @param command
* @return
*/
public CommandResponse setting(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupSettingProto.ApiGroupSettingRequest request = ApiGroupSettingProto.ApiGroupSettingRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneEmpty(siteUserId, groupId)) {
UserGroupBean bean = UserGroupDao.getInstance().getUserGroupSetting(siteUserId, groupId);
if (bean != null) {
ApiGroupSettingProto.ApiGroupSettingResponse response = ApiGroupSettingProto.ApiGroupSettingResponse.newBuilder().setMessageMute(bean.isMute()).build();
commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
}
} 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.common.command.CommandResponse 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.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiGroupService method updateMute.
/**
* 个人更新群设置信息
*
* @param command
* @return
*/
public CommandResponse updateMute(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest request = ApiGroupUpdateSettingProto.ApiGroupUpdateSettingRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
boolean isMute = request.getMessageMute();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneEmpty(siteUserId, groupId)) {
UserGroupBean bean = new UserGroupBean();
bean.setSiteGroupId(groupId);
bean.setMute(isMute);
if (UserGroupDao.getInstance().updateUserGroupSetting(siteUserId, bean)) {
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
}
} 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.common.command.CommandResponse in project openzaly by akaxincom.
the class ApiGroupService method quit.
/**
* 用户退群 <br>
* 无权限限制
*
* @param command
* @return
*/
public CommandResponse quit(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiGroupQuitProto.ApiGroupQuitRequest request = ApiGroupQuitProto.ApiGroupQuitRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String groupId = request.getGroupId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(groupId)) {
if (UserGroupDao.getInstance().quitGroup(groupId, siteUserId)) {
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.common.command.CommandResponse 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);
}
Aggregations