mirror of https://gitee.com/stylefeng/roses
【8.3.3】【dataScope】获取用户指定类型数据范围
parent
a274908614
commit
0fdcae3439
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.db.mp.datascope;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.datascope.config.DataScopeConfig;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.permission.DataScopeTypeEnum;
|
||||
|
||||
/**
|
||||
* 获取用户角色的数据范围
|
||||
|
@ -18,4 +19,12 @@ public interface UserRoleDataScopeApi {
|
|||
*/
|
||||
DataScopeConfig getUserRoleDataScopeConfig();
|
||||
|
||||
/**
|
||||
* 获取当前用户的,规定指定类型的数据范围的配置
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2025/1/27 23:32
|
||||
*/
|
||||
DataScopeConfig getUserPointDataScopeConfig(DataScopeTypeEnum dataScopeTypeEnum);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
|
@ -75,6 +76,27 @@ public class UserRoleDataScopeImpl implements UserRoleDataScopeApi {
|
|||
return parseSysRoleDataScope(roleDataScopeList, loginUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataScopeConfig getUserPointDataScopeConfig(DataScopeTypeEnum dataScopeTypeEnum) {
|
||||
|
||||
// 获取当前登录用户id
|
||||
LoginUser loginUser = LoginContext.me().getLoginUserNullable();
|
||||
if (loginUser == null) {
|
||||
return nullDataScopeConfig();
|
||||
}
|
||||
|
||||
// 只能进行非指定类型的数据范围的生成
|
||||
if (dataScopeTypeEnum == null || dataScopeTypeEnum.equals(DataScopeTypeEnum.DEFINE_ORG_LEVEL_WITH_CHILD)
|
||||
|| dataScopeTypeEnum.equals(DataScopeTypeEnum.DEFINE)
|
||||
|| dataScopeTypeEnum.equals(DataScopeTypeEnum.DEFINE_ORG_WITH_CHILD)) {
|
||||
return nullDataScopeConfig();
|
||||
}
|
||||
|
||||
SysRoleDataScope sysRoleDataScope = new SysRoleDataScope();
|
||||
sysRoleDataScope.setDataScopeType(dataScopeTypeEnum.getCode());
|
||||
return parseSysRoleDataScope(ListUtil.of(sysRoleDataScope), loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 空的数据范围的配置
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue