mirror of https://gitee.com/stylefeng/roses
【8.0】【sys】更新获取用户数据范围接口
parent
eb32102ba8
commit
cdab7b985e
|
@ -83,11 +83,6 @@ public enum AuthExceptionEnum implements AbstractExceptionEnum {
|
|||
*/
|
||||
PERMISSION_RES_VALIDATE_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + AuthConstants.AUTH_EXCEPTION_STEP_CODE + "09", "权限校验失败,请检查用户是否有该资源的权限"),
|
||||
|
||||
/**
|
||||
* 数据范围类型转化异常
|
||||
*/
|
||||
DATA_SCOPE_ERROR(RuleConstants.BUSINESS_ERROR_TYPE_CODE + AuthConstants.AUTH_EXCEPTION_STEP_CODE + "10", "数据范围类型转化异常,数据范围类型为:{}"),
|
||||
|
||||
/**
|
||||
* 权限校验失败,只有超级管理员可以授权所有数据
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.sys.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户权限的Api
|
||||
*
|
||||
|
@ -7,4 +9,24 @@ package cn.stylefeng.roses.kernel.sys.api;
|
|||
* @since 2023/7/18 22:51
|
||||
*/
|
||||
public interface UserPermissionApi {
|
||||
|
||||
/**
|
||||
* 获取当前用户拥有的数据范围类型
|
||||
*
|
||||
* 枚举值在
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/7/18 22:58
|
||||
*/
|
||||
Integer currentUserDataScopeType();
|
||||
|
||||
/**
|
||||
* 获取当前用户拥有的所有组织机构id列表
|
||||
*
|
||||
* @return null或者空数组,代表用户没有访问权限,其他情况则代表用户拥有的组织机构id访问权限
|
||||
* @author fengshuonan
|
||||
* @since 2023/7/18 22:54
|
||||
*/
|
||||
Set<Long> currentUserOrgScopeList();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,13 +22,12 @@
|
|||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.auth.api.enums;
|
||||
package cn.stylefeng.roses.kernel.sys.api.constants;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.SysException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.exception.enums.RoleExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEnum.DATA_SCOPE_ERROR;
|
||||
|
||||
/**
|
||||
* 数据范围类型枚举,数据范围的值越小,数据权限越小
|
||||
*
|
||||
|
@ -38,11 +37,6 @@ import static cn.stylefeng.roses.kernel.auth.api.exception.enums.AuthExceptionEn
|
|||
@Getter
|
||||
public enum DataScopeTypeEnum {
|
||||
|
||||
/**
|
||||
* 仅本人数据
|
||||
*/
|
||||
SELF(10, "仅本人数据"),
|
||||
|
||||
/**
|
||||
* 本部门数据
|
||||
*/
|
||||
|
@ -86,7 +80,7 @@ public enum DataScopeTypeEnum {
|
|||
}
|
||||
}
|
||||
}
|
||||
throw new AuthException(DATA_SCOPE_ERROR, code);
|
||||
throw new SysException(RoleExceptionEnum.DATA_SCOPE_ERROR, code);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,12 @@ public enum RoleExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 用户没有该应用的权限,无法跳转到该应用
|
||||
*/
|
||||
USER_HAVE_NO_APP_ID(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "用户没有该应用的权限,无法跳转到该应用");
|
||||
USER_HAVE_NO_APP_ID(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "用户没有该应用的权限,无法跳转到该应用"),
|
||||
|
||||
/**
|
||||
* 数据范围类型转化异常
|
||||
*/
|
||||
DATA_SCOPE_ERROR(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "数据范围类型转化异常,数据范围类型为:{}");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -2,12 +2,12 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveRoleCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRoleDataScope;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.enums.exception.SysRoleDataScopeExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.mapper.SysRoleDataScopeMapper;
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.enums.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
|
@ -12,6 +11,7 @@ import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
|||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.sys.api.callback.RemoveRoleCallbackApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.api.constants.SysConstants;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRole;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.enums.exception.SysRoleExceptionEnum;
|
||||
|
@ -112,9 +112,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
@Override
|
||||
public Integer getRoleDataScopeType(Long roleId) {
|
||||
|
||||
// 角色id为空,返回仅本人数据
|
||||
// 角色id为空,返回仅本部门数据
|
||||
if (ObjectUtil.isEmpty(roleId)) {
|
||||
return DataScopeTypeEnum.SELF.getCode();
|
||||
return DataScopeTypeEnum.DEPT.getCode();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysRole> sysRoleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -129,7 +129,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
}
|
||||
}
|
||||
|
||||
return DataScopeTypeEnum.SELF.getCode();
|
||||
return DataScopeTypeEnum.DEPT.getCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue