diff --git a/example/example-app/example-app-cmd-domain/pom.xml b/example/example-app/example-app-cmd-domain/pom.xml index cdbea2e3..d71638c9 100644 --- a/example/example-app/example-app-cmd-domain/pom.xml +++ b/example/example-app/example-app-cmd-domain/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-app/example-app-cmd-meta/pom.xml b/example/example-app/example-app-cmd-meta/pom.xml index 6c9b04b3..5b50656a 100644 --- a/example/example-app/example-app-cmd-meta/pom.xml +++ b/example/example-app/example-app-cmd-meta/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-app/example-app-query/pom.xml b/example/example-app/example-app-query/pom.xml index 0645e7ee..edb1fc71 100644 --- a/example/example-app/example-app-query/pom.xml +++ b/example/example-app/example-app-query/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-app - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-app/pom.xml b/example/example-app/pom.xml index 9f076296..4d3edb3a 100644 --- a/example/example-app/pom.xml +++ b/example/example-app/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.45 + 3.4.46 ../pom.xml pom diff --git a/example/example-domain/example-domain-leave/pom.xml b/example/example-domain/example-domain-leave/pom.xml index d7c2ada9..29850fd5 100644 --- a/example/example-domain/example-domain-leave/pom.xml +++ b/example/example-domain/example-domain-leave/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-domain/example-domain-user/pom.xml b/example/example-domain/example-domain-user/pom.xml index 2f188b31..df83c04b 100644 --- a/example/example-domain/example-domain-user/pom.xml +++ b/example/example-domain/example-domain-user/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-domain - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-domain/pom.xml b/example/example-domain/pom.xml index 98a5ca27..9fd07a36 100644 --- a/example/example-domain/pom.xml +++ b/example/example-domain/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-example - 3.4.45 + 3.4.46 ../pom.xml 4.0.0 diff --git a/example/example-infra/example-infra-flow/pom.xml b/example/example-infra/example-infra-flow/pom.xml index ef2c201d..90c6b246 100644 --- a/example/example-infra/example-infra-flow/pom.xml +++ b/example/example-infra/example-infra-flow/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-infra/example-infra-jpa/pom.xml b/example/example-infra/example-infra-jpa/pom.xml index c6e9ba9d..7e60dc2b 100644 --- a/example/example-infra/example-infra-jpa/pom.xml +++ b/example/example-infra/example-infra-jpa/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot example-infra - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-infra/example-infra-security/pom.xml b/example/example-infra/example-infra-security/pom.xml index 33fa1f61..34f5de56 100644 --- a/example/example-infra/example-infra-security/pom.xml +++ b/example/example-infra/example-infra-security/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot example-infra - 3.4.45 + 3.4.46 ../pom.xml diff --git a/example/example-infra/pom.xml b/example/example-infra/pom.xml index ce319bb6..24cd9c4b 100644 --- a/example/example-infra/pom.xml +++ b/example/example-infra/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.45 + 3.4.46 ../pom.xml pom diff --git a/example/example-interface/pom.xml b/example/example-interface/pom.xml index 270dfbed..b9e33f63 100644 --- a/example/example-interface/pom.xml +++ b/example/example-interface/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-example - 3.4.45 + 3.4.46 example-interface diff --git a/example/example-server/pom.xml b/example/example-server/pom.xml index a62efec3..3f96a1eb 100644 --- a/example/example-server/pom.xml +++ b/example/example-server/pom.xml @@ -5,7 +5,7 @@ springboot-example com.codingapi.springboot - 3.4.45 + 3.4.46 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index cc114850..f7a1d626 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -19,7 +19,7 @@ springboot-example - 3.4.45 + 3.4.46 springboot-example springboot-example project for Spring Boot diff --git a/pom.xml b/pom.xml index ecbbd600..7788e956 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.codingapi.springboot springboot-parent - 3.4.45 + 3.4.46 https://github.com/codingapi/springboot-framewrok springboot-parent diff --git a/springboot-starter-data-authorization/pom.xml b/springboot-starter-data-authorization/pom.xml index fdcccbc7..3edbddfd 100644 --- a/springboot-starter-data-authorization/pom.xml +++ b/springboot-starter-data-authorization/pom.xml @@ -6,7 +6,7 @@ com.codingapi.springboot springboot-parent - 3.4.45 + 3.4.46 springboot-starter-data-authorization diff --git a/springboot-starter-data-fast/pom.xml b/springboot-starter-data-fast/pom.xml index 6fe6420c..8a1ecf8c 100644 --- a/springboot-starter-data-fast/pom.xml +++ b/springboot-starter-data-fast/pom.xml @@ -5,7 +5,7 @@ springboot-parent com.codingapi.springboot - 3.4.45 + 3.4.46 4.0.0 diff --git a/springboot-starter-flow/pom.xml b/springboot-starter-flow/pom.xml index 6e6a60a9..4ff286b4 100644 --- a/springboot-starter-flow/pom.xml +++ b/springboot-starter-flow/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.45 + 3.4.46 springboot-starter-flow diff --git a/springboot-starter-security/pom.xml b/springboot-starter-security/pom.xml index 9b411bd8..2040a630 100644 --- a/springboot-starter-security/pom.xml +++ b/springboot-starter-security/pom.xml @@ -6,7 +6,7 @@ springboot-parent com.codingapi.springboot - 3.4.45 + 3.4.46 springboot-starter-security diff --git a/springboot-starter/pom.xml b/springboot-starter/pom.xml index eeae0aaa..c682ffd5 100644 --- a/springboot-starter/pom.xml +++ b/springboot-starter/pom.xml @@ -5,7 +5,7 @@ com.codingapi.springboot springboot-parent - 3.4.45 + 3.4.46 springboot-starter diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/GroovyMetadataReloadGatewayContext.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/GroovyMetadataReloadGatewayContext.java new file mode 100644 index 00000000..3db69b87 --- /dev/null +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/GroovyMetadataReloadGatewayContext.java @@ -0,0 +1,31 @@ +package com.codingapi.springboot.framework.script; + +import com.codingapi.springboot.framework.script.gateway.GroovyMetadataReloadGateway; +import com.codingapi.springboot.framework.script.meta.GroovyMetadata; +import lombok.Getter; + +import java.util.ArrayList; +import java.util.List; + +public class GroovyMetadataReloadGatewayContext { + + private final List gateways; + + @Getter + private final static GroovyMetadataReloadGatewayContext instance = new GroovyMetadataReloadGatewayContext(); + + private GroovyMetadataReloadGatewayContext(){ + this.gateways = new ArrayList<>(); + } + + public void addGateway(GroovyMetadataReloadGateway gateway){ + this.gateways.add(gateway); + } + + public void reload(GroovyMetadata metadata){ + for (GroovyMetadataReloadGateway gateway:gateways){ + gateway.reload(metadata); + } + } + +} diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/gateway/GroovyMetadataReloadGateway.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/gateway/GroovyMetadataReloadGateway.java new file mode 100644 index 00000000..ba35a0b2 --- /dev/null +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/gateway/GroovyMetadataReloadGateway.java @@ -0,0 +1,12 @@ +package com.codingapi.springboot.framework.script.gateway; + +import com.codingapi.springboot.framework.script.meta.GroovyMetadata; + +/** + * 脚本元数据刷新加载对象 + */ +public interface GroovyMetadataReloadGateway { + + void reload(GroovyMetadata metadata); + +} diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/meta/GroovyMetadata.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/meta/GroovyMetadata.java index 1e289922..b4a69550 100644 --- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/meta/GroovyMetadata.java +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/meta/GroovyMetadata.java @@ -45,6 +45,10 @@ public GroovyMetadata() { this.binds = new ArrayList<>(); } + /** + * 通过class构建 脚本类型数据 + * @param clazz class类型 + */ public void buildType(Class clazz) { String dataType = clazz.getSimpleName(); GroovyType groovyType = this.types.get(dataType); @@ -56,20 +60,42 @@ public void buildType(Class clazz) { if(scriptType!=null) { groovyType.setDescription(scriptType.description()); } - this.types.put(dataType, groovyType); + this.put(dataType, groovyType); } } + /** + * 增加请求参数数据对象 + * @param request 请求参数 + */ public void addRequest(GroovyField request) { this.requests.add(request); } + /** + * 更新流程类型数据 + * @param dataType 数据类型 + * @param groovyType 脚本类型 + */ + public void put(String dataType,GroovyType groovyType){ + this.types.put(dataType, groovyType); + } + + /** + * 获取流程类型数据 + * @param dataType 数据类型 + * @return 脚本类型 + */ public GroovyType getType(String dataType){ return this.types.get(dataType); } + /** + * 增加绑定数据对象 + * @param bind 绑定数据 + */ public void addBind(GroovyField bind) { this.binds.add(bind); } diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/request/GroovyRunningScript.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/request/GroovyRunningScript.java index 633f7d2d..178d9d6a 100644 --- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/request/GroovyRunningScript.java +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/request/GroovyRunningScript.java @@ -1,5 +1,6 @@ package com.codingapi.springboot.framework.script.request; +import com.codingapi.springboot.framework.script.GroovyMetadataReloadGatewayContext; import com.codingapi.springboot.framework.script.meta.GroovyMetadata; import com.codingapi.springboot.framework.script.service.GroovyMetadataParserService; import lombok.Getter; @@ -84,16 +85,22 @@ public Object[] getParams() { return objects.toArray(); } + /** + * 重新设置脚本元数据信息 + * @param metadata 脚本元数据信息 + */ public void resetMetadata(GroovyMetadata metadata) { this.metadata = metadata; + GroovyMetadataReloadGatewayContext.getInstance().reload(this.metadata); } /** - * 构建元数据信息 + * 构建脚本元数据信息 */ public void buildMetadata() { GroovyMetadataParserService groovyMetaDataParserService = new GroovyMetadataParserService(this); this.metadata = groovyMetaDataParserService.parser(); + GroovyMetadataReloadGatewayContext.getInstance().reload(this.metadata); } } diff --git a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/service/GroovyTypeParser.java b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/service/GroovyTypeParser.java index 21dbb3a6..c29cf655 100644 --- a/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/service/GroovyTypeParser.java +++ b/springboot-starter/src/main/java/com/codingapi/springboot/framework/script/service/GroovyTypeParser.java @@ -70,34 +70,34 @@ private void loadMethods() { groovyFunction.setDescription(scriptFunction.description()); } - Parameter[] methodParameters = method.getParameters(); - Map parameterMap = new HashMap<>(); - for (Parameter parameter : methodParameters) { - parameterMap.put(parameter.getName(), parameter); - } - ScriptField[] parameters = scriptFunction.parameters(); + Map parameterMap = new HashMap<>(); if (parameters != null) { - for (ScriptField parameter : parameters) { - Parameter methodParameter = parameterMap.get(parameter.name()); - if (methodParameter != null) { - Class clazz = methodParameter.getType(); - this.metadata.buildType(clazz); - - GroovyField groovyParameter = new GroovyField(); - groovyParameter.setDataType(clazz.getSimpleName()); - groovyParameter.setName(methodParameter.getName()); - - if (StringUtils.hasText(parameter.name())) { - groovyParameter.setName(parameter.name()); - } - if (StringUtils.hasText(parameter.description())) { - groovyParameter.setDescription(parameter.description()); - } - - groovyFunction.addParameter(groovyParameter); + for (ScriptField scriptField : parameters) { + parameterMap.put(scriptField.name(), scriptField); + } + } + + Parameter[] methodParameters = method.getParameters(); + for (Parameter methodParameter : methodParameters) { + Class clazz = methodParameter.getType(); + this.metadata.buildType(clazz); + + GroovyField groovyParameter = new GroovyField(); + groovyParameter.setDataType(clazz.getSimpleName()); + groovyParameter.setName(methodParameter.getName()); + + ScriptField scriptParameter = parameterMap.get(methodParameter.getName()); + if (scriptParameter != null) { + if (StringUtils.hasText(scriptParameter.name())) { + groovyParameter.setName(scriptParameter.name()); + } + if (StringUtils.hasText(scriptParameter.description())) { + groovyParameter.setDescription(scriptParameter.description()); } } + + groovyFunction.addParameter(groovyParameter); } Class returnType = method.getReturnType();