diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml
index aa57db57..24a09e75 100644
--- a/.github/workflows/docker-build.yml
+++ b/.github/workflows/docker-build.yml
@@ -4,10 +4,10 @@ name: Docker Build
on:
push:
branches:
- - main
- - release-*
+ - "main"
+ - "release-*"
tags:
- - 'v*'
+ - "v*"
jobs:
build:
@@ -22,6 +22,16 @@ jobs:
distribution: 'adopt'
- name: Build with Maven
run: mvn -B package --file pom.xml -Dmaven.test.skip
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v4
+ with:
+ images: ${{ secrets.DOCKER_HUB_USERNAME }}/hango-portal
+ flavor: latest=true
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
@@ -34,5 +44,5 @@ jobs:
with:
context: .
file: ./gateway-portal/Dockerfile
- push: true
- tags: ${{ secrets.DOCKER_HUB_USERNAME }}/hango-portal:latest
\ No newline at end of file
+ push: ${{ github.ref_type == 'tag' }}
+ tags: ${{ steps.meta.outputs.tags }}
\ No newline at end of file
diff --git a/gateway-api/pom.xml b/gateway-api/pom.xml
index 2a537a3e..1cfde3eb 100644
--- a/gateway-api/pom.xml
+++ b/gateway-api/pom.xml
@@ -11,7 +11,7 @@
4.0.0
gateway-api
- 0.1.5-SNAPSHOT
+ 0.1.6-SNAPSHOT
jar
@@ -69,7 +69,7 @@
io.swagger
swagger-core
- 1.5.20
+ 1.6.6
@@ -94,14 +94,8 @@
org.apache.cxf
- cxf-spring-boot-starter-jaxws
- 3.1.12
-
-
- ch.qos.logback
- logback-core
-
-
+ cxf-rt-frontend-jaxws
+ 3.5.3
diff --git a/gateway-portal/pom.xml b/gateway-portal/pom.xml
index 78e72e2c..7d1f0df2 100644
--- a/gateway-portal/pom.xml
+++ b/gateway-portal/pom.xml
@@ -22,7 +22,8 @@
UTF-8
UTF-8
1.8
- 1.5.4.RELEASE
+ 1.48.1
+ 2.0.9
org.hango.cloud.dashboard.DashboardApplication
@@ -35,18 +36,9 @@
-
-
- org.springframework.boot
- spring-boot-dependencies
- ${spring.boot.version}
- pom
- import
-
org.springframework.boot
spring-boot-starter-web
- ${spring.boot.version}
@@ -61,7 +53,6 @@
org.springframework.boot
spring-boot-starter
- ${spring.boot.version}
org.springframework.boot
@@ -73,15 +64,9 @@
org.springframework.boot
spring-boot-starter-test
- ${spring.boot.version}
test
-
-
-
-
-
org.apache.logging.log4j
log4j-slf4j-impl
@@ -114,27 +99,23 @@
org.slf4j
jul-to-slf4j
- 1.7.30
compile
-
-
-
-
-
+
+ com.querydsl
+ querydsl-core
+
org.springframework.boot
spring-boot-starter-tomcat
- ${spring.boot.version}
org.springframework.boot
spring-boot-starter-jdbc
- ${spring.boot.version}
mysql
@@ -144,7 +125,6 @@
org.apache.commons
commons-dbcp2
- 2.1.1
commons-logging
@@ -156,13 +136,11 @@
redis.clients
jedis
- 2.10.2
org.springframework.boot
spring-boot-starter-data-redis
- ${spring.boot.version}
redis.clients
@@ -175,7 +153,6 @@
org.apache.commons
commons-lang3
- 3.6
io.swagger
@@ -186,7 +163,6 @@
commons-codec
commons-codec
- 1.8
commons-httpclient
@@ -209,7 +185,6 @@
com.nimbusds
nimbus-jose-jwt
- 4.3.1
@@ -221,7 +196,6 @@
org.yaml
snakeyaml
- 1.25
@@ -246,10 +220,16 @@
jest
5.3.3
+
+
+ gson
+ com.google.code.gson
+
+
- org.elasticsearch
- elasticsearch
- 6.8.4
+ io.netty
+ netty-common
+ 4.1.77.Final
@@ -267,19 +247,17 @@
org.hango.cloud
gateway-api
- 0.1.5-SNAPSHOT
+ 0.1.6-SNAPSHOT
org.springframework.cloud
spring-cloud-starter-consul-discovery
- 1.3.4.RELEASE
org.springframework.cloud
- spring-cloud-starter-eureka
- 1.3.4.RELEASE
+ spring-cloud-starter-netflix-eureka-client
org.springframework.boot
@@ -311,13 +289,13 @@
com.h2database
h2
- 2.1.214
+ runtime
org.apache.zookeeper
zookeeper
- 3.6.0
+ 3.6.3
org.slf4j
@@ -383,7 +361,6 @@
org.springframework.boot
spring-boot-starter-aop
- ${spring.boot.version}
spring-expression
@@ -394,7 +371,7 @@
org.redisson
redisson-spring-boot-starter
- 2.15.2
+ 3.16.4
@@ -408,7 +385,6 @@
net.minidev
json-smart
- 2.2.1
test
@@ -416,17 +392,17 @@
io.grpc
grpc-netty-shaded
- 1.20.0
+ ${grpc.version}
io.grpc
grpc-protobuf
- 1.20.0
+ ${grpc.version}
io.grpc
grpc-stub
- 1.20.0
+ ${grpc.version}
com.google.protobuf
@@ -455,21 +431,20 @@
javax.validation
validation-api
- 2.0.1.Final
org.powermock
powermock-module-junit4
- 1.6.5
+ ${mockit.version}
test
org.powermock
- powermock-api-mockito
- 1.6.5
+ powermock-api-mockito2
+ ${mockit.version}
@@ -482,8 +457,19 @@
com.hubspot.jinjava
jinjava
2.5.6
+
+
+ jsoup
+ org.jsoup
+
+
+
+ jsoup
+ org.jsoup
+ 1.14.2
+
@@ -503,6 +489,31 @@
false
+
+ maven-surefire-plugin
+ 2.19.1
+
+ ${argLine}
+
+ **/*Test.java
+
+
+ **/BaseTest.java
+
+
+
+
+ default-test
+ test
+
+ test
+
+
+ ${surefireArgLine}
+
+
+
+
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/DashboardApplication.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/DashboardApplication.java
index 3d47b63b..a908ff8a 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/DashboardApplication.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/DashboardApplication.java
@@ -5,17 +5,11 @@
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
-import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
-import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
-import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
-import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
@@ -31,7 +25,12 @@
* @Author: Wang Dacheng(wangdacheng)
* @Date: 创建时间: 2017/12/4 上午10:33.
*/
-@SpringBootApplication(exclude = {GsonAutoConfiguration.class, JestAutoConfiguration.class, RedisAutoConfiguration.class})
+@SpringBootApplication(
+ exclude = {
+ GsonAutoConfiguration.class,
+ RedisAutoConfiguration.class,
+ AutoServiceRegistrationAutoConfiguration.class
+ })
@ImportResource({"classpath:applicationContext.xml"})
@EnableScheduling
@PropertySource({"classpath:gdashboard-application.properties", "classpath:gdashboard-jdbc.properties"})
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/config/ServerConfiguration.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/config/ServerConfiguration.java
index 5fdad8e6..1769827a 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/config/ServerConfiguration.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/config/ServerConfiguration.java
@@ -1,13 +1,12 @@
package org.hango.cloud.dashboard.apiserver.config;
-import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
+import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* @author Weng Yanghui (wengyanghui)
@@ -20,7 +19,7 @@ public class ServerConfiguration extends WebMvcAutoConfiguration {
@Bean
public WebMvcConfigurer corsConfigurer() {
- return new WebMvcConfigurerAdapter() {
+ return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**")
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboInfoDto.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboInfoDto.java
index ebddb84a..cb3894d7 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboInfoDto.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboInfoDto.java
@@ -2,12 +2,15 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
import org.hango.cloud.dashboard.apiserver.meta.DubboInfo;
import org.hango.cloud.dashboard.apiserver.util.Const;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
import java.util.ArrayList;
import java.util.List;
@@ -53,7 +56,7 @@ public class DubboInfoDto {
private String version;
/**
- * 是否开启自定义参数映射开关, 默认false
+ * 是否开启自定义参数映射开关, 目前只支持开启
*/
@JSONField(name = "CustomParamMapping")
private boolean customParamMapping;
@@ -70,6 +73,27 @@ public class DubboInfoDto {
@JSONField(name = "Params")
private List params = new ArrayList<>();
+
+ /**
+ * 参数来源,支持query和body两种参数来源配置
+ */
+ @JSONField(name = "ParamSource")
+ @Pattern(regexp = "query|body")
+ private String paramSource;
+
+ /**
+ * dubbo attachmentInfo
+ */
+ @JSONField(name = "Attachment")
+ private List dubboAttachment;
+
+ /**
+ * 方法是否有效
+ */
+ @JSONField(name = "MethodWorks")
+ private Boolean methodWorks;
+
+
public static DubboInfoDto toDto(DubboInfo info) {
if (info == null) {
return null;
@@ -83,7 +107,9 @@ public static DubboInfoDto toDto(DubboInfo info) {
dubboInfoDto.setVersion(meta.getVersion());
dubboInfoDto.setGroup(meta.getGroup());
dubboInfoDto.setParams(meta.getParams());
+ dubboInfoDto.setParamSource(meta.getParamSource());
dubboInfoDto.setCustomParamMapping(meta.getCustomParamMapping());
+ dubboInfoDto.setDubboAttachment(meta.getAttachmentInfo());
return dubboInfoDto;
}
@@ -103,6 +129,22 @@ public void setParams(List params) {
this.params = params;
}
+ public String getParamSource() {
+ return paramSource;
+ }
+
+ public void setParamSource(String paramSource) {
+ this.paramSource = paramSource;
+ }
+
+ public List getDubboAttachment() {
+ return dubboAttachment;
+ }
+
+ public void setDubboAttachment(List dubboAttachment) {
+ this.dubboAttachment = dubboAttachment;
+ }
+
public String getParamToStr() {
if (CollectionUtils.isEmpty(params)) {
return null;
@@ -162,6 +204,14 @@ public void setCustomParamMapping(boolean customParamMapping) {
this.customParamMapping = customParamMapping;
}
+ public Boolean getMethodWorks() {
+ return methodWorks;
+ }
+
+ public void setMethodWorks(Boolean methodWorks) {
+ this.methodWorks = methodWorks;
+ }
+
public DubboInfo toMeta() {
DubboInfo dubboInfo = new DubboInfo();
dubboInfo.setObjectId(objectId);
@@ -172,7 +222,9 @@ public DubboInfo toMeta() {
meta.setMethod(method);
meta.setInterfaceName(interfaceName);
meta.setParams(params);
+ meta.setParamSource(paramSource);
meta.setCustomParamMapping(customParamMapping);
+ meta.setAttachmentInfo(dubboAttachment);
dubboInfo.setDubboInfo(JSON.toJSONString(meta));
return dubboInfo;
}
@@ -205,12 +257,26 @@ public static class DubboMeta {
*/
private List params;
-
/**
* 是否开启自定义参数映射开关, 默认false
*/
private boolean customParamMapping;
+ /**
+ * 参数来源,支持:query和body三种参数来源配置
+ */
+ private String paramSource = Const.POSITION_BODY;
+
+ /**
+ * dubbo attachment信息
+ */
+ private List attachmentInfo;
+
+ /**
+ * dubbo 泛型信息
+ */
+ private String genericInfo;
+
public String getMethod() {
return method;
}
@@ -258,6 +324,30 @@ public boolean getCustomParamMapping() {
public void setCustomParamMapping(boolean customParamMapping) {
this.customParamMapping = customParamMapping;
}
+
+ public String getParamSource() {
+ return paramSource;
+ }
+
+ public void setParamSource(String paramSource) {
+ this.paramSource = paramSource;
+ }
+
+ public List getAttachmentInfo() {
+ return attachmentInfo;
+ }
+
+ public void setAttachmentInfo(List attachmentInfo) {
+ this.attachmentInfo = attachmentInfo;
+ }
+
+ public String getGenericInfo() {
+ return genericInfo;
+ }
+
+ public void setGenericInfo(String genericInfo) {
+ this.genericInfo = genericInfo;
+ }
}
public static class DubboParam {
@@ -272,6 +362,15 @@ public static class DubboParam {
@JSONField(name = "Value")
private String value;
+ @JSONField(name = "Required")
+ private boolean required;
+
+ @JSONField(name = "DefaultValue")
+ private Object defaultValue;
+
+ @JSONField(name = "GenericInfo")
+ private String genericInfo;
+
public String getKey() {
return key;
}
@@ -287,5 +386,96 @@ public String getValue() {
public void setValue(String value) {
this.value = value;
}
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(Object defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public String getGenericInfo() {
+ return genericInfo;
+ }
+
+ public void setGenericInfo(String genericInfo) {
+ this.genericInfo = genericInfo;
+ }
+ }
+
+
+ public static class DubboAttachmentDto{
+ /**
+ * attachment位置 Header/Cookie
+ */
+ @JSONField(name = "ParamPosition")
+ private String paramPosition;
+ /**
+ * 客户端参数名称
+ */
+ @JSONField(name = "ClientParamName")
+ private String clientParamName;
+
+ /**
+ * 服务端参数名称
+ */
+ @JSONField(name = "ServerParamName")
+ private String serverParamName;
+
+ /**
+ * 备注信息
+ */
+ @JSONField(name = "Description")
+ private String description;
+
+ public String getParamPosition() {
+ return paramPosition;
+ }
+
+ public void setParamPosition(String paramPosition) {
+ this.paramPosition = paramPosition;
+ }
+
+ public String getClientParamName() {
+ return clientParamName;
+ }
+
+ public void setClientParamName(String clientParamName) {
+ this.clientParamName = clientParamName;
+ }
+
+ public String getServerParamName() {
+ return serverParamName;
+ }
+
+ public void setServerParamName(String serverParamName) {
+ this.serverParamName = serverParamName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDistinctName(){
+ return paramPosition + clientParamName;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+ }
}
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboMetaDto.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboMetaDto.java
index 4f7ecb05..3e241b26 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboMetaDto.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/dto/DubboMetaDto.java
@@ -63,7 +63,7 @@ public class DubboMetaDto implements Comparable {
*/
@JSONField(name = "Group")
- private String group;
+ private String group= StringUtils.EMPTY;;
/**
@@ -71,7 +71,7 @@ public class DubboMetaDto implements Comparable {
*/
@JSONField(name = "Version")
- private String version;
+ private String version = StringUtils.EMPTY;;
/**
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/handler/PluginHandler.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/handler/PluginHandler.java
index ac43dbd7..9ba0393d 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/handler/PluginHandler.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/handler/PluginHandler.java
@@ -21,11 +21,16 @@ public abstract class PluginHandler {
public static final Map pluginUseSubNameList = new HashMap<>();
static {
+ //21GA版本插件
+ pluginIgnoreList.add("com.netease.metadatahub");
+ pluginIgnoreList.add("com.netease.metadataext");
//22GA版本插件
pluginIgnoreList.add("proxy.filters.http.metadatahub");
}
static {
+ //21GA版本插件
+ pluginUseSubNameList.put("com.netease.resty", new RestyPluginHandler());
//22GA版本插件
pluginUseSubNameList.put("proxy.filters.http.rider", new RiderPluginHandler());
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/BasePageInfo.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/BasePageInfo.java
index 4ef5f4f8..a6d0aed7 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/BasePageInfo.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/BasePageInfo.java
@@ -37,7 +37,7 @@ public void setOffset(int offset) {
@JSONField(serialize = false)
public Pageable getPageable() {
- return new QPageRequest(Math.floorDiv(offset, limit), limit);
+ return QPageRequest.of(Math.floorDiv(offset, limit), limit);
}
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/RegistryCenterEnum.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/RegistryCenterEnum.java
index f3ddc645..8c0af8bb 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/RegistryCenterEnum.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/RegistryCenterEnum.java
@@ -12,24 +12,27 @@ public enum RegistryCenterEnum {
/**
* Eureka注册中心方式发布的服务,对应的host拼接为{appName}.eureka,且格式为小写
*/
- Eureka("Eureka", "%s.eureka"),
- Zookeeper("Zookeeper", "%s.dubbo"),
- Nacos("Nacos", "%s.nacos"),
+ Eureka("Eureka", "%s.eureka",2),
+ Zookeeper("Zookeeper", "%s.dubbo",3),
+ Nacos("Nacos", "%s.nacos",4),
/**
* Consul注册中心方式发布的服务,对应的host拼接为{appName}.service.consul.{consul别名}
* consul别名,用于区分不同consul应用
*/
- Consul("Consul", "%s.service.consul.%s"),
- Kubernetes("Kubernetes", "%s");
+ Consul("Consul", "%s.service.consul.%s",1),
+ Kubernetes("Kubernetes", "%s",0),
+ ;
private String type;
private String suffix;
+ private int order;
- RegistryCenterEnum(String type, String suffix) {
+ RegistryCenterEnum(String type, String suffix, int order) {
this.type = type;
this.suffix = suffix;
+ this.order = order;
}
public static RegistryCenterEnum get(String type) {
@@ -48,4 +51,8 @@ public String getType() {
public String getSuffix() {
return suffix;
}
+
+ public int getOrder() {
+ return order;
+ }
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/ServiceType.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/ServiceType.java
index 136e16d5..0920b700 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/ServiceType.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/ServiceType.java
@@ -17,17 +17,17 @@ public enum ServiceType {
/**
- * 获取服务类别(默认HTTP服务)
+ * 获取服务类别(无默认值)
*
* @param serviceType
* @return
*/
- public static String getByName(String serviceType) {
+ public static ServiceType getServiceTypeByName(String serviceType) {
for (ServiceType type : ServiceType.values()) {
if (type.name().equalsIgnoreCase(serviceType)) {
- return type.name();
+ return type;
}
}
- return http.name();
+ return null;
}
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/CommonErrorCode.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/CommonErrorCode.java
index b70da1bb..49e732d5 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/CommonErrorCode.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/CommonErrorCode.java
@@ -61,6 +61,7 @@ public class CommonErrorCode extends ErrorCode {
public static ErrorCode CannotDownloadSDK = new ErrorCode(ErrorCodeEnum.CannotDownloadServiceSDK);
public static ErrorCode NoSuchService = new ErrorCode(ErrorCodeEnum.NoSuchService);
public static ErrorCode ServicePublishedUpdateLimit = new ErrorCode(ErrorCodeEnum.ServicePublishedUpdateLimit);
+ public static ErrorCode ServiceTypeInvalid = new ErrorCode(ErrorCodeEnum.ServiceTypeInvalid);
/**
* 授权相关
*/
@@ -138,6 +139,10 @@ public class CommonErrorCode extends ErrorCode {
public static ErrorCode RepeatParamValue = new ErrorCode(ErrorCodeEnum.RepeatValue, "ParamValue");
public static ErrorCode UpdateNotAllowedRuleName = new ErrorCode(ErrorCodeEnum.UpdateNotAllowed, "RuleName");
public static ErrorCode CustomParamMappingInvalid = new ErrorCode(ErrorCodeEnum.CustomParamMappingInvalid);
+ public static ErrorCode GenericInfoInvalid = new ErrorCode(ErrorCodeEnum.GenericInfoInvalid);
+ public static ErrorCode UnSupportedDefaultValueType = new ErrorCode(ErrorCodeEnum.UnSupportedDefaultValueType);
+ public static ErrorCode DefaultValueConfigInvaild = new ErrorCode(ErrorCodeEnum.DefaultValueConfigInvaild);
+ public static ErrorCode DubboAttachmentConfigInvaild = new ErrorCode(ErrorCodeEnum.DubboAttachmentConfigInvaild);
public static ErrorCode ServiceNotFound = new ErrorCode(ErrorCodeEnum.ServiceNotFound);
public static ErrorCode CannotOfflineService = new ErrorCode(ErrorCodeEnum.CannotOfflineService);
public static ErrorCode CannotOfflineGrpcService = new ErrorCode(ErrorCodeEnum.CannotOfflineGrpcService);
@@ -197,6 +202,8 @@ public class CommonErrorCode extends ErrorCode {
public static ErrorCode MirrorByRouteRule = new ErrorCode(ErrorCodeEnum.MirrorByRouteRule);
public static ErrorCode RouteRuleNotPublished = new ErrorCode(ErrorCodeEnum.RouteRuleNotPublished);
public static ErrorCode RouteRuleServiceNotMatch = new ErrorCode(ErrorCodeEnum.RouteRuleServiceNotMatch);
+
+ public static ErrorCode RouteHasTrafficMarkRules = new ErrorCode(ErrorCodeEnum.RouteHasTrafficMarkRules);
public static ErrorCode RouteRuleMethodInvalid = new ErrorCode(ErrorCodeEnum.RouteRuleMethodInvalid);
public static ErrorCode CannotDeleteRouteRuleService = new ErrorCode(ErrorCodeEnum.CannotDeleteRouteRuleService);
public static ErrorCode SortKeyInvalid = new ErrorCode(ErrorCodeEnum.SortKeyInvalid);
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/ErrorCodeEnum.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/ErrorCodeEnum.java
index 460bef8b..3f75f23f 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/ErrorCodeEnum.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/meta/errorcode/ErrorCodeEnum.java
@@ -178,6 +178,8 @@ public enum ErrorCodeEnum {
//服务相关
CannotUpdateService("CannotUpdateService", "You can't update service until offline the service", "在下线服务之前,不能修改服务的基本信息", 400),
ServicePublishedUpdateLimit("ServicePublishedUpdateLimit", "You can't update service publish type", "不能更新发布服务的发布方式", 400),
+
+ ServiceTypeInvalid("ServiceTypeInvalid", "Service type is invalid", "服务类型不合法", 400),
CannotUpdateServiceName("CannotUpdateServiceName", "You can't update service name cause of sync", "从元数据同步服务,不允许修改服务名称", 400),
CannotDeleteOnlineService("CannotDeleteOnlineService", "You can't delete service until offline the service", "在下线服务之前,不能删除服务", 400),
CannotDeleteApiService("CannotDeleteApiService", "You can't delete service until delete all apis", "在删除api前,不能删除服务", 400),
@@ -268,6 +270,7 @@ public enum ErrorCodeEnum {
RouteRuleAlreadyPublishedToGw("RouteRuleAlreadyPublishedToGw", "The route rule has already published to gw, gw is: %s.", "路由规则已发布至网关: %s", 400),
RouteRuleNotPublished("RouteRuleNotPublished", "The route rule not published", "路由规则未发布", 400),
RouteRuleServiceNotMatch("RouteRuleServiceNotMatch", "The route rule not match the service", "服务和路由规则不匹配", 400),
+ RouteHasTrafficMarkRules("RouteHasTrafficMarkRules", "The route rule has traffic mark rules", "该路由存在流量染色规则,请先删除流量染色规则再下线路由", 400),
RouteRuleMethodInvalid("RouteRuleMethodInvalid", "The route rule method is invalid", "路由规则指定的method不合法", 400),
CannotDeleteRouteRuleService("CannotDeleteRouteRuleService", "The service has route rule", "服务存在路由规则,不允许删除", 400),
SortKeyInvalid("SortKeyInvalid", "The sort key is invalid", "搜索查询查询搜索项不正确", 400),
@@ -348,6 +351,10 @@ public enum ErrorCodeEnum {
FailedToOfflineServiceOrRoute("FailedToOfflineServiceOrRoute", "Failed to automatically offline service or route", "自动下线服务或路由失败", 400),
PublishTypeNotSupport("PublishTypeNotSupport", "The publish type of service can not support this operation", "该服务的发布方式并不支持本操作", 400),
CustomParamMappingInvalid("CustomParamMappingInvalid", "All params name must be blank when custom mapping switch is closed", "关闭自定义参数映射开关后, 所有自定义名称必须为空", 400),
+ GenericInfoInvalid("GenericInfoInvalid", "generic config invalid", "泛型配置格式错误", 400),
+ UnSupportedDefaultValueType("UnSupportedDefaultValueType", "default value type not support", "默认值类型不支持", 400),
+ DefaultValueConfigInvaild("DefaultValueConfigInvaild", "default value config invaild", "默认值配置错误", 400),
+ DubboAttachmentConfigInvaild("DubboAttachmentConfigInvaild", "dubbo attachment config invaild", "隐式参数配置错误", 400),
;
private String code;
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IDubboService.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IDubboService.java
index 2214df58..5b45a422 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IDubboService.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IDubboService.java
@@ -59,6 +59,12 @@ public interface IDubboService {
*/
DubboInfo getDubboInfo(long objectId, String objectType);
+
+ /**
+ * 判断方法是否有效
+ */
+ void processMethodWorks(DubboInfoDto dto);
+
/**
* 更新Dubbo转换参数
*
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRegistryCenterService.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRegistryCenterService.java
index abbda8c7..efa842b0 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRegistryCenterService.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRegistryCenterService.java
@@ -54,10 +54,9 @@ public interface IRegistryCenterService {
* 所以该接口暂不需携带项目隔离信息
*
* @param registryType
- * @param registryAddr
* @return
*/
- RegistryCenterDto findByTypeAndAddr(String registryType, String registryAddr);
+ RegistryCenterDto findByType(String registryType);
/**
* 通过类型获取项目下注册中心信息
@@ -93,4 +92,10 @@ public interface IRegistryCenterService {
*/
List getApplicationsFromConsul(String registryCenter);
+ /**
+ * 根据服务类型查询支持的注册中心类型
+ * @param serviceType
+ * @return
+ */
+ List describeRegistryTypesByServiceType(String serviceType);
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRouteRuleProxyService.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRouteRuleProxyService.java
index a5069e50..31b9097f 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRouteRuleProxyService.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IRouteRuleProxyService.java
@@ -80,20 +80,6 @@ public interface IRouteRuleProxyService {
List getRouteRuleProxyList(long gwId, long serviceId, String pattern, String sortKey,
String sortValue, long offset, long limit);
- /**
- * 分页查询认证授权的已发布路由
- *
- * @param gwId 网关id
- * @param serviceId 服务id
- * @param routeId 路由id
- * @param auth 是否认证
- * @param offset 分页查询offset
- * @param limit 分页查询limit
- * @return
- */
- List getAuthRouteProxy(long gwId, long serviceId, long routeId, boolean auth, long offset,
- long limit);
-
/**
* 查询已发布路由规则列表
*
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceInfoService.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceInfoService.java
index 9b3f00f6..8690d686 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceInfoService.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceInfoService.java
@@ -150,4 +150,11 @@ public interface IServiceInfoService {
* @return {@link List} 服务详情列表
*/
List getServiceInfoList(List serviceIdList);
+
+ /**
+ * 校验serviceType是否合法
+ * @param serviceType
+ * @return
+ */
+ ErrorCode checkServiceType(String serviceType);
}
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceProxyService.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceProxyService.java
index cbee190f..f2e3aab5 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceProxyService.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/IServiceProxyService.java
@@ -217,14 +217,6 @@ List getAuthServiceProxyByLimit(long gwId, long serviceId, lon
*/
String getBackendServiceSendToApiPlane(ServiceProxyDto serviceProxyDto);
- /**
- * 校验注册中心地址是否合法
- *
- * @param registerCenterAddr
- * @return
- */
- ErrorCode checkEurekaRegistryCenterAddr(String registerCenterAddr);
-
/**
* 获取subsetsName
*
diff --git a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/impl/DubboServiceImpl.java b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/impl/DubboServiceImpl.java
index fbd2a22f..b291ca2f 100644
--- a/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/impl/DubboServiceImpl.java
+++ b/gateway-portal/src/main/java/org/hango/cloud/dashboard/apiserver/service/impl/DubboServiceImpl.java
@@ -2,21 +2,22 @@
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.hango.cloud.dashboard.apiserver.dao.IDubboDao;
import org.hango.cloud.dashboard.apiserver.dto.DubboInfoDto;
+import org.hango.cloud.dashboard.apiserver.dto.DubboMetaDto;
import org.hango.cloud.dashboard.apiserver.meta.DubboInfo;
import org.hango.cloud.dashboard.apiserver.meta.RegistryCenterEnum;
import org.hango.cloud.dashboard.apiserver.meta.errorcode.CommonErrorCode;
import org.hango.cloud.dashboard.apiserver.meta.errorcode.ErrorCode;
-import org.hango.cloud.dashboard.apiserver.service.IDubboService;
-import org.hango.cloud.dashboard.apiserver.service.IRouteRuleInfoService;
-import org.hango.cloud.dashboard.apiserver.service.IRouteRuleProxyService;
-import org.hango.cloud.dashboard.apiserver.service.IServiceProxyService;
+import org.hango.cloud.dashboard.apiserver.service.*;
+import org.hango.cloud.dashboard.apiserver.util.ClassTypeUtil;
import org.hango.cloud.dashboard.apiserver.util.Const;
import org.hango.cloud.dashboard.apiserver.util.ZkClientUtils;
+import org.hango.cloud.dashboard.envoy.dao.IRouteRuleProxyDao;
import org.hango.cloud.dashboard.envoy.meta.RouteRuleInfo;
import org.hango.cloud.dashboard.envoy.meta.RouteRuleProxyInfo;
import org.hango.cloud.dashboard.envoy.meta.ServiceProxyInfo;
@@ -27,11 +28,12 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
+import static org.hango.cloud.dashboard.apiserver.util.Const.POSITION_COOKIE;
+import static org.hango.cloud.dashboard.apiserver.util.Const.POSITION_HEADER;
+
/**
* @author zhangbj
* @version 1.0
@@ -56,6 +58,12 @@ public class DubboServiceImpl implements IDubboService {
@Autowired
private IRouteRuleInfoService envoyRouteRuleInfoService;
+ @Autowired
+ private IRouteRuleProxyDao routeRuleProxyDao;
+
+ @Autowired
+ private IDubboMetaService dubboMetaService;
+
@Override
public long addDubboInfo(DubboInfoDto dto) {
if (dto == null) {
@@ -106,7 +114,14 @@ public void delete(long objectId, String objectType) {
@Override
public DubboInfoDto getDubboDto(long objectId, String objectType) {
- return DubboInfoDto.toDto(getDubboInfo(objectId, objectType));
+ DubboInfoDto dubboInfoDto = DubboInfoDto.toDto(getDubboInfo(objectId, objectType));
+ //默认值json格式转换为json string以适配前端api
+ if (dubboInfoDto != null && dubboInfoDto.getParams() != null){
+ for (DubboInfoDto.DubboParam param : dubboInfoDto.getParams()) {
+ param.setDefaultValue(JSONObject.toJSONString(param.getDefaultValue()));
+ }
+ }
+ return dubboInfoDto;
}
@Override
@@ -122,6 +137,40 @@ public DubboInfo getDubboInfo(long objectId, String objectType) {
return infoList.get(0);
}
+
+ @Override
+ public void processMethodWorks(DubboInfoDto dto) {
+ if (dto == null){
+ return;
+ }
+ //获取已发布路由信息
+ Map params = new HashMap<>(Const.DEFAULT_MAP_SIZE);
+ params.put("Id", dto.getObjectId());
+ List routeRuleProxyInfos = routeRuleProxyDao.getRecordsByField(params);
+ if (CollectionUtils.isEmpty(routeRuleProxyInfos)){
+ logger.error("未找到已发布路由信息,查询条件为 routeRuleProxyId:{}", dto.getObjectId());
+ return;
+ }
+ RouteRuleProxyInfo proxyInfo = routeRuleProxyInfos.get(0);
+ //获取dubbo meta信息
+ List dubboMetaDtos = dubboMetaService.findByCondition(proxyInfo.getGwId(), dto.getInterfaceName(), dto.getGroup(), dto.getVersion());
+ //判断方法是否失效
+ for (DubboMetaDto dubboMetaDto : dubboMetaDtos) {
+ if (dto.getMethod().equals(dubboMetaDto.getMethod()) && equalParams(dto.getParams(), dubboMetaDto.getParams())){
+ dto.setMethodWorks(true);
+ return;
+ }
+ }
+ dto.setMethodWorks(false);
+ }
+
+ private boolean equalParams(List dubboParams, List params){
+ List dubboParamInfo = CollectionUtils.isEmpty(dubboParams) ? new ArrayList<>() : dubboParams.stream().map(DubboInfoDto.DubboParam::getValue).collect(Collectors.toList());
+ List paramInfo = CollectionUtils.isEmpty(params) ? new ArrayList<>() : params;
+ return dubboParamInfo.equals(paramInfo);
+ }
+
+
@Override
public long updateDubboInfo(DubboInfoDto dto) {
DubboInfo dtoFromDb = getDubboInfo(dto.getObjectId(), dto.getObjectType());
@@ -169,17 +218,12 @@ private ErrorCode checkAndCompleteEnvoyDubbo(DubboInfoDto dto) {
logger.info("参数校验失败,该服务的发布方式并不支持本操作, 服务发布方式为 {}", serviceProxy.getRegistryCenterType());
return CommonErrorCode.PublishTypeNotSupport;
}
- List paramWithNoneKeyList = dto.getParams().stream().filter(f -> StringUtils.isBlank(f.getKey())).collect(Collectors.toList());
- //开启自定义参数映射开关后, 不允许自定义名称为空的存在
- if (dto.getCustomParamMapping() && !CollectionUtils.isEmpty(paramWithNoneKeyList)) {
- logger.info("开启自定义参数映射开关后, 不允许自定义名称为空的存在 : {}", JSON.toJSONString(paramWithNoneKeyList));
- return CommonErrorCode.ParameterNull;
- }
- //关闭自定义参数映射开关后, 所有自定义名称必须为空
- //当dto.getParams()元素数与paramWithNoneKeyList 元素数相等,代表所有自定义名称为空
- if (!dto.getCustomParamMapping() && dto.getParams().size() != paramWithNoneKeyList.size()) {
- logger.info("关闭自定义参数映射开关后, 所有自定义名称必须为空 : {}", JSON.toJSONString(dto));
- return CommonErrorCode.CustomParamMappingInvalid;
+ //自定义参数校验
+ if (dto.getCustomParamMapping()){
+ ErrorCode errorCode = checkCustomParamMapping(dto);
+ if (CommonErrorCode.Success != errorCode){
+ return errorCode;
+ }
}
String backendService = serviceProxy.getBackendService();
String[] meta = ZkClientUtils.splitIgv(backendService);
@@ -189,6 +233,136 @@ private ErrorCode checkAndCompleteEnvoyDubbo(DubboInfoDto dto) {
return CommonErrorCode.Success;
}
+ //自定义参数映射校验
+ private ErrorCode checkCustomParamMapping(DubboInfoDto dto){
+ List params = dto.getParams();
+ for (DubboInfoDto.DubboParam param : params) {
+ //参数名不能为空
+ if (StringUtils.isBlank(param.getKey())){
+ logger.error("自定义参数映射不允许参数名为空 : {}", JSON.toJSONString(dto));
+ return CommonErrorCode.ParameterNull;
+ }
+ //参数类型不能为空
+ if (StringUtils.isBlank(param.getValue())){
+ logger.error("自定义参数映射不允许参数类型为空 : {}", JSON.toJSONString(dto));
+ return CommonErrorCode.ParameterNull;
+ }
+ //默认值类型校验
+ if (param.getDefaultValue() != null){
+ ErrorCode errorCode = checkDefaultValue(param.getValue(), param.getDefaultValue());
+ if (!CommonErrorCode.Success.equals(errorCode)){
+ return errorCode;
+ }
+ }
+ //泛型校验
+ Boolean checkResult = checkGenericInfo(param.getGenericInfo());
+ if (!checkResult){
+ logger.error("无效的泛型配置 : {}", JSON.toJSONString(dto));
+ return CommonErrorCode.GenericInfoInvalid;
+ }
+ }
+ //隐式参数校验
+ if (!checkDubboAttachment(dto.getDubboAttachment())){
+ return CommonErrorCode.DubboAttachmentConfigInvaild;
+ }
+ return CommonErrorCode.Success;
+ }
+
+ private Boolean checkDubboAttachment(List dubboAttachmentDtos){
+ if (CollectionUtils.isEmpty(dubboAttachmentDtos)){
+ return Boolean.TRUE;
+ }
+ for (DubboInfoDto.DubboAttachmentDto dubboAttachmentDto : dubboAttachmentDtos) {
+ String paramPosition = dubboAttachmentDto.getParamPosition();
+ if (StringUtils.isBlank(paramPosition)){
+ logger.error("隐式参数来源不能为空 : {}", JSON.toJSONString(dubboAttachmentDto));
+ return Boolean.FALSE;
+ }
+ if (!POSITION_COOKIE.equalsIgnoreCase(paramPosition) && !POSITION_HEADER.equalsIgnoreCase(paramPosition)){
+ logger.error("隐式参数来源错误 : {}", paramPosition);
+ return Boolean.FALSE;
+ }
+ if (StringUtils.isBlank(dubboAttachmentDto.getClientParamName())){
+ logger.error("参数名不能为空 : {}", JSON.toJSONString(dubboAttachmentDto));
+ return Boolean.FALSE;
+ }
+
+ if (StringUtils.isBlank(dubboAttachmentDto.getServerParamName())){
+ logger.error("隐式参数名不能为空 : {}", JSON.toJSONString(dubboAttachmentDto));
+ return Boolean.FALSE;
+ }
+ }
+ long clientCount = dubboAttachmentDtos.stream().map(o -> o.getParamPosition() + o.getClientParamName()).distinct().count();
+ if (clientCount != dubboAttachmentDtos.size()){
+ logger.error("参数名重复 : {}", JSON.toJSONString(dubboAttachmentDtos));
+
+ return Boolean.FALSE;
+ }
+ long serverCount = dubboAttachmentDtos.stream().map(DubboInfoDto.DubboAttachmentDto::getServerParamName).distinct().count();
+ if (serverCount != dubboAttachmentDtos.size()){
+ logger.error("隐式参数名重复 : {}", JSON.toJSONString(dubboAttachmentDtos));
+ return Boolean.FALSE;
+ }
+ return Boolean.TRUE;
+ }
+
+ private ErrorCode checkDefaultValue(String javaType, Object defaultValue){
+ if (!ClassTypeUtil.isMapClass(javaType) && !ClassTypeUtil.isCollectionClass(javaType) && !ClassTypeUtil.isPrimitive(javaType) && !ClassTypeUtil.isWrapperClass(javaType)){
+ logger.error("默认值类型不支持 : {}", javaType);
+ return CommonErrorCode.UnSupportedDefaultValueType;
+ }
+ //boolean类型校验
+ if (ClassTypeUtil.isBooleanClass(javaType) && !(defaultValue instanceof Boolean)){
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ //数值类型校验
+ if (ClassTypeUtil.isNumberClass(javaType) && !(defaultValue instanceof Number)){
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ //字符串类型校验
+ if (ClassTypeUtil.isStringClass(javaType) && !(defaultValue instanceof String)){
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ //集合类型校验
+ if (ClassTypeUtil.isCollectionClass(javaType) && !(defaultValue instanceof Collection)){
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ //字典类型校验
+ if (ClassTypeUtil.isMapClass(javaType) && !(defaultValue instanceof Map)){
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ //兜底校验
+ String str = JSONObject.toJSONString(defaultValue);
+ try {
+ JSONObject.parseObject(str, ClassTypeUtil.getClassForName(javaType));
+ } catch (Exception e) {
+ logger.error("默认值配置错误,type:{}, defaultValue:{}", javaType, str);
+ return CommonErrorCode.DefaultValueConfigInvaild;
+ }
+ return CommonErrorCode.Success;
+ }
+
+ public Boolean checkGenericInfo(String genericInfo){
+ if (StringUtils.isBlank(genericInfo)){
+ return Boolean.TRUE;
+ }
+ String[] genericConfigs = genericInfo.split(",");
+ for (String genericConfig : genericConfigs) {
+ if (StringUtils.isBlank(genericConfig)) {
+ return Boolean.FALSE;
+ }
+ if (!genericConfig.startsWith(".")){
+ return Boolean.FALSE;
+ }
+ String[] split = genericConfig.split(":");
+ if (split.length != 2){
+ return Boolean.FALSE;
+ }
+ }
+ return Boolean.TRUE;
+ }
+
+
private ErrorCode checkAndCompleteG0Dubbo(DubboInfoDto dto) {
//暂未实现
return CommonErrorCode.Success;
@@ -236,7 +410,53 @@ public EnvoyRouteRuleHeaderOperationDto getDubboHeaderOperation(DubboInfoDto dto
add.put(Const.HEADER_DUBBO_GROUP, dto.getGroup());
add.put(Const.HEADER_DUBBO_VERSION, dto.getVersion());
add.put(Const.HEADER_DUBBO_PARAMS, dto.getParamToStr());
+ add.put(Const.HEADER_DUBBO_PARAM_SOURCE, dto.getParamSource());
add.put(Const.HEADER_DUBBO_CUSTOM_PARAMS_MAPPING_SWITCH, BooleanUtils.toStringTrueFalse(dto.getCustomParamMapping()));
+ List params = dto.getParams();
+ if (!CollectionUtils.isEmpty(params)){
+ List genericInfoList = params.stream().map(DubboInfoDto.DubboParam::getGenericInfo).collect(Collectors.toList());
+ if (!CollectionUtils.isEmpty(genericInfoList)){
+ add.put(Const.HEADER_DUBBO_GENERIC, StringUtils.join(genericInfoList, ";"));
+ }
+ if (dto.getCustomParamMapping()){
+ List