소스 검색

优化数据权限控制

zhouhao 7 년 전
부모
커밋
86a966ad58

+ 0 - 20
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/annotation/RequiresDepartment.java

@@ -1,20 +0,0 @@
-package org.hswebframework.web.organizational.authorization.annotation;
-
-import org.hswebframework.web.authorization.annotation.Logical;
-
-import java.lang.annotation.*;
-
-/**
- * @author zhouhao
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface RequiresDepartment {
-    String[] value() default {};
-
-    boolean hasChidren() default true;
-
-    Logical logocal() default Logical.OR;
-
-}

+ 0 - 20
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/annotation/RequiresOrg.java

@@ -1,20 +0,0 @@
-package org.hswebframework.web.organizational.authorization.annotation;
-
-import org.hswebframework.web.authorization.annotation.Logical;
-
-import java.lang.annotation.*;
-
-/**
- * @author zhouhao
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface RequiresOrg {
-    String[] value() default {};
-
-    boolean hasChidren() default true;
-
-    Logical logocal() default Logical.OR;
-
-}

+ 0 - 20
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/annotation/RequiresPosition.java

@@ -1,20 +0,0 @@
-package org.hswebframework.web.organizational.authorization.annotation;
-
-import org.hswebframework.web.authorization.annotation.Logical;
-
-import java.lang.annotation.*;
-
-/**
- * @author zhouhao
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface RequiresPosition {
-    String[] value() default {};
-
-    boolean hasChidren() default true;
-
-    Logical logocal() default Logical.OR;
-
-}

+ 3 - 8
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/AbstractScopeDataAccessHandler.java

@@ -23,7 +23,6 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
- *
  * @author zhouhao
  */
 public abstract class AbstractScopeDataAccessHandler<E> implements DataAccessHandler {
@@ -74,19 +73,15 @@ public abstract class AbstractScopeDataAccessHandler<E> implements DataAccessHan
     }
 
     protected boolean handleAdd(ScopeDataAccessConfig access, AuthorizingContext context) {
-        PersonnelAuthorization authorization = getPersonnelAuthorization();
-        Set<String> scopes = authorization.getRootOrgId();
-        String scope = null;
+        Set<String> scopes = getTryOperationScope(access);
+        String scope;
         if (scopes.isEmpty()) {
             return true;
         } else if (scopes.size() == 1) {
             scope = scopes.iterator().next();
         } else {
-            logger.warn("existing many scope :{} , try use config.", scopes);
-        }
-        scopes = getTryOperationScope(access).stream().map(String::valueOf).collect(Collectors.toSet());
-        if (scope == null && scopes.size() == 1) {
             scope = scopes.iterator().next();
+            logger.warn("existing many scope :{} , try use config.", scope);
         }
         if (scope != null) {
             String finalScopeId = scope;

+ 0 - 2
hsweb-system/hsweb-system-organizational/hsweb-system-organizational-authorization/src/main/java/org/hswebframework/web/organizational/authorization/simple/handler/DepartmentScopeDataAccessHandler.java

@@ -17,8 +17,6 @@ import static org.hswebframework.web.organizational.authorization.access.DataAcc
 import static org.hswebframework.web.organizational.authorization.access.DataAccessType.SCOPE_TYPE_ONLY_SELF;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public class DepartmentScopeDataAccessHandler extends AbstractScopeDataAccessHandler<DepartmentAttachEntity> {