mirror of
https://github.com/weizhiqiang1995/erp-pro.git
synced 2025-03-03 19:03:11 +08:00
Merge branch 'company_server' of https://gitee.com/doc_wei01/skyeye into company_server
This commit is contained in:
commit
39125da0b8
10 changed files with 147 additions and 213 deletions
|
@ -22,6 +22,22 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-pay</artifactId>
|
||||
<version>${weixin-java.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-mp-spring-boot-starter</artifactId>
|
||||
<version>${weixin-java.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId>
|
||||
<version>${weixin-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
package com;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
@ -24,9 +22,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
@EnableFeignClients
|
||||
public class SkyShopApplication {
|
||||
|
||||
@Value("${IMAGES_PATH}")
|
||||
private String tPath;
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(SkyShopApplication.class, args);
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
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.skyeye</groupId>
|
||||
<artifactId>skyeye-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.skyeye</groupId>
|
||||
<artifactId>skyeye-zuul</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
@ -11,132 +17,20 @@
|
|||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
||||
<spring-boot.version>2.7.18</spring-boot.version>
|
||||
<spring-cloud.version>2021.0.9</spring-cloud.version>
|
||||
<alibaba-cloud.version>2021.0.6.1</alibaba-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<!--SpringBoot整合Spring Cloud-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--SpringBoot整合Spring Cloud Alibaba-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>${alibaba-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringBoot相关配置 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置中心注册到nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 服务注册到nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud alibaba sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 服务调用 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--热更新,热加载,不用每次重启启动 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
<scope>true</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-json</artifactId>
|
||||
<version>5.5.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- json-lib -->
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.sonarsource.scanner.maven</groupId>
|
||||
<artifactId>sonar-maven-plugin</artifactId>
|
||||
<version>3.2</version>
|
||||
</plugin>
|
||||
|
||||
<!-- 资源文件拷贝插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
@ -4,20 +4,22 @@
|
|||
|
||||
package com;
|
||||
|
||||
import org.nutz.plugin.spring.boot.NutzDaoAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
NutzDaoAutoConfiguration.class
|
||||
})
|
||||
@ComponentScan(basePackages = {"com.skyeye"})
|
||||
@EnableDiscoveryClient // 开启服务发现
|
||||
@EnableZuulProxy
|
||||
public class SkyeyeZuulApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(SkyeyeZuulApplication.class, args);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {
|
|||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")// 设置允许跨域的路径
|
||||
.allowedOrigins("*")// 设置允许跨域请求的域名
|
||||
.allowedOriginPatterns("*")// 设置允许跨域请求的域名
|
||||
.allowCredentials(true)// 是否允许证书 不再默认开启
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE")// 设置允许的方法
|
||||
.allowedHeaders("*")// 设置允许头部
|
||||
.maxAge(3600);// 跨域允许时间
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,17 @@
|
|||
|
||||
package com.skyeye.filter;
|
||||
|
||||
import com.netflix.zuul.ZuulFilter;
|
||||
import com.netflix.zuul.context.RequestContext;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -23,92 +26,33 @@ import java.util.List;
|
|||
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
|
||||
*/
|
||||
@Component
|
||||
public class SkyeyeZuulFilter extends ZuulFilter {
|
||||
public class SkyeyeZuulFilter implements GlobalFilter, Ordered {
|
||||
|
||||
private static final List<String> METHOD_LIST = Arrays.asList("GET", "POST", "PUT", "DELETE");
|
||||
|
||||
/**
|
||||
* 过滤器的类型,它决定过滤器在请求的哪个生命周期中执行。 这里定义为pre,代表会在请求被路由之前执行。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String filterType() {
|
||||
return "pre";
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
// 1.获取请求对象
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
// 2.获取响应对象
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
|
||||
String method = request.getMethod().name().toUpperCase();
|
||||
if (!METHOD_LIST.contains(method)) {
|
||||
response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED);
|
||||
return response.setComplete();
|
||||
}
|
||||
String uri = request.getURI().getPath();
|
||||
if (uri.contains("/images/")) {
|
||||
response.setStatusCode(HttpStatus.NOT_FOUND);
|
||||
return response.setComplete();
|
||||
}
|
||||
// 放行
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
/**
|
||||
* filter执行顺序,通过数字指定。 数字越大,优先级越低。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int filterOrder() {
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断该过滤器是否需要被执行。这里我们直接返回了true,因此该过滤器对所有请求都会生效。 实际运用中我们可以利用该函数来指定过滤器的有效范围。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldFilter() {
|
||||
String method = RequestContext.getCurrentContext().getRequest().getMethod().toUpperCase();
|
||||
if (!METHOD_LIST.contains(method)) {
|
||||
return false;
|
||||
}
|
||||
HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
if (uri.contains("/images/")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤器的具体逻辑
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object run() {
|
||||
// 获取currentContext
|
||||
RequestContext currentContext = RequestContext.getCurrentContext();
|
||||
// 获取响应对象
|
||||
HttpServletResponse response = currentContext.getResponse();
|
||||
// 设置响应格式
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
|
||||
HttpServletRequest request = RequestContext.getCurrentContext().getRequest();
|
||||
System.err.println("REQUEST:: @@START@@ " + request.getSession().getId());
|
||||
System.err.println("REQUEST:: " + request.getScheme() + " " + request.getRemoteAddr() + ":" + request.getRemotePort());
|
||||
System.err.println("REQUEST:: " + request.getScheme() + " " + request.getRemoteAddr() + ":" + request.getRemotePort());
|
||||
StringBuilder params = new StringBuilder("?");
|
||||
Enumeration<String> names = request.getParameterNames();
|
||||
if (request.getMethod().equals("GET")) {
|
||||
while (names.hasMoreElements()) {
|
||||
String name = names.nextElement();
|
||||
params.append(name);
|
||||
params.append("=");
|
||||
params.append(request.getParameter(name));
|
||||
params.append("&");
|
||||
}
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
params.delete(params.length() - 1, params.length());
|
||||
}
|
||||
System.err.println("REQUEST:: > " + request.getMethod() + " " + request.getRequestURI() + params + " " + request.getProtocol());
|
||||
Enumeration<String> headers = request.getHeaderNames();
|
||||
while (headers.hasMoreElements()) {
|
||||
String name = headers.nextElement();
|
||||
String value = request.getHeader(name);
|
||||
System.err.println("REQUEST:: > " + name + ":" + value);
|
||||
}
|
||||
System.err.println("REQUEST:: @@END@@ " + request.getSession().getId());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,7 @@ spring:
|
|||
name: skyeye-zuul-${spring.profiles.active} # 服务名
|
||||
main:
|
||||
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
|
||||
allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务
|
||||
data:
|
||||
redis:
|
||||
repositories:
|
||||
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
||||
web-application-type: reactive
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
|
@ -26,4 +22,82 @@ spring:
|
|||
# 配置文件后缀
|
||||
file-extension: yml
|
||||
# 命名空间 常用场景之一是不同环境的配置的区分隔离,例如开发测试环境和生产环境的资源(如配置、服务)隔离等
|
||||
namespace: ${spring.profiles.active} # 配置命名空间
|
||||
namespace: ${spring.profiles.active} # 配置命名空间
|
||||
# 支持多个共享 Data Id 的配置,优先级小于ext-config,自定义 Data Id 配置 属性是个集合,内部由 Config POJO 组成。Config 有 3 个属性,分别是 dataId, group 以及 refresh
|
||||
ext-config:
|
||||
- data-id: skyeye-common.yml # 配置文件名-Data Id
|
||||
group: DEFAULT_GROUP # 默认为DEFAULT_GROUP
|
||||
refresh: false # 是否动态刷新,默认为false
|
||||
gateway:
|
||||
routes:
|
||||
- id: fileBase #路由的ID,没有固定规则但要求唯一,建议配合服务名
|
||||
uri: lb://skyeye-pro-${spring.profiles.active} #匹配后提供服务的路由地址
|
||||
predicates:
|
||||
- Path=/fileBase/** # 断言,路径相匹配的进行路由
|
||||
- id: reqBase
|
||||
uri: lb://skyeye-pro-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/reqBase/**
|
||||
- id: shop
|
||||
uri: lb://skyeye-shop-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/shop/**
|
||||
- id: flowable
|
||||
uri: lb://skyeye-flowable-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/flowable/**
|
||||
- id: school
|
||||
uri: lb://skyeye-school-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/school/**
|
||||
- id: report
|
||||
uri: lb://skyeye-report-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/report/**
|
||||
- id: adm
|
||||
uri: lb://skyeye-adm-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/adm/**,/survey/**,/note/**,/knowlg/**,/mail/**,/diskCloud/**,/email/**,/notice/**,/businessFlow/**,/forum/**,/jobdiary/**,/ehr/**,/lightApp/**
|
||||
- id: schedule
|
||||
uri: lb://skyeye-schedule-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/schedule/**
|
||||
- id: wages
|
||||
uri: lb://skyeye-wages-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/wages/**
|
||||
- id: crm
|
||||
uri: lb://skyeye-crm-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/crm/**
|
||||
- id: ifs
|
||||
uri: lb://skyeye-ifs-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/ifs/**
|
||||
- id: erp
|
||||
uri: lb://skyeye-erp-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/erp/**
|
||||
- id: boss
|
||||
uri: lb://skyeye-boss-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/boss/**
|
||||
- id: checkwork
|
||||
uri: lb://skyeye-checkwork-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/checkwork/**
|
||||
- id: sealService
|
||||
uri: lb://skyeye-seal-service-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/sealService/**
|
||||
- id: wall
|
||||
uri: lb://skyeye-wall-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/wall/**
|
||||
- id: tms
|
||||
uri: lb://skyeye-tms-${spring.profiles.active}
|
||||
predicates:
|
||||
- Path=/tms/**
|
||||
logging:
|
||||
level:
|
||||
com: debug
|
3
skyeye-zuul/src/main/resources/log4j.properties
Normal file
3
skyeye-zuul/src/main/resources/log4j.properties
Normal file
|
@ -0,0 +1,3 @@
|
|||
log4j.rootLogger=INFO, A1
|
||||
log4j.appender.A1=org.apache.logging.log4j.core.appender.ConsoleAppender
|
||||
log4j.appender.A1.layout=org.apache.logging.log4j.core.layout.PatternLayout
|
|
@ -63,6 +63,11 @@
|
|||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- starter-actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
|
|
@ -12,7 +12,7 @@ spring:
|
|||
repositories:
|
||||
enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度
|
||||
profiles:
|
||||
active: public
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
|
|
Loading…
Reference in a new issue