From de9f41c05e67d75919e0e1803e1c11339e36c7d7 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sat, 14 Sep 2024 14:28:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9A=E7=BD=91=E5=85=B3=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skyeye-promote/skyeye-common/pom.xml | 16 +++ .../src/main/java/com/SkyShopApplication.java | 5 - skyeye-zuul/pom.xml | 118 +----------------- .../main/java/com/SkyeyeZuulApplication.java | 10 +- .../config/MyWebMvcConfigurerAdapter.java | 3 +- .../com/skyeye/filter/SkyeyeZuulFilter.java | 112 +++++------------ skyeye-zuul/src/main/resources/bootstrap.yml | 86 ++++++++++++- .../src/main/resources/log4j.properties | 3 + 8 files changed, 141 insertions(+), 212 deletions(-) create mode 100644 skyeye-zuul/src/main/resources/log4j.properties diff --git a/skyeye-promote/skyeye-common/pom.xml b/skyeye-promote/skyeye-common/pom.xml index 4493da42..63ac5736 100644 --- a/skyeye-promote/skyeye-common/pom.xml +++ b/skyeye-promote/skyeye-common/pom.xml @@ -22,6 +22,22 @@ 1.0-SNAPSHOT + + com.github.binarywang + weixin-java-pay + ${weixin-java.version} + + + com.github.binarywang + wx-java-mp-spring-boot-starter + ${weixin-java.version} + + + com.github.binarywang + wx-java-miniapp-spring-boot-starter + ${weixin-java.version} + + diff --git a/skyeye-shop/shop-web/src/main/java/com/SkyShopApplication.java b/skyeye-shop/shop-web/src/main/java/com/SkyShopApplication.java index 30ae4070..78e9bfd5 100644 --- a/skyeye-shop/shop-web/src/main/java/com/SkyShopApplication.java +++ b/skyeye-shop/shop-web/src/main/java/com/SkyShopApplication.java @@ -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); diff --git a/skyeye-zuul/pom.xml b/skyeye-zuul/pom.xml index e0be3e6c..df9533c7 100644 --- a/skyeye-zuul/pom.xml +++ b/skyeye-zuul/pom.xml @@ -4,6 +4,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + com.skyeye + skyeye-parent + 1.0-SNAPSHOT + + com.skyeye skyeye-zuul 1.0-SNAPSHOT @@ -11,132 +17,20 @@ 8 8 - - 2.7.18 - 2021.0.9 - 2021.0.6.1 - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${alibaba-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - - org.springframework.boot - spring-boot-starter-web - - - mysql - mysql-connector-java - - - - org.springframework.cloud spring-cloud-starter-gateway - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - - - org.springframework.boot - spring-boot-devtools - true - true - - - - org.freemarker - freemarker - - - - cn.hutool - hutool-json - 5.5.4 - - - - - net.sf.json-lib - json-lib - 2.4 - jdk15 - - ${project.artifactId} - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.2 - - org.apache.maven.plugins diff --git a/skyeye-zuul/src/main/java/com/SkyeyeZuulApplication.java b/skyeye-zuul/src/main/java/com/SkyeyeZuulApplication.java index 889c1805..60a0497c 100644 --- a/skyeye-zuul/src/main/java/com/SkyeyeZuulApplication.java +++ b/skyeye-zuul/src/main/java/com/SkyeyeZuulApplication.java @@ -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); } diff --git a/skyeye-zuul/src/main/java/com/skyeye/config/MyWebMvcConfigurerAdapter.java b/skyeye-zuul/src/main/java/com/skyeye/config/MyWebMvcConfigurerAdapter.java index e70bae85..51cd893c 100644 --- a/skyeye-zuul/src/main/java/com/skyeye/config/MyWebMvcConfigurerAdapter.java +++ b/skyeye-zuul/src/main/java/com/skyeye/config/MyWebMvcConfigurerAdapter.java @@ -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);// 跨域允许时间 } diff --git a/skyeye-zuul/src/main/java/com/skyeye/filter/SkyeyeZuulFilter.java b/skyeye-zuul/src/main/java/com/skyeye/filter/SkyeyeZuulFilter.java index 510da309..70ccb8db 100644 --- a/skyeye-zuul/src/main/java/com/skyeye/filter/SkyeyeZuulFilter.java +++ b/skyeye-zuul/src/main/java/com/skyeye/filter/SkyeyeZuulFilter.java @@ -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 METHOD_LIST = Arrays.asList("GET", "POST", "PUT", "DELETE"); - /** - * 过滤器的类型,它决定过滤器在请求的哪个生命周期中执行。 这里定义为pre,代表会在请求被路由之前执行。 - * - * @return - */ @Override - public String filterType() { - return "pre"; + public Mono 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 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 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; - } - } diff --git a/skyeye-zuul/src/main/resources/bootstrap.yml b/skyeye-zuul/src/main/resources/bootstrap.yml index 86e54c1e..c1c33af5 100644 --- a/skyeye-zuul/src/main/resources/bootstrap.yml +++ b/skyeye-zuul/src/main/resources/bootstrap.yml @@ -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} # 配置命名空间 \ No newline at end of file + 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 \ No newline at end of file diff --git a/skyeye-zuul/src/main/resources/log4j.properties b/skyeye-zuul/src/main/resources/log4j.properties new file mode 100644 index 00000000..c7ee4dce --- /dev/null +++ b/skyeye-zuul/src/main/resources/log4j.properties @@ -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 From e32c20b012bed8e4ae0456ed8f25a410f3792638 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sat, 14 Sep 2024 15:19:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20xxl-job=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xxl-job-2.3.0/xxl-job-admin/pom.xml | 5 +++++ xxl-job-2.3.0/xxl-job-admin/src/main/resources/bootstrap.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xxl-job-2.3.0/xxl-job-admin/pom.xml b/xxl-job-2.3.0/xxl-job-admin/pom.xml index 37c137d3..3561b778 100644 --- a/xxl-job-2.3.0/xxl-job-admin/pom.xml +++ b/xxl-job-2.3.0/xxl-job-admin/pom.xml @@ -63,6 +63,11 @@ spring-boot-starter-mail + + org.springframework.cloud + spring-cloud-starter-bootstrap + + org.springframework.boot diff --git a/xxl-job-2.3.0/xxl-job-admin/src/main/resources/bootstrap.yml b/xxl-job-2.3.0/xxl-job-admin/src/main/resources/bootstrap.yml index 6336424a..c2bf87d7 100644 --- a/xxl-job-2.3.0/xxl-job-admin/src/main/resources/bootstrap.yml +++ b/xxl-job-2.3.0/xxl-job-admin/src/main/resources/bootstrap.yml @@ -12,7 +12,7 @@ spring: repositories: enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 profiles: - active: public + active: dev cloud: nacos: discovery: