浏览代码

完善部分注释

zhouhao 8 年之前
父节点
当前提交
8b1f928e4a
共有 33 个文件被更改,包括 273 次插入128 次删除
  1. 73 7
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Authorization.java
  2. 12 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthorizationHolder.java
  3. 2 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Permission.java
  4. 1 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Role.java
  5. 6 0
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/CustomDataAccess.java
  6. 2 2
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java
  7. 1 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/FieldAccess.java
  8. 12 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/FieldAccessController.java
  9. 1 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/OwnCreatedDataAccess.java
  10. 3 3
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/ParamContext.java
  11. 1 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/ScriptDataAccess.java
  12. 11 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/AuthInfo.java
  13. 21 23
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java
  14. 1 8
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Logical.java
  15. 21 1
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresDataAccess.java
  16. 13 8
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresExpression.java
  17. 9 3
      hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresFieldAccess.java
  18. 2 2
      hsweb-authorization/hsweb-authorization-shiro/pom.xml
  19. 3 0
      hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/BoostAuthorizationAttributeSourceAdvisor.java
  20. 4 4
      hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/DataAccessAnnotationMethodInterceptor.java
  21. 24 1
      hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/DefaultFieldAccessController.java
  22. 0 5
      hsweb-commons/hsweb-commons-controller/pom.xml
  23. 4 9
      hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java
  24. 4 5
      hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java
  25. 2 2
      hsweb-commons/hsweb-commons-entity/pom.xml
  26. 16 8
      hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/TreeSupportEntity.java
  27. 1 1
      hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/EntityFactory.java
  28. 4 4
      hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/param/DeleteParamEntity.java
  29. 4 4
      hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/param/QueryParamEntity.java
  30. 1 1
      hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java
  31. 3 5
      hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java
  32. 2 1
      hsweb-core/src/main/java/org/hswebframework/web/id/IDGenerator.java
  33. 9 14
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorization.java

+ 73 - 7
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Authorization.java

