mirror of https://gitee.com/stylefeng/roses
【8.0】【sys】获取角色对应的数据范围
parent
8a0485b07a
commit
62deae273c
|
@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service;
|
|||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.api.SysRoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.sys.api.enums.permission.DataScopeTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.entity.SysRole;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.SysRoleRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -100,4 +101,12 @@ public interface SysRoleService extends IService<SysRole>, SysRoleServiceApi {
|
|||
*/
|
||||
void updateRoleDataScopeType(Long roleId, Integer dataScopeType);
|
||||
|
||||
/**
|
||||
* 获取角色对应的数据范围,如果是多个角色,则取最大类型的数据范围
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/7/18 23:19
|
||||
*/
|
||||
DataScopeTypeEnum getRoleDataScope(List<Long> roleIds);
|
||||
|
||||
}
|
|
@ -145,6 +145,27 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||
this.update(sysRoleLambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataScopeTypeEnum getRoleDataScope(List<Long> roleIds) {
|
||||
|
||||
LambdaQueryWrapper<SysRole> sysRoleLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysRoleLambdaQueryWrapper.in(SysRole::getRoleId, roleIds);
|
||||
sysRoleLambdaQueryWrapper.select(SysRole::getDataScopeType);
|
||||
|
||||
// 按数据范围降序排列,50-全部数据最大
|
||||
sysRoleLambdaQueryWrapper.orderByDesc(SysRole::getDataScopeType);
|
||||
|
||||
SysRole sysRole = this.getOne(sysRoleLambdaQueryWrapper, false);
|
||||
if (sysRole != null) {
|
||||
if (sysRole.getDataScopeType() != null) {
|
||||
return DataScopeTypeEnum.codeToEnum(sysRole.getDataScopeType());
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是查询不到,则直接返回仅本人数据
|
||||
return DataScopeTypeEnum.SELF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> findList(SysRoleRequest sysRoleRequest) {
|
||||
LambdaQueryWrapper<SysRole> wrapper = this.createWrapper(sysRoleRequest);
|
||||
|
|
Loading…
Reference in New Issue