Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/4.0.x' into 4.0.x

zhou-hao 5 rokov pred
rodič
commit
b61c40d56b
28 zmenil súbory, kde vykonal 77 pridanie a 38 odobranie
  1. 1 1
      hsweb-authorization/hsweb-authorization-api/pom.xml
  2. 1 1
      hsweb-authorization/hsweb-authorization-basic/pom.xml
  3. 1 1
      hsweb-authorization/pom.xml
  4. 1 1
      hsweb-commons/hsweb-commons-api/pom.xml
  5. 1 1
      hsweb-commons/hsweb-commons-crud/pom.xml
  6. 1 1
      hsweb-commons/pom.xml
  7. 1 1
      hsweb-concurrent/hsweb-concurrent-cache/pom.xml
  8. 1 1
      hsweb-concurrent/pom.xml
  9. 1 1
      hsweb-core/pom.xml
  10. 1 5
      hsweb-core/src/main/java/org/hswebframework/web/bean/DefaultToStringOperator.java
  11. 26 8
      hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java
  12. 1 1
      hsweb-core/src/main/java/org/hswebframework/web/utils/TemplateParser.java
  13. 25 0
      hsweb-core/src/test/java/org/hswebframework/web/utils/ExpressionUtilsTest.java
  14. 1 1
      hsweb-datasource/hsweb-datasource-api/pom.xml
  15. 1 1
      hsweb-datasource/hsweb-datasource-jta/pom.xml
  16. 1 1
      hsweb-datasource/hsweb-datasource-web/pom.xml
  17. 1 1
      hsweb-datasource/pom.xml
  18. 1 1
      hsweb-logging/hsweb-access-logging-aop/pom.xml
  19. 1 1
      hsweb-logging/hsweb-access-logging-api/pom.xml
  20. 1 1
      hsweb-logging/pom.xml
  21. 1 1
      hsweb-starter/pom.xml
  22. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml
  23. 1 1
      hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml
  24. 1 1
      hsweb-system/hsweb-system-authorization/pom.xml
  25. 1 1
      hsweb-system/hsweb-system-dictionary/pom.xml
  26. 1 1
      hsweb-system/hsweb-system-file/pom.xml
  27. 1 1
      hsweb-system/pom.xml
  28. 1 1
      pom.xml

+ 1 - 1
hsweb-authorization/hsweb-authorization-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-authorization</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-authorization/hsweb-authorization-basic/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-authorization</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-authorization/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-commons/hsweb-commons-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-commons</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-commons/hsweb-commons-crud/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-commons</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-commons/pom.xml

@@ -23,7 +23,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
hsweb-concurrent/hsweb-concurrent-cache/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-concurrent</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-concurrent/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-core/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 5
hsweb-core/src/main/java/org/hswebframework/web/bean/DefaultToStringOperator.java

