13 changed files with 1282 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||
|
# Created by .ignore support plugin (hsz.mobi) |
||||
|
### Java template |
||||
|
# Compiled class file |
||||
|
*.class |
||||
|
|
||||
|
# Log file |
||||
|
*.log |
||||
|
|
||||
|
# BlueJ files |
||||
|
*.ctxt |
||||
|
|
||||
|
# Mobile Tools for Java (J2ME) |
||||
|
.mtj.tmp/ |
||||
|
|
||||
|
# Package Files # |
||||
|
*.jar |
||||
|
*.war |
||||
|
*.nar |
||||
|
*.ear |
||||
|
*.zip |
||||
|
*.tar.gz |
||||
|
*.rar |
||||
|
|
||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml |
||||
|
hs_err_pid* |
||||
|
.idea/ |
||||
|
*.iml |
||||
|
**/target/ |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
# 基础镜像 |
||||
|
FROM openjdk:8 |
||||
|
# 作者 |
||||
|
MAINTAINER rongchao@elink-cn.com |
||||
|
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_FILE的值 |
||||
|
ARG JAR_FILE |
||||
|
# 对应pom.xml文件中的dockerfile-maven-plugin插件JAR_NAME的值 |
||||
|
ARG JAR_NAME |
||||
|
# 对应pom.xml文件中的dockerfile-maven-plugin插件SERVER_PORT的值 |
||||
|
ARG SERVER_PORT |
||||
|
# 复制打包完成后的jar文件到/opt目录下 |
||||
|
ENV JAR_PATH /mnt/epdc/${JAR_NAME}.jar |
||||
|
ADD ${JAR_FILE} $JAR_PATH |
||||
|
# /data设为环境变量 |
||||
|
ENV DATAPATH /data |
||||
|
# 挂载/data目录到主机 |
||||
|
VOLUME $DATAPATH |
||||
|
# 启动容器时执行 |
||||
|
ENTRYPOINT java -jar $JAR_CONFIG $JAR_PATH |
||||
|
EXPOSE ${SERVER_PORT} |
@ -0,0 +1,261 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<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"> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<parent> |
||||
|
<groupId>com.esua.epdc.yushan</groupId> |
||||
|
<artifactId>epdc-cloud-parent-yushan</artifactId> |
||||
|
<version>1.0.0</version> |
||||
|
<relativePath>../epdc-cloud-parent-yushan</relativePath> |
||||
|
</parent> |
||||
|
|
||||
|
<artifactId>epdc-cloud-gateway-yushan</artifactId> |
||||
|
<packaging>jar</packaging> |
||||
|
<description>榆山党建e家网关模块</description> |
||||
|
|
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-gateway</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- zipkin client --> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-zipkin</artifactId> |
||||
|
</dependency> |
||||
|
|
||||
|
<!-- commons start --> |
||||
|
<dependency> |
||||
|
<groupId>com.esua.epdc.yushan</groupId> |
||||
|
<artifactId>epdc-commons-tools</artifactId> |
||||
|
<version>${epdc-cloud-commons.version}</version> |
||||
|
</dependency> |
||||
|
|
||||
|
<dependency> |
||||
|
<groupId>com.esua.epdc.yushan</groupId> |
||||
|
<artifactId>epdc-common-clienttoken</artifactId> |
||||
|
<version>${epdc-cloud-commons.version}</version> |
||||
|
</dependency> |
||||
|
<!-- commons end --> |
||||
|
</dependencies> |
||||
|
|
||||
|
<build> |
||||
|
<finalName>${project.artifactId}</finalName> |
||||
|
<plugins> |
||||
|
<plugin> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
|
</plugin> |
||||
|
<plugin> |
||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||
|
<artifactId>maven-surefire-plugin</artifactId> |
||||
|
<configuration> |
||||
|
<skipTests>true</skipTests> |
||||
|
</configuration> |
||||
|
</plugin> |
||||
|
<plugin> |
||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||
|
<artifactId>maven-deploy-plugin</artifactId> |
||||
|
<configuration> |
||||
|
<skip>true</skip> |
||||
|
</configuration> |
||||
|
</plugin> |
||||
|
<plugin> |
||||
|
<groupId>com.spotify</groupId> |
||||
|
<artifactId>dockerfile-maven-plugin</artifactId> |
||||
|
</plugin> |
||||
|
</plugins> |
||||
|
</build> |
||||
|
|
||||
|
<profiles> |
||||
|
<profile> |
||||
|
<id>dev</id> |
||||
|
<activation> |
||||
|
<activeByDefault>true</activeByDefault> |
||||
|
</activation> |
||||
|
<properties> |
||||
|
<server.port>9094</server.port> |
||||
|
<spring.profiles.active>dev</spring.profiles.active> |
||||
|
<docker.tag>dev</docker.tag> |
||||
|
|
||||
|
<!-- redis配置 --> |
||||
|
<spring.redis.index>2</spring.redis.index> |
||||
|
<spring.redis.host>47.104.224.45</spring.redis.host> |
||||
|
<spring.redis.port>6379</spring.redis.port> |
||||
|
<spring.redis.password>elink@888</spring.redis.password> |
||||
|
|
||||
|
<!-- gateway routes --> |
||||
|
<gateway.routes.epdc-auth-server.uri>lb://epdc-auth-server</gateway.routes.epdc-auth-server.uri> |
||||
|
<gateway.routes.epdc-admin-server.uri>lb://epdc-admin-server</gateway.routes.epdc-admin-server.uri> |
||||
|
<!-- <gateway.routes.epdc-admin-server.uri>http://127.0.0.1:9092</gateway.routes.epdc-admin-server.uri>--> |
||||
|
<gateway.routes.epdc-activiti-server.uri>lb://epdc-activiti-server |
||||
|
</gateway.routes.epdc-activiti-server.uri> |
||||
|
<!--<gateway.routes.epdc-api-server.uri>lb://epdc-api-server</gateway.routes.epdc-api-server.uri>--> |
||||
|
<gateway.routes.epdc-api-server.uri>http://127.0.0.1:9040</gateway.routes.epdc-api-server.uri> |
||||
|
<gateway.routes.epdc-app-server.uri>lb://epdc-app-server</gateway.routes.epdc-app-server.uri> |
||||
|
<!-- <gateway.routes.epdc-app-server.uri>http://127.0.0.1:9058</gateway.routes.epdc-app-server.uri>--> |
||||
|
<gateway.routes.epdc-heart-server.uri>lb://epdc-heart-server</gateway.routes.epdc-heart-server.uri> |
||||
|
<!-- <gateway.routes.epdc-heart-server.uri>http://127.0.0.1:9060</gateway.routes.epdc-heart-server.uri>--> |
||||
|
<gateway.routes.epdc-job-server.uri>lb://epdc-job-server</gateway.routes.epdc-job-server.uri> |
||||
|
<!-- <gateway.routes.epdc-job-server.uri>http://127.0.0.1:9061</gateway.routes.epdc-job-server.uri>--> |
||||
|
<gateway.routes.epdc-message-server.uri>lb://epdc-message-server |
||||
|
</gateway.routes.epdc-message-server.uri> |
||||
|
<!--<gateway.routes.epdc-news-server.uri>lb://epdc-news-server</gateway.routes.epdc-news-server.uri>--> |
||||
|
<gateway.routes.epdc-news-server.uri>http://127.0.0.1:9064</gateway.routes.epdc-news-server.uri> |
||||
|
<gateway.routes.epdc-oss-server.uri>lb://epdc-oss-server</gateway.routes.epdc-oss-server.uri> |
||||
|
<gateway.routes.epdc-events-server.uri>lb://epdc-events-server</gateway.routes.epdc-events-server.uri> |
||||
|
<!-- <gateway.routes.epdc-events-server.uri>http://127.0.0.1:9066</gateway.routes.epdc-events-server.uri>--> |
||||
|
<gateway.routes.epdc-cloud-analysis-server.uri>http://127.0.0.1:9060 |
||||
|
</gateway.routes.epdc-cloud-analysis-server.uri> |
||||
|
<!-- <gateway.routes.epdc-cloud-analysis-server.uri>lb://epdc-cloud-analysis-server</gateway.routes.epdc-cloud-analysis-server.uri>--> |
||||
|
<gateway.routes.epdc-work-record-server.uri>http://127.0.0.1:9085 |
||||
|
</gateway.routes.epdc-work-record-server.uri> |
||||
|
<!-- <gateway.routes.epdc-work-record-server.uri>lb://epdc-work-record-server</gateway.routes.epdc-work-record-server.uri>--> |
||||
|
<gateway.routes.epdc-services-server.uri>lb://epdc-services-server |
||||
|
</gateway.routes.epdc-services-server.uri> |
||||
|
<!-- <gateway.routes.epdc-services-server.uri>http://127.0.0.1:9067</gateway.routes.epdc-services-server.uri>--> |
||||
|
<!--<gateway.routes.epdc-user-server.uri>lb://epdc-user-server</gateway.routes.epdc-user-server.uri>--> |
||||
|
<gateway.routes.epdc-user-server.uri>http://127.0.0.1:9068</gateway.routes.epdc-user-server.uri> |
||||
|
<gateway.routes.epdc-demo-server.uri>lb://epdc-demo-server</gateway.routes.epdc-demo-server.uri> |
||||
|
<gateway.routes.epdc-group-server.uri>http://127.0.0.1:9063</gateway.routes.epdc-group-server.uri> |
||||
|
<!--<gateway.routes.epdc-group-server.uri>lb://epdc-group-server</gateway.routes.epdc-group-server.uri>--> |
||||
|
<gateway.routes.epdc-websocket-server.uri>lb://epdc-websocket-server |
||||
|
</gateway.routes.epdc-websocket-server.uri> |
||||
|
<!-- <gateway.routes.epdc-custom-server.uri>http://127.0.0.1:9076</gateway.routes.epdc-kpi-server.uri>--> |
||||
|
<gateway.routes.epdc-custom-server.uri>lb://epdc-custom-server</gateway.routes.epdc-custom-server.uri> |
||||
|
<gateway.routes.epdc-points-server.uri>lb://epdc-points-server</gateway.routes.epdc-points-server.uri> |
||||
|
<!-- <gateway.routes.epdc-kpi-server.uri>lb://epdc-kpi-server</gateway.routes.epdc-kpi-server.uri>--> |
||||
|
<gateway.routes.epdc-kpi-server.uri>http://127.0.0.1:9069</gateway.routes.epdc-kpi-server.uri> |
||||
|
<gateway.routes.epdc-analysis-server.uri>lb://epdc-analysis-server |
||||
|
</gateway.routes.epdc-analysis-server.uri> |
||||
|
<!-- nacos --> |
||||
|
<nacos.register-enabled>false</nacos.register-enabled> |
||||
|
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
||||
|
<nacos.ip></nacos.ip> |
||||
|
<nacos.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.namespace> |
||||
|
|
||||
|
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
||||
|
</properties> |
||||
|
</profile> |
||||
|
<profile> |
||||
|
<id>test</id> |
||||
|
<properties> |
||||
|
<server.port>10000</server.port> |
||||
|
<spring.profiles.active>test</spring.profiles.active> |
||||
|
<docker.tag>test</docker.tag> |
||||
|
|
||||
|
<!-- redis配置 --> |
||||
|
<spring.redis.index>2</spring.redis.index> |
||||
|
<spring.redis.host>114.215.125.123</spring.redis.host> |
||||
|
<spring.redis.port>9603</spring.redis.port> |
||||
|
<spring.redis.password>epdc!redis@master1405</spring.redis.password> |
||||
|
|
||||
|
<!-- gateway routes --> |
||||
|
<gateway.routes.epdc-auth-server.uri>lb://epdc-auth-server</gateway.routes.epdc-auth-server.uri> |
||||
|
<gateway.routes.epdc-admin-server.uri>lb://epdc-admin-server</gateway.routes.epdc-admin-server.uri> |
||||
|
<gateway.routes.epdc-activiti-server.uri>lb://epdc-activiti-server |
||||
|
</gateway.routes.epdc-activiti-server.uri> |
||||
|
<gateway.routes.epdc-api-server.uri>lb://epdc-api-server</gateway.routes.epdc-api-server.uri> |
||||
|
<gateway.routes.epdc-app-server.uri>lb://epdc-app-server</gateway.routes.epdc-app-server.uri> |
||||
|
<gateway.routes.epdc-heart-server.uri>lb://epdc-heart-server</gateway.routes.epdc-heart-server.uri> |
||||
|
<gateway.routes.epdc-job-server.uri>lb://epdc-job-server</gateway.routes.epdc-job-server.uri> |
||||
|
<gateway.routes.epdc-message-server.uri>lb://epdc-message-server |
||||
|
</gateway.routes.epdc-message-server.uri> |
||||
|
<gateway.routes.epdc-news-server.uri>lb://epdc-news-server</gateway.routes.epdc-news-server.uri> |
||||
|
<gateway.routes.epdc-oss-server.uri>lb://epdc-oss-server</gateway.routes.epdc-oss-server.uri> |
||||
|
<gateway.routes.epdc-events-server.uri>lb://epdc-events-server</gateway.routes.epdc-events-server.uri> |
||||
|
<gateway.routes.epdc-cloud-analysis-server.uri>lb://epdc-cloud-analysis-server |
||||
|
</gateway.routes.epdc-cloud-analysis-server.uri> |
||||
|
<gateway.routes.epdc-work-record-server.uri>lb://epdc-work-record-server |
||||
|
</gateway.routes.epdc-work-record-server.uri> |
||||
|
<gateway.routes.epdc-services-server.uri>lb://epdc-services-server |
||||
|
</gateway.routes.epdc-services-server.uri> |
||||
|
<gateway.routes.epdc-user-server.uri>lb://epdc-user-server</gateway.routes.epdc-user-server.uri> |
||||
|
<gateway.routes.epdc-demo-server.uri>lb://epdc-demo-server</gateway.routes.epdc-demo-server.uri> |
||||
|
<gateway.routes.epdc-group-server.uri>lb://epdc-group-server</gateway.routes.epdc-group-server.uri> |
||||
|
<gateway.routes.epdc-websocket-server.uri>lb://epdc-websocket-server |
||||
|
</gateway.routes.epdc-websocket-server.uri> |
||||
|
<gateway.routes.epdc-kpi-server.uri>lb://epdc-kpi-server</gateway.routes.epdc-kpi-server.uri> |
||||
|
<gateway.routes.epdc-custom-server.uri>lb://epdc-custom-server</gateway.routes.epdc-custom-server.uri> |
||||
|
<gateway.routes.epdc-points-server.uri>lb://epdc-points-server</gateway.routes.epdc-points-server.uri> |
||||
|
<gateway.routes.epdc-analysis-server.uri>lb://epdc-analysis-server |
||||
|
</gateway.routes.epdc-analysis-server.uri> |
||||
|
|
||||
|
<!-- nacos --> |
||||
|
<nacos.register-enabled>true</nacos.register-enabled> |
||||
|
<nacos.server-addr>47.104.224.45:8848</nacos.server-addr> |
||||
|
<nacos.ip>47.104.85.99</nacos.ip> |
||||
|
<nacos.namespace>6a3577b4-7b79-43f6-aebb-9c3f31263f6a</nacos.namespace> |
||||
|
|
||||
|
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
||||
|
</properties> |
||||
|
</profile> |
||||
|
|
||||
|
<profile> |
||||
|
<id>prod</id> |
||||
|
<properties> |
||||
|
<server.port>9094</server.port> |
||||
|
<spring.profiles.active>prod</spring.profiles.active> |
||||
|
<docker.tag>prod</docker.tag> |
||||
|
|
||||
|
<!-- gateway routes --> |
||||
|
<gateway.routes.epdc-auth-server.uri>lb://epdc-auth-server</gateway.routes.epdc-auth-server.uri> |
||||
|
<gateway.routes.epdc-admin-server.uri>lb://epdc-admin-server</gateway.routes.epdc-admin-server.uri> |
||||
|
<gateway.routes.epdc-activiti-server.uri>lb://epdc-activiti-server |
||||
|
</gateway.routes.epdc-activiti-server.uri> |
||||
|
<gateway.routes.epdc-api-server.uri>lb://epdc-api-server</gateway.routes.epdc-api-server.uri> |
||||
|
<gateway.routes.epdc-app-server.uri>lb://epdc-app-server</gateway.routes.epdc-app-server.uri> |
||||
|
<gateway.routes.epdc-heart-server.uri>lb://epdc-heart-server</gateway.routes.epdc-heart-server.uri> |
||||
|
<gateway.routes.epdc-job-server.uri>lb://epdc-job-server</gateway.routes.epdc-job-server.uri> |
||||
|
<gateway.routes.epdc-message-server.uri>lb://epdc-message-server |
||||
|
</gateway.routes.epdc-message-server.uri> |
||||
|
<gateway.routes.epdc-news-server.uri>lb://epdc-news-server</gateway.routes.epdc-news-server.uri> |
||||
|
<gateway.routes.epdc-oss-server.uri>lb://epdc-oss-server</gateway.routes.epdc-oss-server.uri> |
||||
|
<gateway.routes.epdc-cloud-analysis-server.uri>lb://epdc-cloud-analysis-server |
||||
|
</gateway.routes.epdc-cloud-analysis-server.uri> |
||||
|
<gateway.routes.epdc-work-record-server.uri>lb://epdc-work-record-server |
||||
|
</gateway.routes.epdc-work-record-server.uri> |
||||
|
<gateway.routes.epdc-events-server.uri>lb://epdc-events-server</gateway.routes.epdc-events-server.uri> |
||||
|
<gateway.routes.epdc-services-server.uri>lb://epdc-services-server |
||||
|
</gateway.routes.epdc-services-server.uri> |
||||
|
<gateway.routes.epdc-user-server.uri>lb://epdc-user-server</gateway.routes.epdc-user-server.uri> |
||||
|
<gateway.routes.epdc-demo-server.uri>lb://epdc-demo-server</gateway.routes.epdc-demo-server.uri> |
||||
|
<gateway.routes.epdc-group-server.uri>lb://epdc-group-server</gateway.routes.epdc-group-server.uri> |
||||
|
<gateway.routes.epdc-websocket-server.uri>lb://epdc-websocket-server |
||||
|
</gateway.routes.epdc-websocket-server.uri> |
||||
|
<gateway.routes.epdc-kpi-server.uri>lb://epdc-kpi-server</gateway.routes.epdc-kpi-server.uri> |
||||
|
<gateway.routes.epdc-custom-server.uri>lb://epdc-custom-server</gateway.routes.epdc-custom-server.uri> |
||||
|
<gateway.routes.epdc-points-server.uri>lb://epdc-points-server</gateway.routes.epdc-points-server.uri> |
||||
|
<gateway.routes.epdc-analysis-server.uri>lb://epdc-analysis-server |
||||
|
</gateway.routes.epdc-analysis-server.uri> |
||||
|
|
||||
|
<!-- redis配置 --> |
||||
|
<spring.redis.index>0</spring.redis.index> |
||||
|
<spring.redis.host>172.16.0.54</spring.redis.host> |
||||
|
<spring.redis.port>6379</spring.redis.port> |
||||
|
<spring.redis.password>Elink833066</spring.redis.password> |
||||
|
|
||||
|
<!-- nacos --> |
||||
|
<nacos.register-enabled>true</nacos.register-enabled> |
||||
|
<nacos.server-addr>172.16.0.52:8848</nacos.server-addr> |
||||
|
<nacos.ip></nacos.ip> |
||||
|
<nacos.namespace></nacos.namespace> |
||||
|
|
||||
|
<spring.zipkin.base-url>http://localhost:9411</spring.zipkin.base-url> |
||||
|
</properties> |
||||
|
</profile> |
||||
|
</profiles> |
||||
|
|
||||
|
</project> |
@ -0,0 +1,31 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc; |
||||
|
|
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||
|
|
||||
|
/** |
||||
|
* 网关服务 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@SpringBootApplication |
||||
|
@EnableDiscoveryClient |
||||
|
@EnableFeignClients |
||||
|
public class GatewayApplication { |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(GatewayApplication.class, args); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.config; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.autoconfigure.web.ServerProperties; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.http.HttpMethod; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
|
import org.springframework.http.server.reactive.ServerHttpResponse; |
||||
|
import org.springframework.web.cors.reactive.CorsUtils; |
||||
|
import org.springframework.web.server.ServerWebExchange; |
||||
|
import org.springframework.web.server.WebFilter; |
||||
|
import org.springframework.web.server.WebFilterChain; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
/** |
||||
|
* Cors跨域 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
public class CorsConfig { |
||||
|
|
||||
|
private static final String MAX_AGE = "18000L"; |
||||
|
|
||||
|
@Autowired |
||||
|
private ServerProperties serverProperties; |
||||
|
|
||||
|
@Bean |
||||
|
public WebFilter corsFilter() { |
||||
|
return (ServerWebExchange ctx, WebFilterChain chain) -> { |
||||
|
ServerHttpRequest request = ctx.getRequest(); |
||||
|
if (!CorsUtils.isCorsRequest(request)) { |
||||
|
return chain.filter(ctx); |
||||
|
} |
||||
|
HttpHeaders requestHeaders = request.getHeaders(); |
||||
|
ServerHttpResponse response = ctx.getResponse(); |
||||
|
HttpMethod requestMethod = requestHeaders.getAccessControlRequestMethod(); |
||||
|
HttpHeaders headers = response.getHeaders(); |
||||
|
if (!request.getURI().getPath().startsWith(serverProperties.getServlet().getContextPath().concat("/ws"))) { |
||||
|
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, requestHeaders.getOrigin()); |
||||
|
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); |
||||
|
} |
||||
|
headers.addAll(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, requestHeaders.getAccessControlRequestHeaders()); |
||||
|
if (requestMethod != null) { |
||||
|
headers.add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, requestMethod.name()); |
||||
|
} |
||||
|
headers.add(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "*"); |
||||
|
headers.add(HttpHeaders.ACCESS_CONTROL_MAX_AGE, MAX_AGE); |
||||
|
if (request.getMethod() == HttpMethod.OPTIONS) { |
||||
|
response.setStatusCode(HttpStatus.OK); |
||||
|
return Mono.empty(); |
||||
|
} |
||||
|
return chain.filter(ctx); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.config; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.config.ModuleConfig; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* 模块配置信息 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ModuleConfigImpl implements ModuleConfig { |
||||
|
@Override |
||||
|
public String getName() { |
||||
|
return "gateway"; |
||||
|
} |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.feign; |
||||
|
|
||||
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
||||
|
import com.elink.esua.epdc.feign.fallback.ResourceFeignClientFallback; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestHeader; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
|
||||
|
/** |
||||
|
* 资源接口 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_AUTH_SERVER, fallback = ResourceFeignClientFallback.class) |
||||
|
public interface ResourceFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* 是否有资源访问权限 |
||||
|
* |
||||
|
* @param token token |
||||
|
* @param url 资源URL |
||||
|
* @param method 请求方式 |
||||
|
* @return 有访问权限,则返回用户信息 |
||||
|
*/ |
||||
|
@PostMapping("auth/resource") |
||||
|
Result<UserDetail> resource(@RequestHeader(HttpHeaders.ACCEPT_LANGUAGE) String language, @RequestParam("token") String token, |
||||
|
@RequestParam("url") String url, @RequestParam("method") String method); |
||||
|
|
||||
|
/** |
||||
|
* 获取登录用户信息 |
||||
|
* |
||||
|
* @param token |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.commons.tools.security.user.CpUserDetail> |
||||
|
* @author |
||||
|
* @date 2019/8/19 17:19 |
||||
|
*/ |
||||
|
@GetMapping("auth/getLoginUserInfo") |
||||
|
Result<TokenDto> getLoginUserInfo(@RequestParam("token") String token); |
||||
|
} |
@ -0,0 +1,35 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.feign.fallback; |
||||
|
|
||||
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.feign.ResourceFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 资源接口 Fallback |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ResourceFeignClientFallback implements ResourceFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result<UserDetail> resource(String language, String token, String url, String method) { |
||||
|
return new Result<UserDetail>().error(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<TokenDto> getLoginUserInfo(String token) { |
||||
|
return new Result<TokenDto>().error(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,154 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.filter; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.elink.esua.epdc.feign.ResourceFeignClient; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain; |
||||
|
import org.springframework.cloud.gateway.filter.GlobalFilter; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.core.io.buffer.DataBuffer; |
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
|
import org.springframework.util.AntPathMatcher; |
||||
|
import org.springframework.web.server.ServerWebExchange; |
||||
|
import reactor.core.publisher.Flux; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 权限过滤器 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@ConfigurationProperties(prefix = "renren") |
||||
|
public class AuthFilter implements GlobalFilter { |
||||
|
|
||||
|
private final AntPathMatcher antPathMatcher = new AntPathMatcher(); |
||||
|
|
||||
|
@Autowired |
||||
|
private ResourceFeignClient resourceFeignClient; |
||||
|
/** |
||||
|
* 不拦截的urls |
||||
|
*/ |
||||
|
private List<String> urls; |
||||
|
|
||||
|
/** |
||||
|
* 不拦截工作端urls |
||||
|
*/ |
||||
|
private List<String> workLoginUrls; |
||||
|
|
||||
|
/** |
||||
|
* 拦截的工作端urls |
||||
|
*/ |
||||
|
private List<String> workUrls; |
||||
|
|
||||
|
@Override |
||||
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
||||
|
ServerHttpRequest request = exchange.getRequest(); |
||||
|
String requestUri = request.getPath().pathWithinApplication().value(); |
||||
|
|
||||
|
//请求放行,无需验证权限
|
||||
|
if(pathMatcher(requestUri)){ |
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
|
||||
|
//获取用户token
|
||||
|
String token = request.getHeaders().getFirst(Constant.TOKEN_HEADER); |
||||
|
if(StringUtils.isBlank(token)){ |
||||
|
token = request.getHeaders().getFirst(Constant.AUTHORIZATION_HEADER); |
||||
|
if (StringUtils.isBlank(token)) { |
||||
|
token = request.getQueryParams().getFirst(Constant.TOKEN_HEADER); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//资源访问权限
|
||||
|
String language = request.getHeaders().getFirst(HttpHeaders.ACCEPT_LANGUAGE); |
||||
|
Result<UserDetail> result = resourceFeignClient.resource(language, token, requestUri, request.getMethod().toString()); |
||||
|
//没权限访问,直接返回
|
||||
|
if(!result.success()){ |
||||
|
return response(exchange, result); |
||||
|
} |
||||
|
|
||||
|
//获取用户信息
|
||||
|
UserDetail userDetail = result.getData(); |
||||
|
if(userDetail != null){ |
||||
|
//当前登录用户userId,添加到header中
|
||||
|
ServerHttpRequest build = exchange.getRequest().mutate().header(Constant.USER_KEY, userDetail.getId()+"").build(); |
||||
|
return chain.filter(exchange.mutate().request(build).build()); |
||||
|
} |
||||
|
|
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
|
||||
|
private Mono<Void> response(ServerWebExchange exchange, Object object) { |
||||
|
String json = JSON.toJSONString(object); |
||||
|
DataBuffer buffer = exchange.getResponse().bufferFactory().wrap(json.getBytes(StandardCharsets.UTF_8)); |
||||
|
exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8); |
||||
|
exchange.getResponse().setStatusCode(HttpStatus.OK); |
||||
|
return exchange.getResponse().writeWith(Flux.just(buffer)); |
||||
|
} |
||||
|
|
||||
|
private boolean pathMatcher(String requestUri){ |
||||
|
for (String url : workLoginUrls) { |
||||
|
if(antPathMatcher.match(url, requestUri)){ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (String url : workUrls) { |
||||
|
if(antPathMatcher.match(url, requestUri)){ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (String url : urls) { |
||||
|
if(antPathMatcher.match(url, requestUri)){ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public List<String> getUrls() { |
||||
|
return urls; |
||||
|
} |
||||
|
|
||||
|
public void setUrls(List<String> urls) { |
||||
|
this.urls = urls; |
||||
|
} |
||||
|
|
||||
|
public List<String> getWorkLoginUrls() { |
||||
|
return workLoginUrls; |
||||
|
} |
||||
|
|
||||
|
public void setWorkLoginUrls(List<String> workLoginUrls) { |
||||
|
this.workLoginUrls = workLoginUrls; |
||||
|
} |
||||
|
|
||||
|
public List<String> getWorkUrls() { |
||||
|
return workUrls; |
||||
|
} |
||||
|
|
||||
|
public void setWorkUrls(List<String> workUrls) { |
||||
|
this.workUrls = workUrls; |
||||
|
} |
||||
|
} |
@ -0,0 +1,131 @@ |
|||||
|
|
||||
|
package com.elink.esua.epdc.filter; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.feign.ResourceFeignClient; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.cloud.gateway.filter.GatewayFilter; |
||||
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; |
||||
|
import org.springframework.core.io.buffer.DataBuffer; |
||||
|
import org.springframework.http.HttpHeaders; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.http.server.reactive.ServerHttpRequest; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.util.AntPathMatcher; |
||||
|
import org.springframework.web.server.ServerWebExchange; |
||||
|
import reactor.core.publisher.Flux; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* app接口权限过滤器 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component("CpAuth") |
||||
|
public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpAuthGatewayFilterFactory.CpAuthConfig> { |
||||
|
|
||||
|
@Autowired |
||||
|
private ResourceFeignClient resourceFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private CpProperty cpProperty; |
||||
|
|
||||
|
private final AntPathMatcher antPathMatcher = new AntPathMatcher(); |
||||
|
|
||||
|
@Override |
||||
|
public List<String> shortcutFieldOrder() { |
||||
|
return Arrays.asList("enabled"); |
||||
|
} |
||||
|
|
||||
|
public CpAuthGatewayFilterFactory() { |
||||
|
super(CpAuthGatewayFilterFactory.CpAuthConfig.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public GatewayFilter apply(CpAuthConfig config) { |
||||
|
return (exchange, chain) -> { |
||||
|
if (!config.isEnabled()) { |
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
|
||||
|
ServerHttpRequest request = exchange.getRequest(); |
||||
|
String requestUri = request.getPath().pathWithinApplication().value(); |
||||
|
|
||||
|
//请求放行,无需验证权限
|
||||
|
if (!pathMatcher(requestUri)) { |
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
|
||||
|
HttpHeaders headers = request.getHeaders(); |
||||
|
String token = headers.getFirst(Constant.AUTHORIZATION_HEADER); |
||||
|
if (StringUtils.isBlank(token)) { |
||||
|
token = request.getQueryParams().getFirst(Constant.AUTHORIZATION_HEADER); |
||||
|
if (StringUtils.isBlank(token)) { |
||||
|
return chain.filter(exchange); |
||||
|
} |
||||
|
} |
||||
|
Result<TokenDto> result = resourceFeignClient.getLoginUserInfo(token); |
||||
|
if (!result.success()) { |
||||
|
return response(exchange, result); |
||||
|
} |
||||
|
TokenDto user = result.getData(); |
||||
|
//当前登录用户userId,添加到header中
|
||||
|
if (user != null) { |
||||
|
ServerHttpRequest build = exchange.getRequest().mutate().header(Constant.APP_USER_KEY, user.getUserId()).build(); |
||||
|
return chain.filter(exchange.mutate().request(build).build()); |
||||
|
} |
||||
|
return chain.filter(exchange); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
private Mono<Void> response(ServerWebExchange exchange, Object object) { |
||||
|
String json = JSON.toJSONString(object); |
||||
|
DataBuffer buffer = exchange.getResponse().bufferFactory().wrap(json.getBytes(StandardCharsets.UTF_8)); |
||||
|
exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8); |
||||
|
exchange.getResponse().setStatusCode(HttpStatus.OK); |
||||
|
return exchange.getResponse().writeWith(Flux.just(buffer)); |
||||
|
} |
||||
|
|
||||
|
private boolean pathMatcher(String requestUri) { |
||||
|
for (String url : cpProperty.getSwaggerUrls()) { |
||||
|
if (antPathMatcher.match(url, requestUri)) { |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
for (String url : cpProperty.getUrls()) { |
||||
|
if (antPathMatcher.match(url, requestUri)) { |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
public static class CpAuthConfig { |
||||
|
|
||||
|
/** |
||||
|
* 控制是否开启认证 |
||||
|
*/ |
||||
|
private boolean enabled; |
||||
|
|
||||
|
public CpAuthConfig() { |
||||
|
} |
||||
|
|
||||
|
public boolean isEnabled() { |
||||
|
return enabled; |
||||
|
} |
||||
|
|
||||
|
public void setEnabled(boolean enabled) { |
||||
|
this.enabled = enabled; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.elink.esua.epdc.filter; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author rongchao |
||||
|
* @Date 19-5-17 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Component |
||||
|
@EnableConfigurationProperties |
||||
|
@ConfigurationProperties(prefix = "epdc") |
||||
|
public class CpProperty { |
||||
|
|
||||
|
private List<String> urls; |
||||
|
|
||||
|
/** |
||||
|
* 不处理token,直接通过 |
||||
|
*/ |
||||
|
private List<String> swaggerUrls; |
||||
|
|
||||
|
} |
@ -0,0 +1,286 @@ |
|||||
|
server: |
||||
|
tomcat: |
||||
|
max-swallow-size: 100MB |
||||
|
port: @server.port@ |
||||
|
servlet: |
||||
|
context-path: /epdc-api |
||||
|
|
||||
|
spring: |
||||
|
application: |
||||
|
name: epdc-gateway-server |
||||
|
#环境 dev|test|prod |
||||
|
profiles: |
||||
|
active: @spring.profiles.active@ |
||||
|
servlet: |
||||
|
multipart: |
||||
|
enabled: true |
||||
|
file-size-threshold: 0 |
||||
|
max-file-size: 100MB |
||||
|
max-request-size: 100MB |
||||
|
redis: |
||||
|
database: @spring.redis.index@ |
||||
|
host: @spring.redis.host@ |
||||
|
timeout: 30s |
||||
|
port: @spring.redis.port@ |
||||
|
password: @spring.redis.password@ |
||||
|
cloud: |
||||
|
gateway: |
||||
|
locator: |
||||
|
enabled: true |
||||
|
routes: |
||||
|
#认证服务 |
||||
|
- id: epdc-auth-server |
||||
|
uri: @gateway.routes.epdc-auth-server.uri@ |
||||
|
order: 1 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/auth/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#Admin服务 |
||||
|
- id: epdc-admin-server |
||||
|
uri: @gateway.routes.epdc-admin-server.uri@ |
||||
|
order: 2 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/sys/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#OSS服务 |
||||
|
- id: epdc-oss-server |
||||
|
uri: @gateway.routes.epdc-oss-server.uri@ |
||||
|
order: 3 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/oss/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#消息服务 |
||||
|
- id: epdc-message-server |
||||
|
uri: @gateway.routes.epdc-message-server.uri@ |
||||
|
order: 4 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/message/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#工作流服务 |
||||
|
- id: epdc-activiti-server |
||||
|
uri: @gateway.routes.epdc-activiti-server.uri@ |
||||
|
order: 5 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/activiti/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#定时任务服务 |
||||
|
- id: epdc-job-server |
||||
|
uri: @gateway.routes.epdc-job-server.uri@ |
||||
|
order: 6 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/job/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#APP流服务 |
||||
|
- id: epdc-api-server |
||||
|
uri: @gateway.routes.epdc-api-server.uri@ |
||||
|
order: 7 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/api/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
- CpAuth=true |
||||
|
#爱心互助模块 |
||||
|
- id: epdc-heart-server |
||||
|
uri: @gateway.routes.epdc-heart-server.uri@ |
||||
|
order: 8 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/heart/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#友邻社群模块 |
||||
|
- id: epdc-group-server |
||||
|
uri: @gateway.routes.epdc-group-server.uri@ |
||||
|
order: 9 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/group/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#新闻公告模块 |
||||
|
- id: epdc-news-server |
||||
|
uri: @gateway.routes.epdc-news-server.uri@ |
||||
|
order: 10 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/news/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#党群议事模块 |
||||
|
- id: epdc-events-server |
||||
|
uri: @gateway.routes.epdc-events-server.uri@ |
||||
|
order: 11 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/events/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#生活服务模块 |
||||
|
- id: epdc-services-server |
||||
|
uri: @gateway.routes.epdc-services-server.uri@ |
||||
|
order: 12 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/services/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#APP用户模块 |
||||
|
- id: epdc-user-server |
||||
|
uri: @gateway.routes.epdc-user-server.uri@ |
||||
|
order: 13 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/app-user/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#DEMO服务 |
||||
|
- id: epdc-demo-server |
||||
|
uri: @gateway.routes.epdc-demo-server.uri@ |
||||
|
order: 14 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/demo/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#websocket服务 |
||||
|
- id: epdc-websocket-server |
||||
|
uri: @gateway.routes.epdc-websocket-server.uri@ |
||||
|
order: 15 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/ws/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#绩效考核模块 |
||||
|
- id: epdc-kpi-server |
||||
|
uri: @gateway.routes.epdc-kpi-server.uri@ |
||||
|
order: 16 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/kpi/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#定制模块 |
||||
|
- id: epdc-custom-server |
||||
|
uri: @gateway.routes.epdc-custom-server.uri@ |
||||
|
order: 17 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/custom/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#积分管理 |
||||
|
- id: epdc-points-server |
||||
|
uri: @gateway.routes.epdc-points-server.uri@ |
||||
|
order: 18 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/points/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
- id: epdc-cloud-analysis-server |
||||
|
uri: @gateway.routes.epdc-cloud-analysis-server.uri@ |
||||
|
order: 19 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/cloudAnalysis/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
#工作日志 |
||||
|
- id: epdc-work-record-server |
||||
|
uri: @gateway.routes.epdc-work-record-server.uri@ |
||||
|
order: 20 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/workRecord/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
- id: epdc-analysis-server |
||||
|
uri: @gateway.routes.epdc-analysis-server.uri@ |
||||
|
order: 21 |
||||
|
predicates: |
||||
|
- Path=${server.servlet.context-path}/analysis/** |
||||
|
filters: |
||||
|
- StripPrefix=1 |
||||
|
nacos: |
||||
|
discovery: |
||||
|
server-addr: @nacos.server-addr@ |
||||
|
register-enabled: @nacos.register-enabled@ |
||||
|
ip: @nacos.ip@ |
||||
|
namespace: @nacos.namespace@ |
||||
|
zipkin: |
||||
|
# 指定了 zipkin 服务器的地址 |
||||
|
base-url: @spring.zipkin.base-url@ |
||||
|
sleuth: |
||||
|
sampler: |
||||
|
# 将采样比例设置为 1.0,也就是全部都需要。默认是 0.1 |
||||
|
probability: 1.0 |
||||
|
management: |
||||
|
endpoints: |
||||
|
web: |
||||
|
exposure: |
||||
|
include: "*" |
||||
|
endpoint: |
||||
|
health: |
||||
|
show-details: ALWAYS |
||||
|
|
||||
|
|
||||
|
feign: |
||||
|
hystrix: |
||||
|
enabled: true |
||||
|
|
||||
|
hystrix: |
||||
|
command: |
||||
|
default: |
||||
|
execution: |
||||
|
isolation: |
||||
|
thread: |
||||
|
timeoutInMilliseconds: 60000 #缺省为1000 |
||||
|
|
||||
|
ribbon: |
||||
|
ReadTimeout: 300000 |
||||
|
ConnectTimeout: 300000 |
||||
|
|
||||
|
renren: |
||||
|
urls: |
||||
|
- /auth/captcha |
||||
|
- /auth/login |
||||
|
- /*/swagger-resources/** |
||||
|
- /*/swagger-ui.html |
||||
|
- /*/webjars/** |
||||
|
- /*/v2/api-docs |
||||
|
- /*/swagger/api-docs |
||||
|
- /monitor/** |
||||
|
- /api/** |
||||
|
- /activiti/modeler.html |
||||
|
- /activiti/service/** |
||||
|
- /activiti/editor-app/** |
||||
|
- /message/sms/sendCode #发送验证码 |
||||
|
- /oss/file/download |
||||
|
- /ws/** |
||||
|
- /custom/epidemicSentryPost/downloadQRCode/** |
||||
|
workLoginUrls: |
||||
|
- /api/work/user/getToken #工作端-获取token |
||||
|
- /api/work/user/login #工作端-登录 |
||||
|
- /api/analysis/user/getToken #数据分析端-获取token |
||||
|
- /api/analysis/user/login #数据分析端-登录 |
||||
|
- /api/work/*/swagger/** |
||||
|
workUrls: |
||||
|
- /api/work/** #工作端接口 |
||||
|
- /api/analysis/** #数据端接口 |
||||
|
- /cloudAnalysis/** #数据端接口 |
||||
|
- /workRecord/** #工作日志接口 |
||||
|
|
||||
|
epdc: |
||||
|
# 党建e家接口 |
||||
|
urls: |
||||
|
- /api/** |
||||
|
# 不处理token,直接通过 |
||||
|
swaggerUrls: |
||||
|
- /api/wx/getWxConfig # 获取微信公众号配置 |
||||
|
- /api/admin/dept/completeName # 获取完整部门名称 |
||||
|
- /api/message/sms/sendCode # 发送短信验证码 |
||||
|
- /api/message/sms/registerResult # 发送用户注册审核结果 |
||||
|
- /api/events/issue/upload # 上传图片 |
||||
|
- /api/app-user/user/mp/regist # 公众号用户注册 |
||||
|
- /api/app-user/user/ma/getToken # 小程序用户 登录 |
||||
|
- /api/app-user/user/ma/regist # 小程序用户 注册 |
||||
|
- /api/app-user/user/ma/gridLeaderRegister # 小程序用户 网格长注册 |
||||
|
- /api/app-user/user/ma/v2/getToken # 小程序用户 注册或登录(版本v2) |
||||
|
- /api/work/** #工作端接口不拦截 |
||||
|
- /api/analysis/** #数据端接口不拦截 |
||||
|
- /cloudAnalysis/** #数据端接口 |
||||
|
- /workRecord/** #工作日志接口 |
@ -0,0 +1,159 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<configuration> |
||||
|
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
||||
|
|
||||
|
<property name="log.path" value="logs/gateway"/> |
||||
|
|
||||
|
<!-- 彩色日志格式 --> |
||||
|
<property name="CONSOLE_LOG_PATTERN" |
||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
||||
|
|
||||
|
<!--1. 输出到控制台--> |
||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
||||
|
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||
|
<level>debug</level> |
||||
|
</filter> |
||||
|
<encoder> |
||||
|
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
||||
|
<!-- 设置字符集 --> |
||||
|
<charset>UTF-8</charset> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<!--2. 输出到文档--> |
||||
|
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
||||
|
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/debug.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 日志归档 --> |
||||
|
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录debug级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>debug</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
||||
|
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/info.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 每天日志归档路径以及格式 --> |
||||
|
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录info级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>info</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
||||
|
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/warn.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录warn级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>warn</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
||||
|
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/error.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录ERROR级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>ERROR</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 开发、测试环境 --> |
||||
|
<springProfile name="dev,test"> |
||||
|
<logger name="org.springframework.web" level="INFO"/> |
||||
|
<logger name="org.springboot.sample" level="INFO"/> |
||||
|
<logger name="com.elink.esua.epdc" level="INFO"/> |
||||
|
<logger name="com.elink.esua.epdc.dao" level="DEBUG"/> |
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="DEBUG_FILE"/> |
||||
|
<appender-ref ref="INFO_FILE"/> |
||||
|
<appender-ref ref="WARN_FILE"/> |
||||
|
<appender-ref ref="ERROR_FILE"/> |
||||
|
</root> |
||||
|
</springProfile> |
||||
|
|
||||
|
<!-- 生产环境 --> |
||||
|
<springProfile name="prod"> |
||||
|
<logger name="org.springframework.web" level="INFO"/> |
||||
|
<logger name="org.springboot.sample" level="INFO"/> |
||||
|
<logger name="com.elink.esua.epdc" level="INFO"/> |
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="CONSOLE"/> |
||||
|
<appender-ref ref="DEBUG_FILE"/> |
||||
|
<appender-ref ref="INFO_FILE"/> |
||||
|
<appender-ref ref="WARN_FILE"/> |
||||
|
<appender-ref ref="ERROR_FILE"/> |
||||
|
</root> |
||||
|
</springProfile> |
||||
|
|
||||
|
</configuration> |
Loading…
Reference in new issue