@@ -21,20 +21,51 @@ import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.function.Supplier;
 
 /**
- * TODO 完成注释
+ * 用户授权信息,当前登录用户的权限信息,包括用户的基本信息,角色,权限集合等常用信息<br>
+ * 如何获取:
+ * <ul>
+ * <li>springmvc 入参方式: ResponseMessage myTest(@AuthInfo Authorization auth){}</li>
+ * <li>静态方法方式:AuthorizationHolder.get();</li>
+ * </ul>
  *
  * @author zhouhao
+ * @see AuthorizationHolder
+ * @see org.hswebframework.web.authorization.annotation.AuthInfo
+ * @since 3.0
  */
 public interface Authorization extends Serializable {
+
+    /**
+     * 获取用户基本信息
+     *
+     * @return 用户信息
+     */
     User getUser();
 
+    /**
+     * 获取持有的角色集合
+     *
+     * @return 角色集合
+     */
     List<Role> getRoles();
 
+    /**
+     * 获取持有的权限集合
+     *
+     * @return 权限集合
+     */
     List<Permission> getPermissions();
 
+    /**
+     * 根据id获取角色,角色不存在则返回null
+     *
+     * @param id 角色id
+     * @return 角色信息
+     */
     default Role getRole(String id) {
         if (null == id) return null;
         return getRoles().stream()
@@ -43,6 +74,12 @@ public interface Authorization extends Serializable {
                 .orElse(null);
     }
 
+    /**
+     * 根据权限id获取权限信息,权限不存在则返回null
+     *
+     * @param id 权限id
+     * @return 权限信息
+     */
     default Permission getPermission(String id) {
         if (null == id) return null;
         return getPermissions().parallelStream()
@@ -51,17 +88,46 @@ public interface Authorization extends Serializable {
                 .orElse(null);
     }
 
+    /**
+     * 根据属性名获取属性值,返回一个{@link Optional}对象。<br>
+     * 此方法可用于获取自定义的属性信息
+     *
+     * @param name 属性名
+     * @param <T>  属性值类型
+     * @return Optional属性值
+     */
+    <T extends Serializable> Optional<T> getAttribute(String name);
 
-    <T extends Serializable> T getAttribute(String name);
-
-    <T extends Serializable> T getAttribute(String name, T defaultValue);
-
-    <T extends Serializable> T getAttribute(String name, Supplier<T> supplier);
-
+    /**
+     * 设置一个属性值,如果属性名称已经存在,则将其覆盖。<br>
+     * 注意:由于权限信息可能会被序列化,属性值必须实现{@link Serializable}接口
+     *
+     * @param name   属性名称
+     * @param object 属性值
+     */
     void setAttribute(String name, Serializable object);
 
+    /**
+     * 设置多个属性值,参数为map类型,key为属性名称,value为属性值
+     *
+     * @param attributes 属性值map
+     */
     void setAttributes(Map<String, Serializable> attributes);
 
+    /**
+     * 删除属性,并返回被删除的值
+     *
+     * @param name 属性名
+     * @param <T>  被删除的值类型
+     * @return 被删除的值
+     */
+    <T extends Serializable> T removeAttributes(String name);
+
+    /**
+     * 获取全部属性,此属性为通过{@link this#setAttribute(String, Serializable)}或{@link this#setAttributes(Map)}设置的属性。
+     *
+     * @return 全部属性集合
+     */
     Map<String, Serializable> getAttributes();
 
 }

+ 12 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/AuthorizationHolder.java

@@ -19,7 +19,15 @@
 package org.hswebframework.web.authorization;
 
 /**
- * 权限获取器,用于静态方式获取当前登录用户的权限信息
+ * 权限获取器,用于静态方式获取当前登录用户的权限信息.
+ * 例如:
+ * <pre>
+ *     &#064;RequestMapping("/example")
+ *     public ResponseMessage example(){
+ *         Authorization auth = AuthorizationHolder.get();
+ *         return ResponseMessage.ok();
+ *     }
+ * </pre>
  *
  * @author zhouhao
  * @see AuthorizationSupplier
@@ -28,6 +36,9 @@ package org.hswebframework.web.authorization;
 public final class AuthorizationHolder {
     private static AuthorizationSupplier supplier;
 
+    /**
+     * @return 当前登录用户信息
+     */
     public static Authorization get() {
         if (null == supplier) {
             throw new UnsupportedOperationException("AuthorizationSupplier is null!");

+ 2 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Permission.java

@@ -27,6 +27,8 @@ import java.util.Set;
  * 用户持有的权限信息
  *
  * @author zhouhao
+ * @see Authorization
+ * @since 3.0
  */
 public interface Permission extends Serializable {
 

+ 1 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/Role.java

@@ -23,6 +23,7 @@ import java.io.Serializable;
  * 角色信息
  *
  * @author zhouhao
+ * @since 3.0
  */
 public interface Role extends Serializable {
 
@@ -32,7 +33,6 @@ public interface Role extends Serializable {
     String getId();
 
     /**
-     *
      * @return 角色名
      */
     String getName();

+ 6 - 0
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/CustomDataAccess.java

@@ -1,10 +1,16 @@
 package org.hswebframework.web.authorization.access;
 
 /**
+ * 自定义控制器的数据级权限控制器
+ *
  * @author zhouhao
  * @see DataAccess.Type#CUSTOM
  */
 public interface CustomDataAccess extends DataAccess {
+
+    /**
+     * @return 自定义的控制器
+     */
     DataAccessController getController();
 
     default String getType() {

+ 2 - 2
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/DataAccessController.java

@@ -5,14 +5,14 @@ package org.hswebframework.web.authorization.access;
  * 如:A用户只能查询自己创建的B数据,A用户只能修改自己创建的B数据
  *
  * @author zhouhao
- * @see 3.0
+ * @since  3.0
  */
 public interface DataAccessController {
     /**
      * 执行权限控制
      * @param access 控制方式以及配置
      * @param params 当前操作的方法的参数上下文
-     * @return
+     * @return 授权是否通过
      */
     boolean doAccess(DataAccess access, ParamContext params);
 }

+ 1 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/FieldAccess.java

@@ -4,7 +4,7 @@ import java.io.Serializable;
 import java.util.Set;
 
 /**
- * 字段级别权限控制
+ * 字段级别权限控制配置,表示此用户不能对字段{@link this#getField()} 执行 {@link this#getActions()}操作
  *
  * @author zhouhao
  * @see FieldAccessController

+ 12 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/FieldAccessController.java

@@ -1,12 +1,23 @@
 package org.hswebframework.web.authorization.access;
 
+import org.hswebframework.web.authorization.Permission;
+
 import java.util.Set;
 
 /**
- * TODO 完成注释
+ * 字段级权限控制器,用于控制对字段的操作权限。如:不同角色,可操作的字段不同等
  *
  * @author zhouhao
  */
 public interface FieldAccessController {
+
+    /**
+     * 执行权限验证。根据当前被拦截的操作类型,以及此类型可操作的字段集合进行权限验证
+     *
+     * @param action   当前操作的类型 {@link Permission#getActions()}
+     * @param accesses 不可操作的字段
+     * @param params   参数上下文
+     * @return 验证是否通过
+     */
     boolean doAccess(String action, Set<FieldAccess> accesses, ParamContext params);
 }

+ 1 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/OwnCreatedDataAccess.java

@@ -1,7 +1,7 @@
 package org.hswebframework.web.authorization.access;
 
 /**
- * TODO 完成注释
+ * 只能操作由自己创建的数据
  *
  * @author zhouhao
  */

+ 3 - 3
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/ParamContext.java

@@ -29,9 +29,9 @@ public interface ParamContext extends Serializable {
     Method getMethod();
 
     /**
-     * 根据参数名获取参数值,此参数为方法的参数,而非http参数 <br/>
-     * 如:当前被操作的方法为 query(QueryParam param); 调用getParameter("param"); 则返回QueryParam实例<br/>
-     * 注意:返回值为Optional对象,使用方法见{@link Optional}<br/>
+     * 根据参数名获取参数值,此参数为方法的参数,而非http参数 <br>
+     * 如:当前被操作的方法为 query(QueryParam param); 调用getParameter("param"); 则返回QueryParam实例<br>
+     * 注意:返回值为Optional对象,使用方法见{@link Optional}<br>
      *
      * @param name 参数名称
      * @param <T>  参数泛型

+ 1 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/access/ScriptDataAccess.java

@@ -1,7 +1,7 @@
 package org.hswebframework.web.authorization.access;
 
 /**
- * 动态脚本数据权限控制
+ * 通过脚本来控制数据操作权限.脚本可以在前端设置角色的时候进行编辑
  *
  * @author zhouhao
  */

+ 11 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/AuthInfo.java

@@ -20,9 +20,19 @@ package org.hswebframework.web.authorization.annotation;
 import java.lang.annotation.*;
 
 /**
- * TODO 完成注释
+ * 用于springmvc中,将授权信息自动注入到参数中.
+ * 例如:
+ * <pre>
+ *    &#064;ReuqestMapping("/example")
+ *    public ResponseMessage(&#064;AuthInfo Authorization auth){
+ *      User user = auth.getUser();
+ *      return ok();
+ *    }
+ * </pre>
  *
  * @author zhouhao
+ * @see org.hswebframework.web.authorization.Authorization
+ * @since 3.0
  */
 @Target(ElementType.PARAMETER)
 @Retention(RetentionPolicy.RUNTIME)

+ 21 - 23
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Authorize.java

@@ -18,10 +18,17 @@
 
 package org.hswebframework.web.authorization.annotation;
 
+import org.hswebframework.web.authorization.Permission;
+import org.hswebframework.web.authorization.Role;
+import org.hswebframework.web.authorization.User;
+
 import java.lang.annotation.*;
 
 /**
- * 权限注解
+ * 基础权限控制注解,提供基本的控制配置
+ *
+ * @author zhouhao
+ * @since 3.0
  */
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
@@ -32,43 +39,47 @@ public @interface Authorize {
     /**
      * 对角色授权,当使用按角色授权时,对模块以及操作级别授权方式失效
      *
-     * @return 进行授权的角色数组
+     * @return 进 role id array
+     * @see Role#getId()
      */
     String[] role() default {};
 
     /**
      * 对模块授权
      *
-     * @return 进行授权的模块
+     * @return permission id array
+     * @see Permission#getId()
      */
     String[] permission() default {};
 
     /**
      * 如增删改查等
      *
-     * @return
+     * @return action array
+     * @see Permission#getActions()
      */
     String[] action() default {};
 
-
     /**
      * 验证是否为指定user
      *
-     * @return
+     * @return user id array
+     * @see User#getId()
      */
     String[] user() default {};
 
     /**
      * 验证失败时返回的消息
      *
-     * @return
+     * @return 验证失败提示的消息
      */
     String message() default "{unauthorized}";
 
     /**
      * 表达式验证
      *
-     * @return
+     * @return 表达式
+     * @see RequiresExpression#value()
      */
     String expression() default "";
 
@@ -76,23 +87,10 @@ public @interface Authorize {
      * 表达式语言,默认spring表达式
      *
      * @return 表达式语言
+     * @see RequiresExpression#language()
      */
     String expressionLanguage() default "spel";
 
-    /**
-     * 是否为api接口,为true时,可使用api方式请求。
-     *
-     * @return
-     */
-    boolean api() default false;
-
-    /**
-     * 可匿名访问
-     *
-     * @return 是否可匿名访问, 匿名访问将不用登录
-     */
-    boolean anonymous() default false;
-
     /**
      * 是否合并类上的注解
      *
@@ -103,7 +101,7 @@ public @interface Authorize {
     /**
      * 验证模式,在使用多个验证条件时有效
      *
-     * @return
+     * @return logical
      */
     Logical logical() default Logical.OR;
 

+ 1 - 8
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/Logical.java

@@ -18,12 +18,5 @@
 package org.hswebframework.web.authorization.annotation;
 
 public enum Logical {
-    /**
-     * 并集,需要满足所有验证条件
-     */
-    AND,
-    /**
-     * 交集,满足其中一个验证条件
-     */
-    OR
+    AND,OR
 }

+ 21 - 1
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresDataAccess.java

@@ -27,7 +27,14 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
+ * 数据级权限控制注解,用于进行需要数据级别权限控制的声明.
+ * <p>
+ * 此注解仅用于声明此方法需要进行数据级权限控制,具体权限控制方式由控制器实{@link DataAccessController}现
+ * </p>
+ *
  * @author zhouhao
+ * @see DataAccessController
+ * @since 3.0
  */
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
@@ -38,17 +45,30 @@ public @interface RequiresDataAccess {
      * @see Permission#getId()
      */
     String permission();
+
     /**
-     * @return
+     * @return action array
      * @see DataAccess#getAction()
      */
     String[] action() default {};
 
+    /**
+     * @return logical
+     */
     Logical logical() default Logical.OR;
 
+    /**
+     * @return 自定义控制器bean名称
+     */
     String controllerBeanName() default "";
 
+    /**
+     * @return 自定义控制器类型
+     */
     Class<DataAccessController> controllerClass() default DataAccessController.class;
 
+    /**
+     * @return id参数名称
+     */
     String idParamName() default "id";
 }

+ 13 - 8
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresExpression.java

@@ -26,6 +26,7 @@ import java.lang.annotation.Target;
  * 使用表达式进行验证,默认支持spel,ognl表达式。
  *
  * @author zhouhao
+ * @since 3.0
  */
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
@@ -34,16 +35,20 @@ public @interface RequiresExpression {
     /**
      * 表达式内容,表达式可以调用方法的参数值以及当前的用户信息和spring管理的bean
      * 例如:
-     * <code>
-     * <p>
-     * &#064;ReuqestMapping<br>
-     * &#064;RequiresExpression("#param!=null")<br>
-     * public ResponseMessage requestHandle(String param){ <br/>
-     * //...<br>
-     * }<br>
-     * </code>
+     * <pre>
+     * &#064;RequestMapping
+     * &#064;RequiresExpression("#param!=null")
+     * public ResponseMessage requestHandle(String param){
+     *  return ok();
+     * }
+     * </pre>
+     *
+     * @return 表达式
      */
     String value();
 
+    /**
+     * @return 表达式语言 ,支持spel,ognl,groovy,javascript
+     */
     String language() default "spel";
 }

+ 9 - 3
hsweb-authorization/hsweb-authorization-api/src/main/java/org/hswebframework/web/authorization/annotation/RequiresFieldAccess.java

@@ -17,8 +17,9 @@
 
 package org.hswebframework.web.authorization.annotation;
 
-import org.hswebframework.web.authorization.access.FieldAccess;
 import org.hswebframework.web.authorization.Permission;
+import org.hswebframework.web.authorization.access.DataAccessController;
+import org.hswebframework.web.authorization.access.FieldAccess;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -26,9 +27,14 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * todo
+ * 字段级权限控制注解,用于进行需要字段级别权限控制的声明.
+ * <p>
+ * 此注解仅用于声明此方法需要进行字段级权限控制,具体权限控制方式由控制器实{@link org.hswebframework.web.authorization.access.FieldAccessController}现
+ * </p>
  *
  * @author zhouhao
+ * @see org.hswebframework.web.authorization.access.FieldAccessController
+ * @since 3.0
  */
 @Target({ElementType.TYPE, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
@@ -41,7 +47,7 @@ public @interface RequiresFieldAccess {
     String permission();
 
     /**
-     * @return
+     * @return action
      * @see FieldAccess#getActions()
      */
     String action();

+ 2 - 2
hsweb-authorization/hsweb-authorization-shiro/pom.xml

@@ -34,9 +34,9 @@
     </properties>
     <dependencies>
         <dependency>
-            <groupId>${parent.groupId}</groupId>
+            <groupId>${project.parent.groupId}</groupId>
             <artifactId>hsweb-authorization-api</artifactId>
-            <version>${parent.version}</version>
+            <version>${project.parent.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.shiro</groupId>

+ 3 - 0
hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/BoostAuthorizationAttributeSourceAdvisor.java

@@ -56,6 +56,9 @@ public class BoostAuthorizationAttributeSourceAdvisor extends StaticMethodMatche
 
     /**
      * Create a new AuthorizationAttributeSourceAdvisor.
+     *
+     * @param dataAccessController  数据权限控制器
+     * @param fieldAccessController 字段权限控制器
      */
     public BoostAuthorizationAttributeSourceAdvisor(DataAccessController dataAccessController,
                                                     FieldAccessController fieldAccessController) {

+ 4 - 4
hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/DataAccessAnnotationMethodInterceptor.java

@@ -46,14 +46,14 @@ import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 /**
- * 数据级权限控制实现 <br/>
- * 通过在方法上注解{@link RequiresDataAccess},标识需要进行数据级权限控制<br/>
- * 控制的方式和规则由 {@link Permission#getDataAccesses()}实现<br/>
+ * 数据级权限控制实现 <br>
+ * 通过在方法上注解{@link RequiresDataAccess},标识需要进行数据级权限控制<br>
+ * 控制的方式和规则由 {@link Permission#getDataAccesses()}实现<br>
  *
  * @author zhouhao
  * @see DefaultDataAccessController
  * @see DataAccessAnnotationHandler#assertAuthorized(Annotation)
- * @see 3.0
+ * @since  3.0
  */
 public class DataAccessAnnotationMethodInterceptor extends AuthorizingAnnotationMethodInterceptor {
 

+ 24 - 1
hsweb-authorization/hsweb-authorization-shiro/src/main/java/org/hswebframework/web/authorization/shiro/boost/DefaultFieldAccessController.java

@@ -13,9 +13,12 @@ import org.slf4j.LoggerFactory;
 import java.util.Set;
 
 /**
- * TODO 完成注释
+ * 默认的字段级权限控制,目前已实现提供对查询(query),更新(update)的权限控制。
+ * 控制方式主要是通过被拦截方法的参数类型进行识别,如果是可进行控制的参数类型,则通过修改参数属性等方式,进行控制。
  *
  * @author zhouhao
+ * @see FieldAccessController
+ * @since 3.0
  */
 public class DefaultFieldAccessController implements FieldAccessController {
 
@@ -23,6 +26,7 @@ public class DefaultFieldAccessController implements FieldAccessController {
 
     @Override
     public boolean doAccess(String action, Set<FieldAccess> accesses, ParamContext params) {
+        //控制转发
         switch (action) {
             case Permission.ACTION_QUERY:
                 return doQueryAccess(accesses, params);
@@ -34,6 +38,17 @@ public class DefaultFieldAccessController implements FieldAccessController {
         return false;
     }
 
+    /**
+     * 执行更新操作的控制,此方法永远返回true.通过取得参数中实现{@link Entity}的参数,将把这个参数实体所对应不能操作的字段全部设置为null。 <br>
+     * 注意: 此方式还需要dao框架的支持(为null的字段不进行更新) <br>
+     * 如果没有{@link Entity}的参数,则不进行控制并给出警告信息
+     *
+     * @param accesses 不可操作的字段
+     * @param params   参数上下文
+     * @return true
+     * @see BeanUtilsBean
+     * @see org.apache.commons.beanutils.PropertyUtilsBean
+     */
     protected boolean doUpdateAccess(Set<FieldAccess> accesses, ParamContext params) {
         Entity entity = params.getParams().values().stream()
                 .filter(Entity.class::isInstance)
@@ -55,6 +70,14 @@ public class DefaultFieldAccessController implements FieldAccessController {
         return true;
     }
 
+    /**
+     * 执行查询的控制,查询主要针对参数为{@link QueryParamEntity}的动态条件查询,通过设置{@link QueryParamEntity#excludes(String...)}.指定不需要查询的字段
+     * 如果没有{@link QueryParamEntity}的参数,则不进行控制并给出警告信息
+     *
+     * @param accesses 不能查询的字段
+     * @param params   参数上下文
+     * @return true
+     */
     protected boolean doQueryAccess(Set<FieldAccess> accesses, ParamContext params) {
         QueryParamEntity paramEntity = params.getParams().values().stream()
                 .filter(QueryParamEntity.class::isInstance)

+ 0 - 5
hsweb-commons/hsweb-commons-controller/pom.xml

@@ -53,11 +53,6 @@
             <artifactId>hsweb-authorization-api</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.hswebframework.web</groupId>
-            <artifactId>hsweb-authorization-shiro</artifactId>
-            <version>${project.version}</version>
-        </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-webmvc</artifactId>

+ 4 - 9
hsweb-commons/hsweb-commons-controller/src/main/java/org/hswebframework/web/controller/message/ResponseMessage.java

@@ -93,7 +93,7 @@ public class ResponseMessage implements Serializable {
                 } catch (Throwable e) {
                 }
             } else {
-                getStringListFormMap(includes, type).add(field);
+                getStringListFromMap(includes, type).add(field);
             }
         });
         return this;
@@ -114,7 +114,7 @@ public class ResponseMessage implements Serializable {
                 } catch (Throwable e) {
                 }
             } else {
-                getStringListFormMap(excludes, type).add(field);
+                getStringListFromMap(excludes, type).add(field);
             }
         });
         return this;
@@ -154,13 +154,8 @@ public class ResponseMessage implements Serializable {
         return include(Arrays.asList(fields));
     }
 
-    protected Set<String> getStringListFormMap(Map<Class<?>, Set<String>> map, Class type) {
-        Set<String> list = map.get(type);
-        if (list == null) {
-            list = new HashSet<>();
-            map.put(type, list);
-        }
-        return list;
+    protected Set<String> getStringListFromMap(Map<Class<?>, Set<String>> map, Class type) {
+        return map.computeIfAbsent(type, k -> new HashSet<>());
     }
 
     public Object getData() {

+ 4 - 5
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/src/main/java/org/hswebframework/web/dao/datasource/DynamicDataSource.java

@@ -22,6 +22,8 @@ package org.hswebframework.web.dao.datasource;
 import org.hswebframework.web.ThreadLocalUtils;
 
 import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
 
 /**
  * 动态数据源接口,此接口实现多数据源的动态切换
@@ -71,17 +73,13 @@ public interface DynamicDataSource extends DataSource {
 
     /**
      * 切换为默认数据源并记住上一次使用的数据源
-     *
-     * @see this#useDefault(boolean)
      */
     static void useDefault() {
         useDefault(true);
     }
 
     /**
-     * 获取当前激活的数据源
-     *
-     * @return
+     * @return 当前激活的数据源
      */
     DataSource getActiveDataSource();
 
@@ -92,4 +90,5 @@ public interface DynamicDataSource extends DataSource {
      * @see DatabaseType
      */
     DatabaseType getActiveDataBaseType();
+
 }

+ 2 - 2
hsweb-commons/hsweb-commons-entity/pom.xml

@@ -31,9 +31,9 @@
 
     <dependencies>
         <dependency>
-            <groupId>${groupId}</groupId>
+            <groupId>${project.parent.groupId}</groupId>
             <artifactId>hsweb-core</artifactId>
-            <version>${project.version}</version>
+            <version>${project.parent.version}</version>
         </dependency>
         <dependency>
             <groupId>org.hswebframework</groupId>

+ 16 - 8
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/TreeSupportEntity.java

@@ -48,6 +48,12 @@ public interface TreeSupportEntity<PK> extends GenericEntity<PK> {
 
     <T extends TreeSupportEntity<PK>> List<T> getChildren();
 
+    /**
+     * 根据treeCode获取父节点的treeCode
+     *
+     * @param treeCode treeCode
+     * @return 父节点treeCode
+     */
     static String getParentTreeCode(String treeCode) {
         if (treeCode == null || treeCode.length() < 4) return null;
         return treeCode.substring(0, treeCode.length() - 5);
@@ -58,9 +64,11 @@ public interface TreeSupportEntity<PK> extends GenericEntity<PK> {
      * 如树结构数据: {name:'父节点',children:[{name:'子节点1'},{name:'子节点2'}]}<br>
      * 解析后:[{id:'id1',name:'父节点',treeCode:'<b>aoSt</b>'},{id:'id2',name:'子节点1',treeCode:'<b>aoSt</b>-oS5a'},{id:'id3',name:'子节点2',treeCode:'<b>aoSt</b>-uGpM'}]
      *
-     * @param parent 树结构的根节点
-     * @param target 目标集合,转换后的数据将直接添加({@link List#add(Object)})到这个集合.
-     * @param <T>    继承{@link TreeSupportEntity}的类型
+     * @param parent      树结构的根节点
+     * @param target      目标集合,转换后的数据将直接添加({@link List#add(Object)})到这个集合.
+     * @param <T>         继承{@link TreeSupportEntity}的类型
+     * @param idGenerator ID生成策略
+     * @param <PK>        主键类型
      */
     static <T extends TreeSupportEntity<PK>, PK> void expandTree2List(TreeSupportEntity<PK> parent, List<T> target, IDGenerator<PK> idGenerator) {
         List<T> children = parent.getChildren();
@@ -87,13 +95,13 @@ public interface TreeSupportEntity<PK> extends GenericEntity<PK> {
     }
 
     /**
-     * 集合转为树形结构
+     * 集合转为树形结构,返回根节点集合
      *
      * @param dataList      需要转换的集合
-     * @param childAccepter
-     * @param <T>
-     * @param <PK>
-     * @return
+     * @param childAccepter 设置子节点回调
+     * @param <T>           树节点类型
+     * @param <PK>          主键类型
+     * @return 树形结构集合
      */
     static <T extends TreeSupportEntity<PK>, PK> List<T> list2tree(Collection<T> dataList, BiConsumer<T, List<T>> childAccepter) {
         // id,obj

+ 1 - 1
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/EntityFactory.java

@@ -41,7 +41,7 @@ public interface EntityFactory {
      * 根据类型获取实体的真实的实体类型,
      * 可通过此方法获取获取已拓展的实体类型,如:<br>
      * <code>
-     * factory.getInstanceType(MyBeanInterface.class); -> class SimpleMyBeanInterface
+     * factory.getInstanceType(MyBeanInterface.class);
      * </code>
      *
      * @param entityClass 类型

+ 4 - 4
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/param/DeleteParamEntity.java

@@ -4,9 +4,9 @@ import org.hsweb.ezorm.core.param.Param;
 import org.hswebframework.web.commons.entity.Entity;
 
 /**
- * 查询参数实体,使用<a href="https://github.com/hs-web/hsweb-easy-orm">easyorm</a>进行动态查询参数构建<br/>
- * 可通过静态方法创建:<br/>
- * {@link DeleteParamEntity#build()}<br/>
+ * 查询参数实体,使用<a href="https://github.com/hs-web/hsweb-easy-orm">easyorm</a>进行动态查询参数构建<br>
+ * 可通过静态方法创建:<br>
+ * {@link DeleteParamEntity#build()}<br>
  *
  * @author zhouhao
  * @see Param
@@ -19,7 +19,7 @@ public class DeleteParamEntity extends Param implements Entity {
      * 创建后需自行指定条件({@link DeleteParamEntity#where(String, Object)})
      * 否则可能无法执行更新(dao实现应该禁止无条件的删除)
      *
-     * @return
+     * @return DeleteParamEntity
      */
     public static DeleteParamEntity build() {
         return new DeleteParamEntity();

+ 4 - 4
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/param/QueryParamEntity.java

@@ -4,10 +4,10 @@ import org.hsweb.ezorm.core.param.QueryParam;
 import org.hswebframework.web.commons.entity.Entity;
 
 /**
- * 查询参数实体,使用<a href="https://github.com/hs-web/hsweb-easy-orm">easyorm</a>进行动态查询参数构建<br/>
- * 可通过静态方法创建:<br/>
- * {@link QueryParamEntity#empty()}<br/>
- * {@link QueryParamEntity#single(String, Object)}<br/>
+ * 查询参数实体,使用<a href="https://github.com/hs-web/hsweb-easy-orm">easyorm</a>进行动态查询参数构建<br>
+ * 可通过静态方法创建:<br>
+ * {@link QueryParamEntity#empty()}<br>
+ * {@link QueryParamEntity#single(String, Object)}<br>
  * 如:
  * <code>
  * QueryParamBean.single("id",id);

+ 1 - 1
hsweb-commons/hsweb-commons-service/hsweb-commons-service-api/src/main/java/org/hswebframework/web/service/UpdateService.java

@@ -41,7 +41,7 @@ public interface UpdateService<Po> extends Service {
      * 保存或修改
      *
      * @param po 要修改的数据
-     * @return
+     * @return 影响记录数
      */
     int saveOrUpdate(Po po);
 

+ 3 - 5
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/DefaultQueryByEntityService.java

@@ -37,8 +37,7 @@ public interface DefaultQueryByEntityService<E>
      * 分页进行查询数据,查询条件同 {@link DefaultQueryByEntityService#select}
      *
      * @param param 查询参数
-     * @return 分页结果
-     * @ 查询异常
+     * @return 分页查询结果
      */
     @Override
     default PagerResult<E> selectPager(Entity param) {
@@ -85,11 +84,10 @@ public interface DefaultQueryByEntityService<E>
     }
 
     /**
-     * 查询只返回单个结果
+     * 查询只返回单个结果,如果有多个结果,只返回第一个
      *
      * @param param 查询条件
-     * @return 单个结果
-     * @see this#select(Entity)
+     * @return 单个查询结果
      */
     @Override
     @Transactional(readOnly = true)

+ 2 - 1
hsweb-core/src/main/java/org/hswebframework/web/id/IDGenerator.java

@@ -25,9 +25,10 @@ import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 
 /**
- * TODO 完成注释
+ * ID生成器,用于生成ID
  *
  * @author zhouhao
+ * @since 3.0
  */
 public interface IDGenerator<T> {
     T generate();

+ 9 - 14
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimpleAuthorization.java

@@ -92,20 +92,9 @@ public class SimpleAuthorization implements Authorization {
     }
 
     @Override
-    public <T extends Serializable> T getAttribute(String name) {
-        return ((T) attributes.get(name));
-    }
-
-    @Override
-    public <T extends Serializable> T getAttribute(String name, T defaultValue) {
-        T val = getAttribute(name);
-        return val == null ? defaultValue : val;
-    }
-
-    @Override
-    public <T extends Serializable> T getAttribute(String name, Supplier<T> supplier) {
-        T val = getAttribute(name);
-        return val == null ? supplier.get() : val;
+    @SuppressWarnings("unchecked")
+    public <T extends Serializable> Optional<T> getAttribute(String name) {
+        return Optional.of((T) attributes.get(name));
     }
 
     @Override
@@ -132,6 +121,12 @@ public class SimpleAuthorization implements Authorization {
         this.attributes = attributes;
     }
 
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T extends Serializable> T removeAttributes(String name) {
+        return (T) attributes.remove(name);
+    }
+
     public Map<String, Serializable> getAttributes() {
         return attributes;
     }