Merge branch 'master' into eureka

# Conflicts:
#	sop-gateway/pom.xml
#	sop-website/sop-website-server/pom.xml
eureka
tanghc 4 years ago
commit 72ced304ad
  1. 0
      Dockerfile
  2. 6
      README.md
  3. 9
      changelog.md
  4. 6
      doc/docs/files/90001_网关性能测试.md
  5. 2
      doc/pom.xml
  6. 2
      pom.xml
  7. 4
      sop-admin/pom.xml
  8. 4
      sop-admin/sop-admin-server/pom.xml
  9. 2
      sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/service/impl/RegistryServiceNacosImpl.java
  10. 6
      sop-auth/pom.xml
  11. 2
      sop-common/pom.xml
  12. 6
      sop-common/sop-bridge-eureka/pom.xml
  13. 6
      sop-common/sop-bridge-nacos/pom.xml
  14. 2
      sop-common/sop-bridge-nacos/src/main/java/com/gitee/sop/bridge/route/NacosRegistryListener.java
  15. 4
      sop-common/sop-gateway-common/pom.xml
  16. 4
      sop-common/sop-service-common/pom.xml
  17. 2
      sop-example/pom.xml
  18. 4
      sop-example/sop-springmvc/pom.xml
  19. 4
      sop-example/sop-story/pom.xml
  20. 8
      sop-gateway/pom.xml
  21. 13
      sop-gateway/src/main/java/com/gitee/sop/gateway/interceptor/MyRouteInterceptor.java
  22. 11
      sop-gateway/src/main/resources/META-INF/gateway.properties
  23. 5
      sop-gateway/src/main/resources/application-dev.properties
  24. 4
      sop-sdk/pom.xml
  25. 4
      sop-sdk/sdk-java/pom.xml
  26. 2
      sop-test/pom.xml
  27. 25
      sop-test/src/main/java/com/gitee/sop/test/Client.java
  28. BIN
      sop-test/src/main/resources/large_img.png
  29. 41
      sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
  30. 4
      sop-website/pom.xml
  31. 4
      sop-website/sop-website-server/pom.xml

