com.akaxin.proto.site.ApiGroupUpdateProfileProto Java Examples

The following examples show how to use com.akaxin.proto.site.ApiGroupUpdateProfileProto. 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
/**
 * 用户更新群资料<br>
 * 群主/管理员权限限制
 *
 * @param command
 * @return
 */
public CommandResponse updateProfile(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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.isAnyEmpty(siteUserId, groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_PARAMETER);
		}

		if (!checkGroupStatus(groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED);
		}

		// 判断是否具有权限,群主拥有权限
		String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
		if (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;
		}

	} 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
/**
 * 用户更新群资料<br>
 * 群主/管理员权限限制
 *
 * @param command
 * @return
 */
public CommandResponse updateProfile(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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.isAnyEmpty(siteUserId, groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_PARAMETER);
		}

		if (!checkGroupStatus(groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED);
		}

		// 判断是否具有权限,群主拥有权限
		String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
		if (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;
		}

	} 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
/**
 * 用户更新群资料<br>
 * 群主/管理员权限限制
 *
 * @param command
 * @return
 */
public CommandResponse updateProfile(Command command) {
	CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
	IErrorCode 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.isAnyEmpty(siteUserId, groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_PARAMETER);
		}

		if (!checkGroupStatus(groupId)) {
			throw new ZalyException(ErrorCode2.ERROR_GROUP_DELETED);
		}

		// 判断是否具有权限,群主拥有权限
		String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
		if (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;
		}

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