|
@ -3,7 +3,6 @@ package com.epmet.service.impl; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import com.epmet.bean.OpeScopeFilterResultBean; |
|
|
import com.epmet.bean.OpeScopeFilterResultBean; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.OpeScopeConstant; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
@ -175,7 +174,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
Set<String> switchScopes = effectiveOpeScopes.getSwitchScopes(); |
|
|
Set<String> switchScopes = effectiveOpeScopes.getSwitchScopes(); |
|
|
|
|
|
|
|
|
// 生成组织上下级关系系列的sql过滤片段
|
|
|
// 生成组织上下级关系系列的sql过滤片段
|
|
|
if (!CollectionUtil.isEmpty(orgLevelScopes) && !orgLevelScopes.contains(OpeScopeConstant.ORG_ALL)) { |
|
|
if (!CollectionUtil.isEmpty(orgLevelScopes) && !orgLevelScopes.contains(OperationScopeConstant.SCOPE_ORG_ALL)) { |
|
|
genOrgLevelScopeSqlFilter(sb, orgLevelScopes, userDetails.getOrgIdPath(), form.getTableAlias()); |
|
|
genOrgLevelScopeSqlFilter(sb, orgLevelScopes, userDetails.getOrgIdPath(), form.getTableAlias()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -316,7 +315,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
|
|
|
|
|
|
for (RoleOpeScopeResultDTO scope : scopeDTOS) { |
|
|
for (RoleOpeScopeResultDTO scope : scopeDTOS) { |
|
|
|
|
|
|
|
|
if (OpeScopeConstant.ALL.equals(scope.getScopeKey())) { |
|
|
if (OperationScopeConstant.SCOPE_ALL.equals(scope.getScopeKey())) { |
|
|
all = true; |
|
|
all = true; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -327,7 +326,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String scopeIndex = scope.getScopeIndex(); |
|
|
String scopeIndex = scope.getScopeIndex(); |
|
|
if (OpeScopeConstant.ORG_ALL.equals(scope.getScopeKey())) { |
|
|
if (OperationScopeConstant.SCOPE_ORG_ALL.equals(scope.getScopeKey())) { |
|
|
// 该操作具有org_all的权限,直接放入
|
|
|
// 该操作具有org_all的权限,直接放入
|
|
|
orgLevelScopes.put(scopeIndex, scope); |
|
|
orgLevelScopes.put(scopeIndex, scope); |
|
|
continue; |
|
|
continue; |
|
@ -378,7 +377,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
for (String scope : scopes) { |
|
|
for (String scope : scopes) { |
|
|
switch (scope) { |
|
|
switch (scope) { |
|
|
// 当前单位(可以用ORG_ID_PATH,也可以用ORG_ID判断)
|
|
|
// 当前单位(可以用ORG_ID_PATH,也可以用ORG_ID判断)
|
|
|
case OpeScopeConstant.ORG_CURR: |
|
|
case OperationScopeConstant.SCOPE_ORG_CURR: |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
sb.append(" ORG_ID_PATH = '").append(orgIdPath).append("' OR "); |
|
|
sb.append(" ORG_ID_PATH = '").append(orgIdPath).append("' OR "); |
|
|
//sb.append(" ORG_ID = '").append(currOrgID).append("' OR ");
|
|
|
//sb.append(" ORG_ID = '").append(currOrgID).append("' OR ");
|
|
@ -388,7 +387,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
// 本单位及其子级单位
|
|
|
// 本单位及其子级单位
|
|
|
case OpeScopeConstant.ORG_CURR_AND_SUB: |
|
|
case OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB: |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append("%' OR "); |
|
|
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append("%' OR "); |
|
|
} else { |
|
|
} else { |
|
@ -396,7 +395,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
// 本单位的子级单位
|
|
|
// 本单位的子级单位
|
|
|
case OpeScopeConstant.ORG_CURR_SUB: |
|
|
case OperationScopeConstant.SCOPE_ORG_CURR_SUB: |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append(":%' OR "); |
|
|
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append(":%' OR "); |
|
|
} else { |
|
|
} else { |
|
@ -404,7 +403,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
//当前单位的父级单位
|
|
|
//当前单位的父级单位
|
|
|
case OpeScopeConstant.ORG_CURR_SUP: |
|
|
case OperationScopeConstant.SCOPE_ORG_CURR_SUP: |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,':%') OR "); |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,':%') OR "); |
|
|
} else { |
|
|
} else { |
|
@ -412,30 +411,30 @@ public class AccessServiceImpl implements AccessService { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
// 当前单位及其父级单位
|
|
|
// 当前单位及其父级单位
|
|
|
case OpeScopeConstant.ORG_CURR_AND_SUP: |
|
|
case OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP: |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
if (StringUtils.isBlank(tableAlias)) { |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,'%') OR "); |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,'%') OR "); |
|
|
} else { |
|
|
} else { |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,'%' ) OR "); |
|
|
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,'%' ) OR "); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case OpeScopeConstant.ORG_EQUAL: |
|
|
case OperationScopeConstant.SCOPE_ORG_EQUAL: |
|
|
// todo 同级
|
|
|
// todo 同级
|
|
|
//sb.append(" OR ");
|
|
|
//sb.append(" OR ");
|
|
|
break; |
|
|
break; |
|
|
case OpeScopeConstant.ORG_EQUAL_AND_SUB: |
|
|
case OperationScopeConstant.SCOPE_ORG_EQUAL_AND_SUB: |
|
|
// todo 同级及其子级
|
|
|
// todo 同级及其子级
|
|
|
//sb.append(" OR ");
|
|
|
//sb.append(" OR ");
|
|
|
break; |
|
|
break; |
|
|
case OpeScopeConstant.ORG_EQUAL_SUB: |
|
|
case OperationScopeConstant.SCOPE_ORG_EQUAL_SUB: |
|
|
// todo 同级的子级
|
|
|
// todo 同级的子级
|
|
|
//sb.append(" OR ");
|
|
|
//sb.append(" OR ");
|
|
|
break; |
|
|
break; |
|
|
case OpeScopeConstant.ORG_EQUAL_AND_SUP: |
|
|
case OperationScopeConstant.SCOPE_ORG_EQUAL_AND_SUP: |
|
|
// todo 同级及其上级
|
|
|
// todo 同级及其上级
|
|
|
//sb.append(" OR ");
|
|
|
//sb.append(" OR ");
|
|
|
break; |
|
|
break; |
|
|
case OpeScopeConstant.ORG_EQUAL_SUP: |
|
|
case OperationScopeConstant.SCOPE_ORG_EQUAL_SUP: |
|
|
// todo 同级的上级
|
|
|
// todo 同级的上级
|
|
|
//sb.append(" OR ");
|
|
|
//sb.append(" OR ");
|
|
|
break; |
|
|
break; |
|
@ -539,7 +538,7 @@ public class AccessServiceImpl implements AccessService { |
|
|
HashSet<String> opeKeys = new HashSet<>(); |
|
|
HashSet<String> opeKeys = new HashSet<>(); |
|
|
for (RoleOpeScopeResultDTO opeScope : roleOperations) { |
|
|
for (RoleOpeScopeResultDTO opeScope : roleOperations) { |
|
|
String scopeKey = opeScope.getScopeKey(); |
|
|
String scopeKey = opeScope.getScopeKey(); |
|
|
if (OpeScopeConstant.ORG_ALL.equals(scopeKey) || OpeScopeConstant.ALL.equals(scopeKey)) { |
|
|
if (OperationScopeConstant.SCOPE_ORG_ALL.equals(scopeKey) || OperationScopeConstant.SCOPE_ALL.equals(scopeKey)) { |
|
|
// 如果该操作的范围是org_all或者all,不需要根据上下级关系判断,直接返回即可。
|
|
|
// 如果该操作的范围是org_all或者all,不需要根据上下级关系判断,直接返回即可。
|
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
continue; |
|
|
continue; |
|
@ -553,21 +552,21 @@ public class AccessServiceImpl implements AccessService { |
|
|
|
|
|
|
|
|
switch (currOrgRelation) { |
|
|
switch (currOrgRelation) { |
|
|
case ORG_RELATION_SAME:// 就在所在机构下
|
|
|
case ORG_RELATION_SAME:// 就在所在机构下
|
|
|
if (OpeScopeConstant.ORG_CURR.equals(scopeKey) |
|
|
if (OperationScopeConstant.SCOPE_ORG_CURR.equals(scopeKey) |
|
|
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey) |
|
|
|| OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB.equals(scopeKey) |
|
|
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { |
|
|
|| OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP.equals(scopeKey)) { |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case ORG_RELATION_SUB:// 所在机构的子级
|
|
|
case ORG_RELATION_SUB:// 所在机构的子级
|
|
|
if (OpeScopeConstant.ORG_CURR_SUB.equals(scopeKey) |
|
|
if (OperationScopeConstant.SCOPE_ORG_CURR_SUB.equals(scopeKey) |
|
|
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)) { |
|
|
|| OperationScopeConstant.SCOPE_ORG_CURR_AND_SUB.equals(scopeKey)) { |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case ORG_RELATION_SUP:// 所在机构的上级
|
|
|
case ORG_RELATION_SUP:// 所在机构的上级
|
|
|
if (OpeScopeConstant.ORG_CURR_SUP.equals(scopeKey) |
|
|
if (OperationScopeConstant.SCOPE_ORG_CURR_SUP.equals(scopeKey) |
|
|
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) { |
|
|
|| OperationScopeConstant.SCOPE_ORG_CURR_AND_SUP.equals(scopeKey)) { |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
opeKeys.add(opeScope.getOperationKey()); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|