【8.3.3】【dataScope】获取用户指定类型数据范围

dev-8.3.3
fengshuonan 2025-01-27 23:48:58 +08:00
parent a274908614
commit 0fdcae3439
2 changed files with 31 additions and 0 deletions

View File

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

View File

@ -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);
}
/**
*
*