mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
@@ -6,12 +6,12 @@
|
||||
|
||||
```xml
|
||||
<!-- springboot 版本-->
|
||||
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
|
||||
<spring-boot.version>2.6.15</spring-boot.version>
|
||||
<!-- spring cloud 版本 -->
|
||||
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
|
||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||
<!-- spring cloud alibaba 版本 -->
|
||||
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
||||
<spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version>
|
||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||
```
|
||||
|
||||
- pom.xml添加`<dependencyManagement>`控制版本
|
||||
|
50
pom.xml
50
pom.xml
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.2.RELEASE</version>
|
||||
<version>2.6.15</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -35,12 +35,12 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<!-- springboot 版本-->
|
||||
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
|
||||
<spring-boot.version>2.6.15</spring-boot.version>
|
||||
<!-- spring cloud 版本 -->
|
||||
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
|
||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||
<!-- spring cloud alibaba 版本 -->
|
||||
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
||||
<spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version>
|
||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||
|
||||
|
||||
<!-- Logging -->
|
||||
@@ -58,11 +58,12 @@
|
||||
<commons-logging.version>1.2</commons-logging.version>
|
||||
<validation-api.version>2.0.1.Final</validation-api.version>
|
||||
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
|
||||
<fastmybatis.version>1.9.1</fastmybatis.version>
|
||||
<fastmybatis.version>2.4.8</fastmybatis.version>
|
||||
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
|
||||
<guava.version>29.0-jre</guava.version>
|
||||
<knife4j.version>3.0.2</knife4j.version>
|
||||
<swagger.version>1.5.21</swagger.version>
|
||||
<springfox-spring-web.version>2.9.2</springfox-spring-web.version>
|
||||
<springfox-swagger2.version>2.9.2</springfox-swagger2.version>
|
||||
<springfox.version>3.0.0</springfox.version>
|
||||
<easyopen.version>1.16.9</easyopen.version>
|
||||
<asm.version>6.2</asm.version>
|
||||
<pagehelper.version>5.2.0</pagehelper.version>
|
||||
@@ -110,21 +111,36 @@
|
||||
<artifactId>fastmybatis-spring-boot-starter</artifactId>
|
||||
<version>${fastmybatis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-spring-web</artifactId>
|
||||
<version>${springfox-spring-web.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger.version}</version>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>${springfox-swagger2.version}</version>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-spring-web</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>${springfox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>${knife4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -17,12 +14,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "admin_user_info")
|
||||
@Table(name = "admin_user_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class AdminUserInfo implements Serializable {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_common")
|
||||
@Table(name = "config_common",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigCommon {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_gray")
|
||||
@Table(name = "config_gray",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigGray {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -15,12 +12,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_gray_instance")
|
||||
@Table(name = "config_gray_instance",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigGrayInstance {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_ip_blacklist")
|
||||
@Table(name = "config_ip_blacklist",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigIpBlacklist {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_limit")
|
||||
@Table(name = "config_limit",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigLimit {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -4,11 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,12 +14,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_route_base")
|
||||
@Table(name = "config_route_base",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigRouteBase {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_service_route")
|
||||
@Table(name = "config_service_route",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigServiceRoute {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
/** 数据库字段:id */
|
||||
private String id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,13 +13,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isp_resource")
|
||||
@Table(name = "isp_resource",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IspResource {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 资源名称, 数据库字段:name */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_info")
|
||||
@Table(name = "isv_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvInfo {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_keys")
|
||||
@Table(name = "isv_keys",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvKeys {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,13 +13,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "monitor_info")
|
||||
@Table(name = "monitor_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class MonitorInfo {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 路由id, 数据库字段:route_id */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -15,13 +12,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "monitor_info_error")
|
||||
@Table(name = "monitor_info_error",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class MonitorInfoError {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 错误id,md5Hex(instanceId + routeId + errorMsg), 数据库字段:error_id */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.adminserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@@ -4,11 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,12 +14,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "perm_isv_role")
|
||||
@Table(name = "perm_isv_role",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class PermIsvRole {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -4,11 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,12 +14,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "perm_role")
|
||||
@Table(name = "perm_role",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class PermRole {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -4,11 +4,8 @@ import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,12 +14,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "perm_role_permission")
|
||||
@Table(name = "perm_role_permission",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class PermRolePermission {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -135,7 +135,8 @@ public class RegistryServiceNacosImpl implements RegistryService {
|
||||
params.put("ip", serviceInstance.getIp());
|
||||
params.put("port", String.valueOf(serviceInstance.getPort()));
|
||||
String instanceJson = httpTool.request("http://" + nacosAddr + "/nacos/v1/ns/instance", params, null, HttpTool.HTTPMethod.GET);
|
||||
Instance instance = JSON.parseObject(instanceJson, Instance.class);
|
||||
JSONObject jsonObject = JSON.parseObject(instanceJson);
|
||||
Instance instance = JSON.parseObject(jsonObject.getString("data"), Instance.class);
|
||||
instance.setServiceName(serviceInstance.getServiceId());
|
||||
return instance;
|
||||
}
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.sopauth.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,12 +12,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_info")
|
||||
@Table(name = "isv_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvInfo {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -4,11 +4,8 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.gitee.sop.sopauth.auth.OpenUser;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -18,12 +15,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "user_info")
|
||||
@Table(name = "user_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class UserInfo implements OpenUser {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -20,7 +20,6 @@
|
||||
|
||||
<modules>
|
||||
<module>sop-bridge-nacos</module>
|
||||
<module>sop-bridge-eureka</module>
|
||||
<module>sop-gateway-common</module>
|
||||
<module>sop-service-common</module>
|
||||
</modules>
|
||||
|
@@ -26,6 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
|
||||
<version>2.2.10.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@@ -2,16 +2,20 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-common</artifactId>
|
||||
<version>4.4.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-bridge-nacos</artifactId>
|
||||
<version>4.4.2-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.gitee.sop</groupId>
|
||||
<artifactId>sop-gateway-common</artifactId>
|
||||
<version>4.4.2-SNAPSHOT</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -12,6 +12,7 @@ import com.gitee.sop.gatewaycommon.route.RegistryEvent;
|
||||
import com.gitee.sop.gatewaycommon.route.ServiceHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -41,8 +42,8 @@ public class NacosRegistryListener extends BaseRegistryListener {
|
||||
@Autowired
|
||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
|
||||
@Autowired(required = false)
|
||||
private List<RegistryEvent> registryEventList;
|
||||
@Autowired
|
||||
private ObjectProvider<RegistryEvent> registryEventList;
|
||||
|
||||
@Override
|
||||
public synchronized void onEvent(ApplicationEvent applicationEvent) {
|
||||
|
@@ -43,11 +43,6 @@
|
||||
<artifactId>commons-collections</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix-ribbon</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
@@ -104,7 +99,23 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
|
||||
<version>2.2.10.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@@ -2,9 +2,6 @@ package com.gitee.sop.gatewaycommon.bean;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
|
@@ -4,17 +4,9 @@ import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiContext;
|
||||
import com.gitee.sop.gatewaycommon.bean.BeanInitializer;
|
||||
import com.gitee.sop.gatewaycommon.bean.SpringContext;
|
||||
import com.gitee.sop.gatewaycommon.gateway.loadbalancer.NacosServerIntrospector;
|
||||
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptor;
|
||||
import com.gitee.sop.gatewaycommon.limit.LimitManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvGrayManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentContext;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
|
||||
import com.gitee.sop.gatewaycommon.manager.IPBlacklistManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.IsvRoutePermissionManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.LimitConfigManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.RouteConfigManager;
|
||||
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||
import com.gitee.sop.gatewaycommon.manager.*;
|
||||
import com.gitee.sop.gatewaycommon.message.ErrorFactory;
|
||||
import com.gitee.sop.gatewaycommon.monitor.MonitorManager;
|
||||
import com.gitee.sop.gatewaycommon.param.ParameterFormatter;
|
||||
@@ -35,7 +27,6 @@ import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
|
||||
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
@@ -67,9 +58,6 @@ public class AbstractConfiguration implements ApplicationContextAware, Applicati
|
||||
@Autowired
|
||||
protected Environment environment;
|
||||
|
||||
@Autowired
|
||||
private RegistryListener registryListener;
|
||||
|
||||
protected ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
@@ -95,7 +83,7 @@ public class AbstractConfiguration implements ApplicationContextAware, Applicati
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
registryListener.onEvent(heartbeatEvent);
|
||||
applicationContext.getBean(RegistryListener.class).onEvent(heartbeatEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -190,18 +178,6 @@ public class AbstractConfiguration implements ApplicationContextAware, Applicati
|
||||
return corsConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* 负责获取nacos实例的metadata
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty("spring.cloud.nacos.discovery.server-addr")
|
||||
ServerIntrospector nacosServerIntrospector() {
|
||||
return new NacosServerIntrospector();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
this.isStartupCompleted = true;
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.gitee.sop.gatewaycommon.config;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.gateway.configuration.AlipayGatewayConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@@ -12,6 +10,5 @@ import org.springframework.context.annotation.Import;
|
||||
*/
|
||||
@Configuration
|
||||
@Import(AlipayGatewayConfiguration.class)
|
||||
@AutoConfigureBefore(RibbonAutoConfiguration.class)
|
||||
public class SopGatewayAutoConfiguration extends BaseGatewayAutoConfiguration {
|
||||
}
|
||||
|
@@ -1,25 +1,19 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.configuration;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import com.gitee.sop.gatewaycommon.config.AbstractConfiguration;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.GatewayModifyResponseGatewayFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.IndexFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.LimitFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.ParameterFormatterFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.filter.SopLoadBalancerClientFilter;
|
||||
import com.gitee.sop.gatewaycommon.gateway.handler.GatewayExceptionHandler;
|
||||
import com.gitee.sop.gatewaycommon.gateway.loadbalancer.SopLoadBalancerClient;
|
||||
import com.gitee.sop.gatewaycommon.gateway.route.GatewayForwardChooser;
|
||||
import com.gitee.sop.gatewaycommon.gateway.route.GatewayRouteCache;
|
||||
import com.gitee.sop.gatewaycommon.gateway.route.GatewayRouteRepository;
|
||||
import com.gitee.sop.gatewaycommon.config.AbstractConfiguration;
|
||||
import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.gateway.config.LoadBalancerProperties;
|
||||
import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -100,25 +94,4 @@ public class BaseGatewayConfiguration extends AbstractConfiguration {
|
||||
return new GatewayForwardChooser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展默认的负载均衡选择,默认使用的是RibbonLoadBalancerClient
|
||||
* @param clientFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
LoadBalancerClient loadBalancerClient(SpringClientFactory clientFactory) {
|
||||
return new SopLoadBalancerClient(clientFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展默认的负载均衡过滤器,默认是LoadBalancerClientFilter
|
||||
* @param sopLoadBalancerClient SopLoadBalancerClient
|
||||
* @param loadBalancerProperties loadBalancerProperties
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
LoadBalancerClientFilter loadBalancerClientFilter(LoadBalancerClient sopLoadBalancerClient, LoadBalancerProperties loadBalancerProperties) {
|
||||
return new SopLoadBalancerClientFilter(sopLoadBalancerClient, loadBalancerProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.controller;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.SpringContext;
|
||||
import com.gitee.sop.gatewaycommon.gateway.loadbalancer.SopLoadBalancerClient;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.gateway.webflux.ProxyExchange;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -12,6 +13,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 处理restful请求
|
||||
* @author tanghc
|
||||
@@ -21,6 +25,8 @@ public class RestfulController {
|
||||
|
||||
@Value("${sop.restful.path:/rest}")
|
||||
private String prefix;
|
||||
@Autowired
|
||||
private DiscoveryClient discoveryClient;
|
||||
|
||||
@RequestMapping("${sop.restful.path:/rest}/**")
|
||||
public Mono<ResponseEntity<byte[]>> proxy(ProxyExchange<byte[]> proxy, ServerWebExchange exchange) {
|
||||
@@ -32,7 +38,14 @@ public class RestfulController {
|
||||
targetPath = targetPath + "?" + rawQuery;
|
||||
}
|
||||
// 负载均衡
|
||||
ServiceInstance serviceInstance = SpringContext.getBean(SopLoadBalancerClient.class).choose(serviceId, exchange);
|
||||
List<ServiceInstance> instances = discoveryClient.getInstances(serviceId);
|
||||
if (CollectionUtils.isEmpty(instances)) {
|
||||
return Mono.error(new RuntimeException("serviceId: " + serviceId + " not found"));
|
||||
}
|
||||
ServiceInstance serviceInstance = instances.stream()
|
||||
.skip(new Random().nextInt(instances.size()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
String uri = "http://" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + targetPath;
|
||||
return proxy.uri(uri).forward();
|
||||
}
|
||||
|
@@ -1,36 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.filter;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.SopConstants;
|
||||
import com.gitee.sop.gatewaycommon.gateway.loadbalancer.SopLoadBalancerClient;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.gateway.config.LoadBalancerProperties;
|
||||
import org.springframework.cloud.gateway.filter.LoadBalancerClientFilter;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
|
||||
|
||||
/**
|
||||
* 扩展负载均衡过滤器
|
||||
* @author tanghc
|
||||
*/
|
||||
public class SopLoadBalancerClientFilter extends LoadBalancerClientFilter {
|
||||
public SopLoadBalancerClientFilter(LoadBalancerClient loadBalancer, LoadBalancerProperties properties) {
|
||||
super(loadBalancer, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServiceInstance choose(ServerWebExchange exchange) {
|
||||
ServiceInstance serviceInstance;
|
||||
if (loadBalancer instanceof SopLoadBalancerClient) {
|
||||
SopLoadBalancerClient sopLoadBalancerClient = (SopLoadBalancerClient)loadBalancer;
|
||||
serviceInstance = sopLoadBalancerClient.choose(((URI) exchange.getAttribute(GATEWAY_REQUEST_URL_ATTR)).getHost(), exchange);
|
||||
} else {
|
||||
serviceInstance = super.choose(exchange);
|
||||
}
|
||||
exchange.getAttributes().put(SopConstants.TARGET_SERVICE, serviceInstance);
|
||||
return serviceInstance;
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.loadbalancer;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.gateway.ServerWebExchangeUtil;
|
||||
import com.gitee.sop.gatewaycommon.loadbalancer.LoadBalanceServerChooser;
|
||||
import com.gitee.sop.gatewaycommon.param.ApiParam;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public class GatewayLoadBalanceServerChooser extends LoadBalanceServerChooser<ServerWebExchange, ServiceInstance> {
|
||||
|
||||
public GatewayLoadBalanceServerChooser(SpringClientFactory clientFactory) {
|
||||
this.setClientFactory(clientFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost(ServerWebExchange exchange) {
|
||||
return exchange.getRequest().getURI().getHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiParam getApiParam(ServerWebExchange exchange) {
|
||||
return ServerWebExchangeUtil.getApiParam(exchange);
|
||||
}
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.loadbalancer;
|
||||
|
||||
import com.alibaba.cloud.nacos.ribbon.NacosServer;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public class NacosServerIntrospector extends DefaultServerIntrospector {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata(Server server) {
|
||||
if (server instanceof NacosServer) {
|
||||
NacosServer discoveryServer = (NacosServer)server;
|
||||
return discoveryServer.getInstance().getMetadata();
|
||||
} else {
|
||||
return super.getMetadata(server);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.gateway.loadbalancer;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.gateway.ServerWebExchangeUtil;
|
||||
import com.gitee.sop.gatewaycommon.loadbalancer.ServerChooserContext;
|
||||
import com.gitee.sop.gatewaycommon.param.ApiParam;
|
||||
import com.gitee.sop.gatewaycommon.util.LoadBalanceUtil;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;
|
||||
import org.springframework.cloud.netflix.ribbon.RibbonUtils;
|
||||
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 重写负载均衡处理。
|
||||
* 默认使用的是RibbonLoadBalancerClient类,详见org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration#loadBalancerClient()
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
public class SopLoadBalancerClient extends RibbonLoadBalancerClient implements ServerChooserContext<ServerWebExchange> {
|
||||
|
||||
private final SpringClientFactory clientFactory;
|
||||
private GatewayLoadBalanceServerChooser loadBalanceServerChooser;
|
||||
|
||||
public SopLoadBalancerClient(SpringClientFactory clientFactory) {
|
||||
super(clientFactory);
|
||||
this.clientFactory = clientFactory;
|
||||
this.loadBalanceServerChooser = new GatewayLoadBalanceServerChooser(clientFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* New: Select a server using a 'key'.
|
||||
*/
|
||||
@Override
|
||||
public ServiceInstance choose(String serviceId, Object hint) {
|
||||
return loadBalanceServerChooser.choose(
|
||||
serviceId
|
||||
, (ServerWebExchange) hint
|
||||
, this.getLoadBalancer(serviceId)
|
||||
, () -> super.choose(serviceId, hint)
|
||||
, (servers) -> getRibbonServer(serviceId, servers)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiParam getApiParam(ServerWebExchange exchange) {
|
||||
return ServerWebExchangeUtil.getApiParam(exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost(ServerWebExchange exchange) {
|
||||
return exchange.getRequest().getURI().getHost();
|
||||
}
|
||||
|
||||
private RibbonServer getRibbonServer(String serviceId, List<Server> servers) {
|
||||
Server server = LoadBalanceUtil.chooseByRoundRobin(serviceId, servers);
|
||||
if (server == null) {
|
||||
return null;
|
||||
}
|
||||
return new RibbonServer(
|
||||
serviceId
|
||||
, server
|
||||
, isSecure(server, serviceId)
|
||||
, serverIntrospector(serviceId).getMetadata(server)
|
||||
);
|
||||
}
|
||||
|
||||
private ServerIntrospector serverIntrospector(String serviceId) {
|
||||
ServerIntrospector serverIntrospector = this.clientFactory.getInstance(serviceId,
|
||||
ServerIntrospector.class);
|
||||
if (serverIntrospector == null) {
|
||||
serverIntrospector = new DefaultServerIntrospector();
|
||||
}
|
||||
return serverIntrospector;
|
||||
}
|
||||
|
||||
private boolean isSecure(Server server, String serviceId) {
|
||||
IClientConfig config = this.clientFactory.getClientConfig(serviceId);
|
||||
ServerIntrospector serverIntrospector = serverIntrospector(serviceId);
|
||||
return RibbonUtils.isSecure(config, serverIntrospector, server);
|
||||
}
|
||||
}
|
@@ -0,0 +1,179 @@
|
||||
package com.gitee.sop.gatewaycommon.loadbalancer;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.SopConstants;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
|
||||
import com.gitee.sop.gatewaycommon.param.ApiParam;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.loadbalancer.*;
|
||||
import org.springframework.cloud.loadbalancer.core.NoopServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer;
|
||||
import org.springframework.cloud.loadbalancer.core.SelectedInstanceCallback;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.StringUtils;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Data
|
||||
public class GrayLoadBalancer implements ReactorServiceInstanceLoadBalancer {
|
||||
private static final Logger log = LoggerFactory.getLogger(GrayLoadBalancer.class);
|
||||
private final String serviceId;
|
||||
private AtomicInteger position; // 位置,下标
|
||||
private ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider;
|
||||
|
||||
public GrayLoadBalancer(ObjectProvider<ServiceInstanceListSupplier> serviceInstanceListSupplierProvider, String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
this.serviceInstanceListSupplierProvider = serviceInstanceListSupplierProvider;
|
||||
this.position = new AtomicInteger(new Random().nextInt(1000)); //随机进行设置一个值
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Response<ServiceInstance>> choose(Request request) {
|
||||
// 提供备选的服务实例列表
|
||||
ServiceInstanceListSupplier supplier = this.serviceInstanceListSupplierProvider.getIfAvailable(NoopServiceInstanceListSupplier::new);
|
||||
// 选择服务实例
|
||||
return supplier.get(request).next().map((serviceInstances) -> this.processInstanceResponse(supplier, serviceInstances, request));
|
||||
}
|
||||
|
||||
private Response<ServiceInstance> processInstanceResponse(ServiceInstanceListSupplier supplier,
|
||||
List<ServiceInstance> serviceInstances,
|
||||
Request request) {
|
||||
// 从备选的服务列表中选择一个具体的服务实例
|
||||
Response<ServiceInstance> serviceInstanceResponse = this.getInstanceResponse(serviceInstances,
|
||||
request);
|
||||
if (supplier instanceof SelectedInstanceCallback && serviceInstanceResponse.hasServer()) {
|
||||
((SelectedInstanceCallback) supplier).selectedServiceInstance((ServiceInstance) serviceInstanceResponse.getServer());
|
||||
}
|
||||
return serviceInstanceResponse;
|
||||
}
|
||||
|
||||
private Response<ServiceInstance> getInstanceResponse(List<ServiceInstance> instances,
|
||||
Request request) {
|
||||
// 实例为空 首先进行实例判空
|
||||
if (instances.isEmpty()) {
|
||||
if (log.isWarnEnabled()) {
|
||||
//判空后 给予警告
|
||||
log.warn("No servers available for service: " + this.serviceId);
|
||||
}
|
||||
//返回响应
|
||||
return new EmptyResponse();
|
||||
} else {
|
||||
// 存放预发服务器
|
||||
List<ServiceInstance> preServers = new ArrayList<>(4);
|
||||
// 存放灰度发布服务器
|
||||
List<ServiceInstance> grayServers = new ArrayList<>(4);
|
||||
// 存放非预发服务器
|
||||
List<ServiceInstance> notPreServers = new ArrayList<>(4);
|
||||
|
||||
notPreServers.addAll(grayServers);
|
||||
|
||||
for (ServiceInstance instance : instances) {
|
||||
// 获取实例metadata
|
||||
Map<String, String> metadata = instance.getMetadata();
|
||||
// 是否开启了预发模式
|
||||
if (this.isPreServer(metadata)) {
|
||||
preServers.add(instance);
|
||||
} else if (this.isGrayServer(metadata)) {
|
||||
grayServers.add(instance);
|
||||
} else {
|
||||
notPreServers.add(instance);
|
||||
}
|
||||
}
|
||||
notPreServers.addAll(grayServers);
|
||||
|
||||
RequestDataContext context = (RequestDataContext) request.getContext();
|
||||
ApiParam apiParam = new ApiParam();
|
||||
apiParam.putAll(context.getClientRequest().getAttributes());
|
||||
|
||||
// 如果没有开启预发布服务和灰度发布,直接用默认的方式
|
||||
if (preServers.isEmpty() && grayServers.isEmpty()) {
|
||||
int pos = this.position.incrementAndGet() & Integer.MAX_VALUE;
|
||||
ServiceInstance instance = instances.get(pos % instances.size());
|
||||
return new DefaultResponse(instance);
|
||||
}
|
||||
// 如果是从预发布域名访问过来,则认为是预发布请求,选出预发服务器
|
||||
if (this.isRequestFromPreDomain(context.getClientRequest().getHeaders())) {
|
||||
int pos = this.position.incrementAndGet() & Integer.MAX_VALUE;
|
||||
ServiceInstance instance = preServers.get(pos % instances.size());
|
||||
return new DefaultResponse(instance);
|
||||
}
|
||||
// 如果是灰度请求,则认为是灰度用户,选出灰度服务器
|
||||
if (apiParam.fetchGrayRequest()) {
|
||||
int pos = this.position.incrementAndGet() & Integer.MAX_VALUE;
|
||||
ServiceInstance instance = grayServers.get(pos % instances.size());
|
||||
return new DefaultResponse(instance);
|
||||
}
|
||||
return getInstanceResponse(instances);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是预发布服务器
|
||||
*
|
||||
* @param metadata metadata
|
||||
* @return true:是
|
||||
*/
|
||||
private boolean isPreServer(Map<String, String> metadata) {
|
||||
return Objects.equals(metadata.get(SopConstants.METADATA_ENV_KEY), SopConstants.METADATA_ENV_PRE_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是灰度发布服务器
|
||||
*
|
||||
* @param metadata metadata
|
||||
* @return true:是
|
||||
*/
|
||||
private boolean isGrayServer(Map<String, String> metadata) {
|
||||
return Objects.equals(metadata.get(SopConstants.METADATA_ENV_KEY), SopConstants.METADATA_ENV_GRAY_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过判断hostname来确定是否是预发布请求
|
||||
*
|
||||
* @param httpHeaders
|
||||
* @return 返回true:可以进入到预发环境
|
||||
*/
|
||||
boolean isRequestFromPreDomain(HttpHeaders httpHeaders) {
|
||||
String domain = EnvironmentKeys.PRE_DOMAIN.getValue();
|
||||
if (StringUtils.isEmpty(domain)) {
|
||||
return false;
|
||||
}
|
||||
String[] domains = domain.split("\\,");
|
||||
if (httpHeaders.getHost() != null) {
|
||||
String host = httpHeaders.getHost().getHostName();
|
||||
return ArrayUtils.contains(domains, host);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Response<ServiceInstance> getInstanceResponse(List<ServiceInstance> instances) {
|
||||
if (instances.isEmpty()) {
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn("No servers available for service: " + serviceId);
|
||||
}
|
||||
return new EmptyResponse();
|
||||
}
|
||||
|
||||
// Do not move position when there is only 1 instance, especially some suppliers
|
||||
// have already filtered instances
|
||||
if (instances.size() == 1) {
|
||||
return new DefaultResponse(instances.get(0));
|
||||
}
|
||||
|
||||
// Ignore the sign bit, this allows pos to loop sequentially from 0 to
|
||||
// Integer.MAX_VALUE
|
||||
int pos = this.position.incrementAndGet() & Integer.MAX_VALUE;
|
||||
|
||||
ServiceInstance instance = instances.get(pos % instances.size());
|
||||
|
||||
return new DefaultResponse(instance);
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.gitee.sop.gatewaycommon.loadbalancer;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
|
||||
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
|
||||
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@Configuration
|
||||
public class GrayLoadBalancerConfig {
|
||||
@Bean
|
||||
public ReactorLoadBalancer<ServiceInstance> GrayLoadBalancer(Environment environment, LoadBalancerClientFactory loadBalancerClientFactory) {
|
||||
String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
|
||||
return new GrayLoadBalancer(loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class), name);
|
||||
}
|
||||
}
|
@@ -1,128 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.loadbalancer;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.SopConstants;
|
||||
import com.gitee.sop.gatewaycommon.bean.SpringContext;
|
||||
import com.netflix.loadbalancer.ILoadBalancer;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
|
||||
import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 预发布、灰度发布服务器选择
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
public abstract class LoadBalanceServerChooser<T, R> implements ServerChooserContext<T> {
|
||||
|
||||
private SpringClientFactory clientFactory;
|
||||
|
||||
/**
|
||||
* 选择服务器
|
||||
*
|
||||
* @param serviceId serviceId,仅gateway网关有作用
|
||||
* @param exchange 请求上下文
|
||||
* @param loadBalancer loadBalancer
|
||||
* @param superChooser 父类默认的选择
|
||||
* @param serverChooserFunction 执行选择操作
|
||||
* @return 返回服务器实例,没有选到则返回null
|
||||
*/
|
||||
public R choose(
|
||||
String serviceId
|
||||
, T exchange
|
||||
, ILoadBalancer loadBalancer
|
||||
, Supplier<R> superChooser
|
||||
, Function<List<Server>, R> serverChooserFunction) {
|
||||
// 获取所有服务实例
|
||||
List<Server> servers = loadBalancer.getReachableServers();
|
||||
|
||||
// 存放预发服务器
|
||||
List<Server> preServers = new ArrayList<>(4);
|
||||
// 存放灰度发布服务器
|
||||
List<Server> grayServers = new ArrayList<>(4);
|
||||
// 存放非预发服务器
|
||||
List<Server> notPreServers = new ArrayList<>(4);
|
||||
|
||||
for (Server server : servers) {
|
||||
// 获取实例metadata
|
||||
Map<String, String> metadata = getMetadata(serviceId, server);
|
||||
// 是否开启了预发模式
|
||||
if (this.isPreServer(metadata)) {
|
||||
preServers.add(server);
|
||||
} else if (this.isGrayServer(metadata)) {
|
||||
grayServers.add(server);
|
||||
} else {
|
||||
notPreServers.add(server);
|
||||
}
|
||||
}
|
||||
notPreServers.addAll(grayServers);
|
||||
// 如果没有开启预发布服务和灰度发布,直接用默认的方式
|
||||
if (preServers.isEmpty() && grayServers.isEmpty()) {
|
||||
return superChooser.get();
|
||||
}
|
||||
// 如果是从预发布域名访问过来,则认为是预发布请求,选出预发服务器
|
||||
if (this.isRequestFromPreDomain(exchange)) {
|
||||
return serverChooserFunction.apply(preServers);
|
||||
}
|
||||
// 如果是灰度请求,则认为是灰度用户,选出灰度服务器
|
||||
if (this.isRequestGrayServer(exchange)) {
|
||||
return serverChooserFunction.apply(grayServers);
|
||||
}
|
||||
|
||||
// 到这里说明不能访问预发/灰度服务器,则需要路由到非预发服务器
|
||||
// 注意:这里允许走灰度服务器,如果不允许走,注释notPreServers.addAll(grayServers);这行
|
||||
return serverChooserFunction.apply(notPreServers);
|
||||
}
|
||||
|
||||
protected Map<String, String> getMetadata(String serviceId, Server server) {
|
||||
return serverIntrospector(serviceId).getMetadata(server);
|
||||
}
|
||||
|
||||
protected SpringClientFactory getSpringClientFactory() {
|
||||
if (clientFactory == null) {
|
||||
clientFactory = SpringContext.getBean(SpringClientFactory.class);
|
||||
}
|
||||
return clientFactory;
|
||||
}
|
||||
|
||||
public void setClientFactory(SpringClientFactory clientFactory) {
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
private ServerIntrospector serverIntrospector(String serviceId) {
|
||||
ServerIntrospector serverIntrospector = getSpringClientFactory().getInstance(serviceId,
|
||||
ServerIntrospector.class);
|
||||
if (serverIntrospector == null) {
|
||||
serverIntrospector = new DefaultServerIntrospector();
|
||||
}
|
||||
return serverIntrospector;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是预发布服务器
|
||||
*
|
||||
* @param metadata metadata
|
||||
* @return true:是
|
||||
*/
|
||||
private boolean isPreServer(Map<String, String> metadata) {
|
||||
return Objects.equals(metadata.get(SopConstants.METADATA_ENV_KEY), SopConstants.METADATA_ENV_PRE_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是灰度发布服务器
|
||||
*
|
||||
* @param metadata metadata
|
||||
* @return true:是
|
||||
*/
|
||||
private boolean isGrayServer(Map<String, String> metadata) {
|
||||
return Objects.equals(metadata.get(SopConstants.METADATA_ENV_KEY), SopConstants.METADATA_ENV_GRAY_VALUE);
|
||||
}
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package com.gitee.sop.gatewaycommon.loadbalancer;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiParamAware;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
|
||||
import com.gitee.sop.gatewaycommon.param.ApiParam;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public interface ServerChooserContext<T> extends ApiParamAware<T> {
|
||||
|
||||
/**
|
||||
* 通过判断hostname来确定是否是预发布请求
|
||||
*
|
||||
* @param t t
|
||||
* @return 返回true:可以进入到预发环境
|
||||
*/
|
||||
default boolean isRequestFromPreDomain(T t) {
|
||||
String domain = EnvironmentKeys.PRE_DOMAIN.getValue();
|
||||
if (StringUtils.isEmpty(domain)) {
|
||||
return false;
|
||||
}
|
||||
String[] domains = domain.split("\\,");
|
||||
return ArrayUtils.contains(domains, getHost(t));
|
||||
}
|
||||
|
||||
default boolean isRequestGrayServer(T t) {
|
||||
ApiParam apiParam = getApiParam(t);
|
||||
return apiParam.fetchGrayRequest();
|
||||
}
|
||||
|
||||
String getHost(T t);
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package com.gitee.sop.gatewaycommon.manager;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.gitee.sop.gatewaycommon.manager;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ConfigLimitDto;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package com.gitee.sop.gatewaycommon.route;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.InstanceDefinition;
|
||||
import com.gitee.sop.gatewaycommon.bean.SpringContext;
|
||||
import com.gitee.sop.gatewaycommon.manager.EnvironmentKeys;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@@ -7,7 +7,7 @@ import com.gitee.sop.gatewaycommon.bean.ServiceBeanInitializer;
|
||||
import com.gitee.sop.gatewaycommon.bean.ServiceRouteInfo;
|
||||
import com.gitee.sop.gatewaycommon.gateway.route.GatewayRouteCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.http.HttpEntity;
|
||||
|
@@ -107,7 +107,7 @@ public class RequestUtil {
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("字符集不支持", e);
|
||||
}
|
||||
return org.apache.commons.lang.StringUtils.join(list, "&");
|
||||
return org.apache.commons.lang3.StringUtils.join(list, "&");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -12,12 +12,12 @@
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
<!-- springboot 版本-->
|
||||
<spring-boot.version>2.3.2.RELEASE</spring-boot.version>
|
||||
<spring-boot.version>2.6.15</spring-boot.version>
|
||||
<!-- spring cloud 版本 -->
|
||||
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
|
||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||
<!-- spring cloud alibaba 版本 -->
|
||||
<!-- 具体版本对应关系见:https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E -->
|
||||
<spring-cloud-alibaba.version>2.2.5.RELEASE</spring-cloud-alibaba.version>
|
||||
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
|
||||
|
||||
<!-- Logging -->
|
||||
<logback.version>1.2.3</logback.version>
|
||||
@@ -35,8 +35,8 @@
|
||||
<fastmybatis.version>1.9.1</fastmybatis.version>
|
||||
<guava.version>29.0-jre</guava.version>
|
||||
<swagger.version>1.5.21</swagger.version>
|
||||
<springfox-spring-web.version>2.9.2</springfox-spring-web.version>
|
||||
<springfox-swagger2.version>2.9.2</springfox-swagger2.version>
|
||||
<springfox-spring-web.version>3.0.0</springfox-spring-web.version>
|
||||
<springfox-swagger2.version>3.0.0</springfox-swagger2.version>
|
||||
<easyopen.version>1.16.9</easyopen.version>
|
||||
<pagehelper.version>5.2.0</pagehelper.version>
|
||||
<asm.version>6.2</asm.version>
|
||||
@@ -129,6 +129,10 @@
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@@ -37,7 +37,7 @@ public class ServiceConfiguration extends SpringmvcConfiguration {
|
||||
// 在元数据中新增启动时间,不能修改这个值,不然网关拉取接口会有问题
|
||||
// 如果没有这个值,网关会忽略这个服务
|
||||
metadata.put("server.startup-time", String.valueOf(System.currentTimeMillis()));
|
||||
return new NacosWatch(nacosServiceManager, nacosDiscoveryProperties, taskScheduler);
|
||||
return new NacosWatch(nacosServiceManager, nacosDiscoveryProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +0,0 @@
|
||||
package com.gitee.sop.servercommon.swagger;
|
||||
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CustomModelToSwaggerMapper extends ServiceModelToSwagger2MapperImpl {
|
||||
|
||||
@Override
|
||||
protected List<Parameter> parameterListToParameterList(List<springfox.documentation.service.Parameter> list) {
|
||||
// list需要根据order|postion排序
|
||||
list = list.stream()
|
||||
.sorted(Comparator.comparingInt(springfox.documentation.service.Parameter::getOrder))
|
||||
.collect(Collectors.toList());
|
||||
return super.parameterListToParameterList(list);
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
package com.gitee.sop.servercommon.swagger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -24,6 +23,7 @@ import springfox.documentation.swagger.schema.ApiModelProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static springfox.documentation.swagger.common.SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CustomSwaggerParameterBuilder implements ExpandedParameterBuilderPl
|
||||
private void fromApiParam(ParameterExpansionContext context, ApiParam apiParam) {
|
||||
String allowableProperty = Strings.emptyToNull(apiParam.allowableValues());
|
||||
AllowableValues allowable = allowableValues(
|
||||
Optional.fromNullable(allowableProperty),
|
||||
Optional.ofNullable(allowableProperty),
|
||||
context.getFieldType().getErasedType());
|
||||
|
||||
maybeSetParameterName(context, apiParam.name())
|
||||
@@ -88,7 +88,7 @@ public class CustomSwaggerParameterBuilder implements ExpandedParameterBuilderPl
|
||||
private void fromApiModelProperty(ParameterExpansionContext context, ApiModelProperty apiModelProperty) {
|
||||
String allowableProperty = Strings.emptyToNull(apiModelProperty.allowableValues());
|
||||
AllowableValues allowable = allowableValues(
|
||||
Optional.fromNullable(allowableProperty),
|
||||
Optional.ofNullable(allowableProperty),
|
||||
context.getFieldType().getErasedType());
|
||||
|
||||
maybeSetParameterName(context, apiModelProperty.name())
|
||||
|
@@ -6,7 +6,6 @@ import com.fasterxml.classmate.members.RawField;
|
||||
import com.gitee.sop.servercommon.annotation.BizCode;
|
||||
import com.gitee.sop.servercommon.annotation.Open;
|
||||
import com.gitee.sop.servercommon.bean.ServiceConfig;
|
||||
import com.google.common.base.Optional;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -24,10 +23,7 @@ import springfox.documentation.spring.web.plugins.DocumentationPluginsManager;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@@ -29,12 +29,6 @@ public abstract class SwaggerSupport {
|
||||
return new DocumentationPluginsManagerExt();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public CustomModelToSwaggerMapper customModelToSwaggerMapper() {
|
||||
return new CustomModelToSwaggerMapper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public CustomSwaggerParameterBuilder customSwaggerParameterBuilder(
|
||||
|
@@ -107,14 +107,7 @@
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- @Inject -->
|
||||
<dependency>
|
||||
|
@@ -4,7 +4,7 @@ import com.alibaba.nacos.api.annotation.NacosInjected;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.client.naming.utils.NetUtils;
|
||||
import com.alibaba.nacos.api.utils.NetUtils;
|
||||
import com.alibaba.nacos.spring.context.annotation.discovery.EnableNacosDiscovery;
|
||||
import com.gitee.sop.servercommon.configuration.SpringmvcConfiguration;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@@ -47,18 +47,12 @@
|
||||
<!-- swagger2 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@@ -3,6 +3,7 @@ package com.gitee.sop.storyweb.controller.param;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
|
@@ -1 +1,2 @@
|
||||
spring.profiles.active=dev
|
||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
@@ -1,8 +1,12 @@
|
||||
package com.gitee.sop.gateway;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@MapperScan(basePackages = {
|
||||
"com.gitee.sop.gateway.mapper"
|
||||
})
|
||||
@SpringBootApplication(scanBasePackages = "com.gitee.sop")
|
||||
public class SopGatewayApplication {
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.gitee.sop.gateway.config;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.bean.ApiConfig;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_gray")
|
||||
@Table(name = "config_gray",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigGray {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -15,12 +12,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_gray_instance")
|
||||
@Table(name = "config_gray_instance",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigGrayInstance {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_limit")
|
||||
@Table(name = "config_limit",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigLimit {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,12 +12,9 @@ import javax.persistence.Table;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_route_base")
|
||||
@Table(name = "config_route_base",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigRouteBase {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "config_service_route")
|
||||
@Table(name = "config_service_route",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class ConfigServiceRoute {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
/** 数据库字段:id */
|
||||
private String id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_info")
|
||||
@Table(name = "isv_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvInfo {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -17,13 +14,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "monitor_info")
|
||||
@Table(name = "monitor_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class MonitorInfo {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 路由id, 数据库字段:route_id */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -16,13 +13,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "monitor_info_error")
|
||||
@Table(name = "monitor_info_error",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class MonitorInfoError {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 错误id,md5Hex(instanceId + routeId + errorMsg), 数据库字段:error_id */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "perm_isv_role")
|
||||
@Table(name = "perm_isv_role",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class PermIsvRole {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.gateway.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "perm_role_permission")
|
||||
@Table(name = "perm_role_permission",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class PermRolePermission {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.gitee.sop.gateway.interceptor;
|
||||
|
||||
import com.gitee.sop.gateway.mapper.DbMonitorInfoManager;
|
||||
import com.gitee.sop.gateway.manager.DbMonitorInfoManager;
|
||||
import com.gitee.sop.gatewaycommon.bean.LRUCache;
|
||||
import com.gitee.sop.gatewaycommon.interceptor.RouteInterceptorContext;
|
||||
import com.gitee.sop.gatewaycommon.monitor.MonitorDTO;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.gitee.sop.gateway.mapper;
|
||||
package com.gitee.sop.gateway.manager;
|
||||
|
||||
import com.gitee.sop.gateway.mapper.MonitorInfoErrorMapper;
|
||||
import com.gitee.sop.gateway.mapper.MonitorInfoMapper;
|
||||
import com.gitee.sop.gatewaycommon.monitor.MonitorDTO;
|
||||
import com.gitee.sop.gatewaycommon.monitor.MonitorErrorMsg;
|
||||
import com.gitee.sop.gatewaycommon.monitor.RouteErrorCount;
|
@@ -1,22 +1,22 @@
|
||||
package com.gitee.sop.gateway;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* @author tanghc
|
||||
*/
|
||||
public class ExcludeTest extends TestCase {
|
||||
public void testRegex() {
|
||||
String serviceId = "com.aaa.bbb.story-service";
|
||||
String sopServiceExcludeRegex = "com\\..*;story\\-.*";
|
||||
if (StringUtils.isNotBlank(sopServiceExcludeRegex)) {
|
||||
String[] regexArr = sopServiceExcludeRegex.split(";");
|
||||
for (String regex : regexArr) {
|
||||
if (serviceId.matches(regex)) {
|
||||
System.out.println("111");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.gitee.sop.gateway;
|
||||
//
|
||||
//import junit.framework.TestCase;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//
|
||||
///**
|
||||
// * @author tanghc
|
||||
// */
|
||||
//public class ExcludeTest extends TestCase {
|
||||
// public void testRegex() {
|
||||
// String serviceId = "com.aaa.bbb.story-service";
|
||||
// String sopServiceExcludeRegex = "com\\..*;story\\-.*";
|
||||
// if (StringUtils.isNotBlank(sopServiceExcludeRegex)) {
|
||||
// String[] regexArr = sopServiceExcludeRegex.split(";");
|
||||
// for (String regex : regexArr) {
|
||||
// if (serviceId.matches(regex)) {
|
||||
// System.out.println("111");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
@@ -2,7 +2,7 @@ package com.gitee.sop.websiteserver.bean;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@@ -2,7 +2,7 @@ package com.gitee.sop.websiteserver.bean;
|
||||
|
||||
import com.gitee.sop.gatewaycommon.exception.ApiException;
|
||||
import com.gitee.sop.gatewaycommon.message.ErrorMeta;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@@ -33,12 +33,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@Configuration
|
||||
public class WebsiteConfig implements WebMvcConfigurer, EnvironmentAware, ApplicationContextAware {
|
||||
|
||||
@Autowired
|
||||
private RegistryListener registryListener;
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
SpringContext.setApplicationContext(applicationContext);
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ public class WebsiteConfig implements WebMvcConfigurer, EnvironmentAware, Applic
|
||||
*/
|
||||
@EventListener(classes = HeartbeatEvent.class)
|
||||
public void listenNacosEvent(ApplicationEvent heartbeatEvent) {
|
||||
registryListener.onEvent(heartbeatEvent);
|
||||
applicationContext.getBean(RegistryListener.class).onEvent(heartbeatEvent);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.websiteserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,13 +13,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isp_resource")
|
||||
@Table(name = "isp_resource",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IspResource {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 资源名称, 数据库字段:name */
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.websiteserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_info")
|
||||
@Table(name = "isv_info",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvInfo {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.websiteserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,12 +13,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "isv_keys")
|
||||
@Table(name = "isv_keys",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class IsvKeys {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
/** 数据库字段:id */
|
||||
private Long id;
|
||||
|
||||
|
@@ -2,11 +2,8 @@ package com.gitee.sop.websiteserver.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@@ -16,13 +13,10 @@ import java.util.Date;
|
||||
*
|
||||
* @author tanghc
|
||||
*/
|
||||
@Table(name = "user_account")
|
||||
@Table(name = "user_account",pk = @Pk(name = "id"))
|
||||
@Data
|
||||
public class UserAccount {
|
||||
/** 数据库字段:id */
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** 用户名(邮箱), 数据库字段:username */
|
||||
|
@@ -41,7 +41,7 @@ public class ServiceDocListener extends BaseServiceListener {
|
||||
, instance.getIp() + ":" + instance.getPort())
|
||||
);
|
||||
} else {
|
||||
log.error("加载文档失败, status:{}, body:{}", responseEntity.getStatusCodeValue(), responseEntity.getBody());
|
||||
log.error("加载服务文档,serviceId={}, 机器={}, status:{}, body:{}" , serviceId , instance.getIp() + ":" + instance.getPort(), responseEntity.getStatusCodeValue(), responseEntity.getBody());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import com.gitee.sop.websiteserver.bean.DocModule;
|
||||
import com.gitee.sop.websiteserver.bean.DocParameter;
|
||||
import com.gitee.sop.websiteserver.bean.DocParserContext;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
Reference in New Issue
Block a user