@ -2,7 +2,6 @@
一个开放平台解决方案项目,基于Spring Cloud实现,目标让用户快速搭建自己的开放平台。
SOP提供了两种接口调用方式,分别是:[支付宝开放平台](https://docs.open.alipay.com/api)的调用方式和[淘宝开放平台](http://open.taobao.com/api.htm?docId=285&docType=2)的调用方式。
通过简单的配置后,你的项目就具备了和支付宝开放平台的一样的接口提供能力。
SOP封装了开放平台大部分功能包括:签名验证、统一异常处理、统一返回内容 、业务参数验证(JSR-303)、秘钥管理等,未来还会实现更多功能。
@ -78,6 +77,7 @@ System.out.println(responseData);
> 如上图所示,整个系统运行后,开发者只需关注微服务中的业务代码,接口变更后重新部署微服务应用即可
## 已完成列表
- 签名验证
@ -86,7 +86,6 @@ System.out.println(responseData);
- session管理
- 秘钥管理
- 微服务端自动验证(JSR-303)
- 支持Spring Cloud Gateway
- Admin管理平台,统一管理微服务配置,管理路由管理,微服务上下线
- 门户网站,提供用户注册账号
- 接入方管理+秘钥管理
@ -97,10 +96,9 @@ System.out.println(responseData);
- 文档整合
- 应用授权
- 监控日志
- 支持nacos
- 注册中心支持nacos/eureka
- 网关动态修改参数
- 预发布/灰度环境切换
- 支持eureka注册中心
## 界面预览

@ -1,8 +1,17 @@
# changelog
## 4.2.3
- 修复nacos的group不生效问题
## 4.2.2
- 优化版本号
## 4.2.1
- 可指定nacos的group,(`spring.cloud.nacos.discovery.group=xx`)
- 修复spring循环依赖问题
## 4.2.0

@ -133,8 +133,8 @@ Transfer/sec: 226.50KB
`restart.sh`
```bash
echo "Stopping sop-gateway-4.2.2-SNAPSHOT.jar"
pid=`ps -ef | grep sop-gateway-4.2.2-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
echo "Stopping sop-gateway-4.2.3-SNAPSHOT.jar"
pid=`ps -ef | grep sop-gateway-4.2.3-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
echo "kill -9 的id:" $pid
@ -142,7 +142,7 @@ then
fi
nohup java -jar -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:gc.log \
-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8\
-XX:+UseConcMarkSweepGC sop-gateway-4.2.2-SNAPSHOT.jar\
-XX:+UseConcMarkSweepGC sop-gateway-4.2.3-SNAPSHOT.jar\
--spring.profiles.active=dev --server.port=8081 &
tail -f nohup.out

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId>
<artifactId>doc</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<properties>
<!-- Generic properties -->

@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<description>一个开放平台解决方案项目,基于Spring Cloud实现,目标是能够让用户快速得搭建起自己的开放平台</description>

@ -6,13 +6,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-admin</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>

@ -5,13 +5,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-admin-server</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>

@ -56,7 +56,7 @@ public class RegistryServiceNacosImpl implements RegistryService {
@Override
public List<ServiceInfo> listAllService(int pageNo, int pageSize) throws Exception {
ListView<String> servicesOfServer = namingService.getServicesOfServer(pageNo, pageSize);
ListView<String> servicesOfServer = namingService.getServicesOfServer(pageNo, pageSize, nacosGroup);
List<String> serverList = servicesOfServer.getData();
List<ServiceInfo> serviceInfoList = new ArrayList<>();
for (String serviceName : serverList) {

@ -5,7 +5,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
@ -25,7 +25,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<!-- sop相关配置 end-->
@ -37,7 +37,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sdk-java</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<!-- http请求 -->
<dependency>

@ -6,7 +6,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>

@ -5,12 +5,12 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<artifactId>sop-bridge-eureka</artifactId>
@ -18,7 +18,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<dependency>

@ -5,12 +5,12 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<artifactId>sop-bridge-nacos</artifactId>
@ -18,7 +18,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<dependency>

@ -85,7 +85,7 @@ public class NacosRegistryListener extends BaseRegistryListener {
NamingService namingService = nacosDiscoveryProperties.namingServiceInstance();
ListView<String> servicesOfServer = null;
try {
servicesOfServer = namingService.getServicesOfServer(1, Integer.MAX_VALUE);
servicesOfServer = namingService.getServicesOfServer(1, Integer.MAX_VALUE, nacosGroup);
} catch (NacosException e) {
log.error("namingService.getServicesOfServer()错误", e);
}

@ -5,13 +5,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-gateway-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>

@ -6,13 +6,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-service-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>

@ -5,7 +5,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>

@ -5,7 +5,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
@ -26,7 +26,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<!-- nacos -->
<dependency>

@ -4,7 +4,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
@ -19,7 +19,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<dependency>

@ -4,7 +4,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
@ -22,9 +22,9 @@
-->
<dependency>
<groupId>com.gitee.sop</groupId>
<!-- <artifactId>sop-bridge-nacos</artifactId>-->
<artifactId>sop-bridge-eureka</artifactId>
<version>4.2.2-SNAPSHOT</version>
<!-- <artifactId>sop-bridge-eureka</artifactId>-->
<artifactId>sop-bridge-eureka</artifactId>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<dependency>

@ -4,7 +4,6 @@ import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptor;
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptorContext;
import com.gitee.sop.gatewaycommon.param.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.stereotype.Component;
/**
@ -19,16 +18,16 @@ public class MyRouteInterceptor implements RouteInterceptor {
@Override
public void preRoute(RouteInterceptorContext context) {
ApiParam apiParam = context.getApiParam();
log.info("请求接口:{}, ip:{}", apiParam.fetchNameVersion(), apiParam.fetchIp());
log.info("请求接口:{}, request_id:{}, app_id:{}, ip:{}",
apiParam.fetchNameVersion(),
apiParam.fetchRequestId(),
apiParam.fetchAppKey(),
apiParam.fetchIp()
);
}
@Override
public void afterRoute(RouteInterceptorContext context) {
ServiceInstance serviceInstance = context.getServiceInstance();
log.info("请求成功,serviceId:{}({}:{}),微服务返回结果:{}",
serviceInstance.getServiceId(),
serviceInstance.getHost(),serviceInstance.getPort(),
context.getServiceResult());
}
@Override

@ -3,6 +3,10 @@ spring.application.name=sop-gateway
# 不用改,如果要改,请全局替换修改
sop.secret=MZZOUSTua6LzApIWXCwEgbBmxSzpzC
# 文件上传配置
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB
# 网关入口
sop.gateway-index-path=/
@ -33,10 +37,3 @@ mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillInsert=gmt_create
mybatis.fill.com.gitee.fastmybatis.core.support.DateFillUpdate=gmt_modified
# POST请求最大缓存,默认是262144(256KB),即:256 * 1024
# 如果需要传输大文本可以把值设置高一点
spring.codec.max-in-memory-size=262144
# 文件上传配置
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB

@ -9,8 +9,7 @@ mysql.password=root
# nacos注册中心地址
register.url=http://localhost:1111/eureka/
# POST请求最大缓存,默认是262144(256KB),即:256 * 1024
# 如果需要传输大文本可以把值设置高一点
spring.codec.max-in-memory-size=262144
# 上传文件最大容量,默认10MB
spring.servlet.multipart.max-file-size=10MB
logging.level.com.gitee=debug

@ -6,13 +6,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-sdk</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>

@ -4,13 +4,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sdk-java</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<properties>
<!-- Generic properties -->

@ -5,7 +5,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>

@ -174,6 +174,8 @@ public class Client {
public static class RequestBuilder {
private static final String DEFAULT_VERSION = "1.0";
private Map<String, String> systemParam;
private String url;
private String method;
private String version = DEFAULT_VERSION;
@ -277,6 +279,20 @@ public class Client {
return this;
}
/**
* 添加系统参数
* @param name 参数名
* @param value 参数值
* @return 返回RequestBuilder
*/
public RequestBuilder addSystemParam(String name, String value) {
if (systemParam == null) {
systemParam = new HashMap<>(8);
}
systemParam.put(name, value);
return this;
}
/**
* 设置token
*
@ -376,9 +392,14 @@ public class Client {
params.put("charset", "utf-8");
params.put("sign_type", "RSA2");
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
if (systemParam != null) {
params.putAll(systemParam);
}
// 业务参数
params.put("biz_content", JSON.toJSONString(bizContent == null ? Collections.emptyMap() : bizContent));
if (bizContent != null) {
// 业务参数
params.put("biz_content", JSON.toJSONString(bizContent));
}
if (!ignoreSign) {
String content = AlipaySignature.getSignContent(params);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

@ -224,6 +224,29 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
/**
* 演示大文件上传先配置网关参数spring.servlet.multipart.max-file-size=1MB
*/
public void testBigFile() {
Client client = new Client(url, appId, privateKey);
String root = System.getProperty("user.dir");
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("file.upload3")
.version("1.0")
.bizContent(new BizContent().add("remark", "test file upload"))
// 添加文件
.addFile("image", new File(root + "/src/main/resources/large_img.png"))
.callback((requestInfo, responseData) -> {
System.out.println(responseData);
JSONObject jsonObject = JSON.parseObject(responseData);
JSONObject data = jsonObject.getJSONObject(requestInfo.getDataNode());
Assert.assertEquals(data.getString("sub_code"), "isv.invalid-file-size");
})
;
client.execute(requestBuilder);
}
/**
* 传递header
*/
@ -330,6 +353,24 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
/**
* 单个参数绑定
*/
public void testBindParam() {
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("story.param.bind")
.version("1.0")
.addSystemParam("id", "1")
.addSystemParam("name", "葫芦娃")
.httpMethod(HttpTool.HTTPMethod.GET)
.callback(((requestInfo, responseData) -> {
System.out.println(responseData);
Assert.assertTrue(responseData.contains("参数绑定:id:1, name:葫芦娃"));
}));
client.execute(requestBuilder);
}
static class BizContent extends HashMap<String, Object> {
public BizContent add(String key, Object value) {
this.put(key, value);

@ -6,13 +6,13 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-parent</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sop-website</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>

@ -5,7 +5,7 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-website</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
</parent>
@ -25,7 +25,7 @@
<groupId>com.gitee.sop</groupId>
<!-- <artifactId>sop-bridge-nacos</artifactId>-->
<artifactId>sop-bridge-eureka</artifactId>
<version>4.2.2-SNAPSHOT</version>
<version>4.2.3-SNAPSHOT</version>
</dependency>
<dependency>

Loading…
Cancel
Save