style: 代码初始化
parent
10341472e9
commit
1dce28afa3
|
@ -2,16 +2,16 @@
|
|||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu</artifactId>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>muyu-gateway</artifactId>
|
||||
<artifactId>couplet-gateway</artifactId>
|
||||
|
||||
<description>
|
||||
muyu-gateway网关模块
|
||||
couplet-gateway网关模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
@ -72,8 +72,8 @@
|
|||
|
||||
<!-- MuYu Common Redis-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-redis</artifactId>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway;
|
||||
package com.couplet.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||
/**
|
||||
* 网关启动程序
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||
public class MuYuGatewayApplication {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config;
|
||||
package com.couplet.gateway.config;
|
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||
import com.google.code.kaptcha.util.Config;
|
||||
|
@ -12,7 +12,7 @@ import static com.google.code.kaptcha.Constants.*;
|
|||
/**
|
||||
* 验证码配置
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
public class CaptchaConfig {
|
||||
|
@ -62,7 +62,7 @@ public class CaptchaConfig {
|
|||
// KAPTCHA_SESSION_KEY
|
||||
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCodeMath");
|
||||
// 验证码文本生成器
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.muyu.gateway.config.KaptchaTextCreator");
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_IMPL, "com.couplet.gateway.config.KaptchaTextCreator");
|
||||
// 验证码文本字符间距 默认为2
|
||||
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_SPACE, "3");
|
||||
// 验证码文本字符长度 默认为5
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.gateway.config;
|
||||
package com.couplet.gateway.config;
|
||||
|
||||
import com.muyu.gateway.handler.SentinelFallbackHandler;
|
||||
import com.couplet.gateway.handler.SentinelFallbackHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
|
@ -9,7 +9,7 @@ import org.springframework.core.annotation.Order;
|
|||
/**
|
||||
* 网关限流配置
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
public class GatewayConfig {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config;
|
||||
package com.couplet.gateway.config;
|
||||
|
||||
import com.google.code.kaptcha.text.impl.DefaultTextCreator;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import java.util.Random;
|
|||
/**
|
||||
* 验证码文本生成器
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
public class KaptchaTextCreator extends DefaultTextCreator {
|
||||
private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(",");
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.gateway.config;
|
||||
package com.couplet.gateway.config;
|
||||
|
||||
import com.muyu.gateway.handler.ValidateCodeHandler;
|
||||
import com.couplet.gateway.handler.ValidateCodeHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -12,7 +12,7 @@ import org.springframework.web.reactive.function.server.RouterFunctions;
|
|||
/**
|
||||
* 路由配置信息
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
public class RouterFunctionConfiguration {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config;
|
||||
package com.couplet.gateway.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.config.GatewayProperties;
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
|||
/**
|
||||
* 聚合系统接口
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigurer {
|
||||
|
@ -52,7 +52,7 @@ public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigu
|
|||
.contains(routeDefinition.getId()))
|
||||
.forEach(routeDefinition -> routeDefinition.getPredicates().stream()
|
||||
.filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
|
||||
.filter(predicateDefinition -> !"muyu-auth".equalsIgnoreCase(routeDefinition.getId()))
|
||||
.filter(predicateDefinition -> !"couplet-auth".equalsIgnoreCase(routeDefinition.getId()))
|
||||
.forEach(predicateDefinition -> resourceList
|
||||
.add(swaggerResource(routeDefinition.getId(), predicateDefinition.getArgs()
|
||||
.get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", SWAGGER2URL)))));
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config.properties;
|
||||
package com.couplet.gateway.config.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
/**
|
||||
* 验证码配置
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config.properties;
|
||||
package com.couplet.gateway.config.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
/**
|
||||
* 放行白名单配置
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.config.properties;
|
||||
package com.couplet.gateway.config.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
/**
|
||||
* XSS跨站脚本配置
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Configuration
|
||||
@RefreshScope
|
|
@ -1,14 +1,14 @@
|
|||
package com.muyu.gateway.filter;
|
||||
package com.couplet.gateway.filter;
|
||||
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.HttpStatus;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.constant.TokenConstants;
|
||||
import com.muyu.common.core.utils.JwtUtils;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.gateway.config.properties.IgnoreWhiteProperties;
|
||||
import com.couplet.common.core.constant.CacheConstants;
|
||||
import com.couplet.common.core.constant.HttpStatus;
|
||||
import com.couplet.common.core.constant.SecurityConstants;
|
||||
import com.couplet.common.core.constant.TokenConstants;
|
||||
import com.couplet.common.core.utils.JwtUtils;
|
||||
import com.couplet.common.core.utils.ServletUtils;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.gateway.config.properties.IgnoreWhiteProperties;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -24,7 +24,7 @@ import reactor.core.publisher.Mono;
|
|||
/**
|
||||
* 网关鉴权
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class AuthFilter implements GlobalFilter, Ordered {
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.gateway.filter;
|
||||
package com.couplet.gateway.filter;
|
||||
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.couplet.common.core.utils.ServletUtils;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -12,7 +12,7 @@ import java.util.regex.Pattern;
|
|||
/**
|
||||
* 黑名单过滤器
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.filter;
|
||||
package com.couplet.gateway.filter;
|
||||
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
|||
/**
|
||||
* 获取body请求数据(解决流不能重复读取问题)
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class CacheRequestFilter extends AbstractGatewayFilterFactory<CacheRequestFilter.Config> {
|
|
@ -1,11 +1,11 @@
|
|||
package com.muyu.gateway.filter;
|
||||
package com.couplet.gateway.filter;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.gateway.config.properties.CaptchaProperties;
|
||||
import com.muyu.gateway.service.ValidateCodeService;
|
||||
import com.couplet.common.core.utils.ServletUtils;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.gateway.config.properties.CaptchaProperties;
|
||||
import com.couplet.gateway.service.ValidateCodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||
|
@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
/**
|
||||
* 验证码过滤器
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
|
@ -1,8 +1,8 @@
|
|||
package com.muyu.gateway.filter;
|
||||
package com.couplet.gateway.filter;
|
||||
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.html.EscapeUtil;
|
||||
import com.muyu.gateway.config.properties.XssProperties;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.utils.html.EscapeUtil;
|
||||
import com.couplet.gateway.config.properties.XssProperties;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
|
@ -25,7 +25,7 @@ import java.nio.charset.StandardCharsets;
|
|||
/**
|
||||
* 跨站脚本过滤器
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
|
@ -1,6 +1,6 @@
|
|||
package com.muyu.gateway.handler;
|
||||
package com.couplet.gateway.handler;
|
||||
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.couplet.common.core.utils.ServletUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
|
||||
|
@ -15,7 +15,7 @@ import reactor.core.publisher.Mono;
|
|||
/**
|
||||
* 网关统一异常处理
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Order(-1)
|
||||
@Configuration
|
|
@ -1,8 +1,8 @@
|
|||
package com.muyu.gateway.handler;
|
||||
package com.couplet.gateway.handler;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
|
||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.couplet.common.core.utils.ServletUtils;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebExceptionHandler;
|
||||
|
@ -11,7 +11,7 @@ import reactor.core.publisher.Mono;
|
|||
/**
|
||||
* 自定义限流异常处理
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
public class SentinelFallbackHandler implements WebExceptionHandler {
|
||||
private Mono<Void> writeResponse (ServerResponse response, ServerWebExchange exchange) {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.handler;
|
||||
package com.couplet.gateway.handler;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
|
@ -1,8 +1,8 @@
|
|||
package com.muyu.gateway.handler;
|
||||
package com.couplet.gateway.handler;
|
||||
|
||||
import com.muyu.common.core.exception.CaptchaException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.gateway.service.ValidateCodeService;
|
||||
import com.couplet.common.core.exception.CaptchaException;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.gateway.service.ValidateCodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -17,7 +17,7 @@ import java.io.IOException;
|
|||
/**
|
||||
* 验证码获取
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
|
@ -1,4 +1,4 @@
|
|||
package com.muyu.gateway.model.resp;
|
||||
package com.couplet.gateway.model.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
|
@ -1,14 +1,14 @@
|
|||
package com.muyu.gateway.service;
|
||||
package com.couplet.gateway.service;
|
||||
|
||||
import com.muyu.common.core.exception.CaptchaException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.couplet.common.core.exception.CaptchaException;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 验证码处理
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
public interface ValidateCodeService {
|
||||
/**
|
|
@ -1,17 +1,17 @@
|
|||
package com.muyu.gateway.service.impl;
|
||||
package com.couplet.gateway.service.impl;
|
||||
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import com.muyu.common.core.constant.CacheConstants;
|
||||
import com.muyu.common.core.constant.Constants;
|
||||
import com.muyu.common.core.exception.CaptchaException;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.sign.Base64;
|
||||
import com.muyu.common.core.utils.uuid.IdUtils;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.gateway.config.properties.CaptchaProperties;
|
||||
import com.muyu.gateway.model.resp.CaptchaCodeResp;
|
||||
import com.muyu.gateway.service.ValidateCodeService;
|
||||
import com.couplet.common.core.constant.CacheConstants;
|
||||
import com.couplet.common.core.constant.Constants;
|
||||
import com.couplet.common.core.exception.CaptchaException;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.utils.sign.Base64;
|
||||
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.gateway.config.properties.CaptchaProperties;
|
||||
import com.couplet.gateway.model.resp.CaptchaCodeResp;
|
||||
import com.couplet.gateway.service.ValidateCodeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||
/**
|
||||
* 验证码实现处理
|
||||
*
|
||||
* @author muyu
|
||||
* @author couplet
|
||||
*/
|
||||
@Service
|
||||
public class ValidateCodeServiceImpl implements ValidateCodeService {
|
|
@ -6,7 +6,7 @@ server:
|
|||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: muyu-gateway
|
||||
name: couplet-gateway
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
|
@ -34,7 +34,7 @@ spring:
|
|||
ds1:
|
||||
nacos:
|
||||
server-addr: 127.0.0.1:8848
|
||||
dataId: sentinel-muyu-gateway
|
||||
dataId: sentinel-couplet-gateway
|
||||
groupId: DEFAULT_GROUP
|
||||
data-type: json
|
||||
rule-type: gw-flow
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/muyu-gateway"/>
|
||||
<property name="log.path" value="logs/couplet-gateway"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
|||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<logger name="com.couplet" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue