zhouhao 7 lat temu
rodzic
commit
c10f8bfdcd

+ 1 - 0
hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/define/DefaultBasicAuthorizeDefinition.java

@@ -107,6 +107,7 @@ public class DefaultBasicAuthorizeDefinition implements AopAuthorizeDefinition {
             definition.setController(dataAccess.getClass().getName());
         }
         dataAccessDefinition = definition;
+        dataAccessControl=true;
     }
 
 

+ 4 - 4
hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/EnumDictHandlerRegister.java

@@ -68,7 +68,7 @@ public class EnumDictHandlerRegister {
                             //注册枚举数组类型
                             typeHandlerRegistry.register(Array.newInstance(enumType, 0).getClass(), new EnumDictArrayHandler(enumType));
                         }
-                    } catch (Exception ignore) {
+                    } catch (Exception | Error ignore) {
 
                     }
                 }
@@ -130,9 +130,9 @@ public class EnumDictHandlerRegister {
 
         @Override
         public void setParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
-            if(parameter==null){
-                ps.setNull(i,jdbcType.TYPE_CODE);
-            }else {
+            if (parameter == null) {
+                ps.setNull(i, jdbcType.TYPE_CODE);
+            } else {
                 ps.setObject(i, parameter.getValue());
             }
         }

+ 6 - 5
hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/SimpleGenericEntity.java

@@ -18,6 +18,8 @@
 
 package org.hswebframework.web.commons.entity;
 
+import lombok.SneakyThrows;
+
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -27,6 +29,8 @@ import java.util.Map;
  */
 public abstract class SimpleGenericEntity<PK> implements GenericEntity<PK> {
 
+    private static final long serialVersionUID = 4546315942526096290L;
+
     private PK id;
 
     private Map<String, Object> properties;
@@ -75,11 +79,8 @@ public abstract class SimpleGenericEntity<PK> implements GenericEntity<PK> {
 
     @Override
     @SuppressWarnings("unchecked")
+    @SneakyThrows
     public SimpleGenericEntity<PK> clone() {
-        try {
-            return (SimpleGenericEntity) super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new RuntimeException(e);
-        }
+        return (SimpleGenericEntity) super.clone();
     }
 }

+ 16 - 26
hsweb-core/src/main/java/org/hswebframework/web/proxy/Proxy.java

@@ -4,6 +4,8 @@ import javassist.*;
 import javassist.bytecode.AnnotationsAttribute;
 import javassist.bytecode.ConstPool;
 import lombok.Getter;
+import lombok.SneakyThrows;
+import org.springframework.util.ClassUtils;
 
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -12,8 +14,7 @@ import java.util.concurrent.atomic.AtomicLong;
  * @since 3.0
  */
 public class Proxy<I> {
-    public              ClassPool  classPool = new ClassPool(true);
-    public static final AtomicLong counter   = new AtomicLong(1);
+    private static final AtomicLong counter = new AtomicLong(1);
 
     private CtClass  ctClass;
     @Getter
@@ -25,19 +26,19 @@ public class Proxy<I> {
 
     private Class<I> targetClass;
 
+    @SneakyThrows
     public static <I> Proxy<I> create(Class<I> superClass, String... classPathString) {
-        try {
-            return new Proxy<>(superClass, classPathString);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+        return new Proxy<>(superClass, classPathString);
     }
 
-    public Proxy(Class<I> superClass, String... classPathString) throws Exception {
+    @SneakyThrows
+    public Proxy(Class<I> superClass, String... classPathString) {
         if (superClass == null) {
             throw new NullPointerException("superClass can not be null");
         }
         this.superClass = superClass;
+        ClassPool classPool = new ClassPool(true);
+
         ClassPath classPath = new ClassClassPath(this.getClass());
         classPool.insertClassPath(classPath);
 
@@ -58,7 +59,6 @@ public class Proxy<I> {
                 ctClass.setSuperclass(classPool.get(superClass.getName()));
             }
         }
-//        ctClass.debugWriteFile();
         addConstructor("public " + className + "(){}");
     }
 
@@ -74,6 +74,7 @@ public class Proxy<I> {
         return addField(code, null);
     }
 
+    @SneakyThrows
     public Proxy<I> addField(String code, String annotation) {
         return handleException(() -> {
             CtField ctField = CtField.make(code, ctClass);
@@ -89,33 +90,22 @@ public class Proxy<I> {
         });
     }
 
+    @SneakyThrows
     private Proxy<I> handleException(Task task) {
-        try {
-            task.run();
-        } catch (RuntimeException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
+        task.run();
         return this;
     }
 
 
+    @SneakyThrows
     public I newInstance() {
-        try {
-            return getTargetClass().newInstance();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
+        return getTargetClass().newInstance();
     }
 
+    @SneakyThrows
     public Class<I> getTargetClass() {
         if (targetClass == null) {
-            try {
-                targetClass = ctClass.toClass();
-            } catch (CannotCompileException e) {
-                throw new RuntimeException(e.getMessage(), e);
-            }
+            targetClass = ctClass.toClass(ClassUtils.getDefaultClassLoader(), null);
         }
         return targetClass;
     }

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

@@ -12,8 +12,6 @@ import java.util.Set;
 import static org.hswebframework.web.organizational.authorization.access.DataAccessType.*;
 
 /**
- * TODO 完成注释
- *
  * @author zhouhao
  */
 public class DistrictScopeDataAccessHandler extends AbstractScopeDataAccessHandler<DistrictAttachEntity> {