|
@@ -301,7 +301,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
return roles;
|
|
|
}
|
|
|
|
|
|
- // ========== 用户-部门的相关方法 ==========
|
|
|
+ // ========== 用户-企业的相关方法 ==========
|
|
|
|
|
|
@Override
|
|
|
public void assignRoleDataScope(Long roleId, String dataScope, Set<Long> dataScopeDataIds) {
|
|
@@ -312,7 +312,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
@DataPermission(enable = false) // 关闭数据权限,不然就会出现递归获取数据权限的问题
|
|
|
public DataPermissionRespDTO getDataPermission(Long enterpriseId, Long userId) {
|
|
|
DataPermissionRespDTO result = new DataPermissionRespDTO();
|
|
|
- // 获得用户的部门编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询
|
|
|
+ // 获得用户的企业编号的缓存,通过 Guava 的 Suppliers 惰性求值,即有且仅有第一次发起 DB 的查询
|
|
|
EnterpriseUserBindDO enterpriseUserBind = enterpriseUserBindService
|
|
|
.selectByEnterpriseIdAndUserId(enterpriseId, userId);
|
|
|
if (enterpriseUserBind == null) {
|
|
@@ -325,8 +325,12 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
if (CollUtil.isEmpty(roles)) {
|
|
|
result.setSelf(true);
|
|
|
if(enterpriseUserBindService.checkIsAdmin(enterpriseUserBind)) {
|
|
|
- // 管理员
|
|
|
- result.setDataIds(Collections.singleton(enterpriseId));
|
|
|
+ // 管理员 数据权限是 当前企业以及下级
|
|
|
+ CollUtil.addAll(result.getDataIds(), enterpriseService
|
|
|
+ .getChildEnterpriseIdListFromCache(enterpriseUserBind.getEnterpriseId()));
|
|
|
+ // 添加本身企业编号
|
|
|
+ CollUtil.addAll(result.getDataIds(), enterpriseUserBind
|
|
|
+ .getEnterpriseId());
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -345,7 +349,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
// 情况二,DEPT_CUSTOM 自定义
|
|
|
if (Objects.equals(role.getDataScope(), MdeDataScopeEnum.ENTERPRISE_CUSTOM.getScope())) {
|
|
|
CollUtil.addAll(result.getDataIds(), role.getDataScopeEnterpriseIds());
|
|
|
- // 自定义可见部门时,保证可以看到自己所在的部门。否则,一些场景下可能会有问题。
|
|
|
+ // 自定义可见企业时,保证可以看到自己所在的企业。否则,一些场景下可能会有问题。
|
|
|
// 例如说,登录时,基于 t_user 的 username 查询会可能被 dept_id 过滤掉
|
|
|
CollUtil.addAll(result.getDataIds(), enterpriseUserBind.getEnterpriseId());
|
|
|
continue;
|
|
@@ -359,7 +363,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
if (Objects.equals(role.getDataScope(), MdeDataScopeEnum.ENTERPRISE_AND_CHILD.getScope())) {
|
|
|
CollUtil.addAll(result.getDataIds(), enterpriseService
|
|
|
.getChildEnterpriseIdListFromCache(enterpriseUserBind.getEnterpriseId()));
|
|
|
- // 添加本身部门编号
|
|
|
+ // 添加本身企业编号
|
|
|
CollUtil.addAll(result.getDataIds(), enterpriseUserBind
|
|
|
.getEnterpriseId());
|
|
|
continue;
|