@@ -115,9 +115,6 @@ public class DefaultToStringOperator<T> implements ToStringOperator<T> {
             long propertyFeature = 0;
             try {
                 Field field = ReflectionUtils.findField(targetType, descriptor.getName());
-                if (null == field) {
-                    log.debug("无法获取字段{},该字段将不会被打码!", descriptor.getName());
-                }
                 propertyIgnore = field.getAnnotation(ToString.Ignore.class);
                 features = AnnotationUtils.getAnnotation(field, ToString.Features.class);
                 if (propertyIgnore != null) {
@@ -128,8 +125,7 @@ public class DefaultToStringOperator<T> implements ToStringOperator<T> {
                 if (null != features && features.value().length > 0) {
                     propertyFeature = ToString.Feature.createFeatures(features.value());
                 }
-            } catch (Exception e) {
-                log.debug("无法获取字段{},该字段将不会被打码!", descriptor.getName());
+            } catch (Exception ignore) {
             }
             //是否设置了打码
             boolean cover = (propertyIgnore == null && defaultCover) || (propertyIgnore != null && propertyIgnore.cover());

+ 26 - 8
hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java

@@ -1,10 +1,13 @@
 package org.hswebframework.web.utils;
 
 import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.beanutils.BeanUtilsBean2;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.hswebframework.expands.script.engine.DynamicScriptEngine;
 import org.hswebframework.expands.script.engine.DynamicScriptEngineFactory;
 import org.hswebframework.expands.script.engine.ExecuteResult;
+import org.springframework.util.StringUtils;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -17,6 +20,7 @@ import java.util.regex.Pattern;
  * @author zhouhao
  * @since 3.0
  */
+@Slf4j
 public class ExpressionUtils {
 
     //表达式提取正则 ${.+?}
@@ -75,7 +79,7 @@ public class ExpressionUtils {
      */
     @SneakyThrows
     public static String analytical(String expression, Map<String, Object> vars, String language) {
-        if(!expression.contains("${")){
+        if (!expression.contains("${")) {
             return expression;
         }
         DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(language);
@@ -84,24 +88,38 @@ public class ExpressionUtils {
         }
 
         return TemplateParser.parse(expression, var -> {
-            Object fast = vars.get(var);
-            if (fast != null) {
-                return fast.toString();
+            if (StringUtils.isEmpty(var)) {
+                return "";
             }
-            String id = DigestUtils.md5Hex(var);
 
+            if ("spel".equalsIgnoreCase(language) && !var.startsWith("#")) {
+                try {
+                    Object fast = BeanUtilsBean2.getInstance().getProperty(vars, var);
+                    if (fast != null) {
+                        return fast.toString();
+                    }
+                } catch (Exception ignore) {
+                    //ignore
+                    return "";
+                }
+            }
+            String id = DigestUtils.md5Hex(var);
             try {
                 if (!engine.compiled(id)) {
-
                     engine.compile(id, var);
-
                 }
-                return String.valueOf(engine.execute(id, vars).getIfSuccess());
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
+            try {
+                return String.valueOf(engine.execute(id, vars).getIfSuccess());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return "";
+            }
+
         });
     }
 

+ 1 - 1
hsweb-core/src/main/java/org/hswebframework/web/utils/TemplateParser.java

@@ -103,7 +103,7 @@ public class TemplateParser {
         while (next()) {
             if (isPrepare()) {
                 inPrepare = true;
-            } else if (isPrepareEnd()) {
+            } else if (inPrepare&&isPrepareEnd()) {
                 inPrepare = false;
                 setParsed(propertyMapping.apply(new String(expression, 0, expressionPos)).toCharArray());
                 expressionPos = 0;

+ 25 - 0
hsweb-core/src/test/java/org/hswebframework/web/utils/ExpressionUtilsTest.java

@@ -1,5 +1,6 @@
 package org.hswebframework.web.utils;
 
+import com.alibaba.fastjson.JSON;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -38,4 +39,28 @@ public class ExpressionUtilsTest {
         }));
 
     }
+
+    @Test
+    public void testJson2(){
+        String js = ExpressionUtils.analytical("{\n" +
+                "     \"msgtype\": \"markdown\",\n" +
+                "     \"markdown\": {\n" +
+                "         \"title\":\"消息类型:${messageType}\",\n" +
+                "         \"text\": \" - 设备ID: `${deviceId}` \\n - 设备型号: `${headers.productId}`\\n - 设备名称: `${headers.deviceName}`\"" +
+                "     \n},\n" +
+                "      \"at\": {\n" +
+                "          \"isAtAll\": false\n" +
+                "      }\n" +
+                "}", JSON.parseObject("{\n" +
+                "  \"deviceId\": \"VIS-Mandrake-12289\",\n" +
+                "  \"headers\": {\n" +
+                "    \"productId\": \"VIS-Mandrake\",\n" +
+                "    \"deviceName\": \"能见度仪-曼德克-01\"\n" +
+                "  },\n" +
+                "  \"messageType\": \"OFFLINE\",\n" +
+                "  \"timestamp\": 1592098397277\n" +
+                "}"), "spel");
+
+        System.out.println(js);
+    }
 }

+ 1 - 1
hsweb-datasource/hsweb-datasource-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-datasource</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
 
         <relativePath>../pom.xml</relativePath>
     </parent>

+ 1 - 1
hsweb-datasource/hsweb-datasource-jta/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-datasource</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
 
     </parent>

+ 1 - 1
hsweb-datasource/hsweb-datasource-web/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-datasource</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
 
         <relativePath>../pom.xml</relativePath>
     </parent>

+ 1 - 1
hsweb-datasource/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
 
         <relativePath>../pom.xml</relativePath>
     </parent>

+ 1 - 1
hsweb-logging/hsweb-access-logging-aop/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-logging</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
hsweb-logging/hsweb-access-logging-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-logging</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
hsweb-logging/pom.xml

@@ -23,7 +23,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
hsweb-starter/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-system-authorization</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-system-authorization</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-system/hsweb-system-authorization/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-system</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <packaging>pom</packaging>

+ 1 - 1
hsweb-system/hsweb-system-dictionary/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-system</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-system/hsweb-system-file/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-system</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
 

+ 1 - 1
hsweb-system/pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <artifactId>hsweb-framework</artifactId>
         <groupId>org.hswebframework.web</groupId>
-        <version>4.0.3</version>
+        <version>4.0.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>

+ 1 - 1
pom.xml

@@ -24,7 +24,7 @@
 
     <groupId>org.hswebframework.web</groupId>
     <artifactId>hsweb-framework</artifactId>
-    <version>4.0.3</version>
+    <version>4.0.4-SNAPSHOT</version>
     <modules>
         <module>hsweb-starter</module>
         <module>hsweb-core</module>