redisTemplate;
+
+ /**
+ * 过滤方法 只要在这个方法中实现业务 验证 token
+ *
+ * 会将不拦截的请求 配置到 配置文件中
+ *
+ * @param exchange 请求的上下文 获取请求和响应对象
+ * @param chain 网关过滤器链 放行
+ * @return
+ */
+ @Override
+ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
+ // 获取系统白名单请求
+ List whites = ignoreWhitesConfig.getWhites();
+ // 判断 当前 请求是否是 白名单的请求
+ // 获取当前请求的 URI
+ ServerHttpRequest request = exchange.getRequest();
+ String path = request.getURI().getPath();
+ if (StringUtils.matches(path, whites)) {
+ // 白名单请求 放行
+ return chain.filter(exchange);
+ }
+ // 验证 token 非空
+ String token = request.getHeaders().getFirst(TokenConstants.TOKEN);
+ if (StringUtils.isBlank(token)) {
+ // 提示错误信息
+ return GatewayUtils.errorResponse(exchange, "token不能为空!");
+ }
+ // 合法性验证
+ String userKey = null;
+ try {
+ userKey = JwtUtils.getUserKey(token);
+ } catch (Exception e) {
+ return GatewayUtils.errorResponse(exchange, "token不合法!");
+ }
+ // token 有效性验证
+ // 获取 userKey
+ if (!redisTemplate.hasKey(TokenConstants.LOGIN_TOKEN_KEY + userKey)) {
+ // 提示错误信息
+ return GatewayUtils.errorResponse(exchange, "token过期!");
+ }
+ // 续期 登录在10分钟以内自动续期
+ // 获取用户的登录时间
+ String userJSON = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
+ SysUser sysUser = JSONObject.parseObject(userJSON, SysUser.class);
+ Date loginDate = sysUser.getLoginDate();
+ long min = DateUtil.between(loginDate, new Date(), DateUnit.MINUTE);
+ if (min <= 10) {
+ redisTemplate.expire(TokenConstants.LOGIN_TOKEN_KEY + userKey, 30, TimeUnit.MINUTES);
+ }
+ // 放行
+ return chain.filter(exchange);
+ }
+
+ /**
+ * 过滤器的执行顺序 【过滤器可以有多个】 返回的值越小 优先级越高
+ *
+ * @return
+ */
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+}
diff --git a/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java b/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java
new file mode 100644
index 0000000..7b789e5
--- /dev/null
+++ b/bwie-gateway/src/main/java/com/bwie/gateway/utils/GatewayUtils.java
@@ -0,0 +1,98 @@
+package com.bwie.gateway.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.bwie.common.result.Result;
+import com.bwie.common.utils.StringUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.core.io.buffer.DataBuffer;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+/**
+ * @author DongZl
+ * @description: 网关处理工具类
+ */
+@Log4j2
+public class GatewayUtils {
+ /**
+ * 添加请求头参数
+ * @param mutate 修改对象
+ * @param key 键
+ * @param value 值
+ */
+ public static void addHeader(ServerHttpRequest.Builder mutate, String key, Object value) {
+ if (StringUtils.isEmpty(key)){
+ log.warn("添加请求头参数键不可以为空");
+ return;
+ }
+ if (value == null) {
+ log.warn("添加请求头参数:[{}]值为空",key);
+ return;
+ }
+ String valueStr = value.toString();
+ mutate.header(key, valueStr);
+ log.info("添加请求头参数成功 - 键:[{}] , 值:[{}]", key , value);
+ }
+
+ /**
+ * 删除请求头参数
+ * @param mutate 修改对象
+ * @param key 键
+ */
+ public static void removeHeader(ServerHttpRequest.Builder mutate, String key) {
+ if (StringUtils.isEmpty(key)){
+ log.warn("删除请求头参数键不可以为空");
+ return;
+ }
+ mutate.headers(httpHeaders -> httpHeaders.remove(key)).build();
+ log.info("删除请求头参数 - 键:[{}]",key);
+ }
+
+ /**
+ * 错误结果响应
+ * @param exchange 响应上下文
+ * @param msg 响应消息
+ * @return
+ */
+ public static Mono errorResponse(ServerWebExchange exchange, String msg, HttpStatus httpStatus) {
+ ServerHttpResponse response = exchange.getResponse();
+ //设置HTTP响应头状态
+ response.setStatusCode(httpStatus);
+ //设置HTTP响应头文本格式
+ response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
+ //定义响应内容
+ Result> result = Result.error(msg);
+ String resultJson = JSONObject.toJSONString(result);
+ log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
+ DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
+ //进行响应
+ return response.writeWith(Mono.just(dataBuffer));
+ }
+
+ /**
+ * 错误结果响应
+ * @param exchange 响应上下文
+ * @param msg 响应消息
+ * @return
+ */
+ public static Mono errorResponse(ServerWebExchange exchange, String msg) {
+ ServerHttpResponse response = exchange.getResponse();
+ //设置HTTP响应头状态
+ response.setStatusCode(HttpStatus.OK);
+ //设置HTTP响应头文本格式
+ response.getHeaders().add(HttpHeaders.CONTENT_TYPE, "application/json");
+ //定义响应内容
+ Result> result = Result.error(msg);
+ String resultJson = JSONObject.toJSONString(result);
+ log.error("[鉴权异常处理]请求路径:[{}],异常信息:[{}],响应结果:[{}]", exchange.getRequest().getPath(), msg, resultJson);
+ DataBuffer dataBuffer = response.bufferFactory().wrap(resultJson.getBytes());
+ //进行响应
+ return response.writeWith(Mono.just(dataBuffer));
+ }
+
+
+}
diff --git a/bwie-gateway/src/main/resources/bootstrap.yml b/bwie-gateway/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..bcfbb22
--- /dev/null
+++ b/bwie-gateway/src/main/resources/bootstrap.yml
@@ -0,0 +1,31 @@
+# Tomcat
+server:
+ port: 18080
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: bwie-gateway
+ profiles:
+ # 环境配置
+ active: dev
+ main:
+ # 允许使用循环引用
+ allow-circular-references: true
+ # 允许定义相同的bean对象 去覆盖原有的
+ allow-bean-definition-overriding: true
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.223.114.120:8848
+ namespace: 00f412e2-0405-407b-a17e-0f5b2528f0fa
+ config:
+ # 配置中心地址
+ server-addr: 124.223.114.120:8848
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ namespace: 00f412e2-0405-407b-a17e-0f5b2528f0fa
\ No newline at end of file
diff --git a/bwie-modules/.gitignore b/bwie-modules/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/bwie-modules/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/bwie-modules/bwie-system/.gitignore b/bwie-modules/bwie-system/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/bwie-modules/bwie-system/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/bwie-modules/bwie-system/pom.xml b/bwie-modules/bwie-system/pom.xml
new file mode 100644
index 0000000..8956092
--- /dev/null
+++ b/bwie-modules/bwie-system/pom.xml
@@ -0,0 +1,62 @@
+
+
+ 4.0.0
+
+ com.bwie
+ bwie-modules
+ 1.0-SNAPSHOT
+
+
+ bwie-system
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+ com.bwie
+ bwie-common-core
+
+
+ javax.servlet
+ servlet-api
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+
+
+
+ com.bwie
+ bwie-common-log
+
+
+
diff --git a/bwie-modules/bwie-system/src/main/resources/bootstrap.yml b/bwie-modules/bwie-system/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..2ebec53
--- /dev/null
+++ b/bwie-modules/bwie-system/src/main/resources/bootstrap.yml
@@ -0,0 +1,43 @@
+# Tomcat
+server:
+ port: 9002
+# Spring
+spring:
+ main:
+ allow-circular-references: true
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ # 应用名称
+ name: bwie-user
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: 124.223.114.120:8848
+ namespace: 00f412e2-0405-407b-a17e-0f5b2528f0fa
+ config:
+ # 配置中心地址
+ server-addr: 124.223.114.120:8848
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ namespace: 00f412e2-0405-407b-a17e-0f5b2528f0fa
+fdfs:
+ so-timeout: 1500 # socket 连接时长
+ connect-timeout: 600 # 连接 tracker 服务器超时时长
+ # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
+ tracker-list: 124.223.114.120:22122
+ web-server-url: 124.223.114.120:8888
+ pool:
+ jmx-enabled: false
+ # 生成缩略图
+ thumb-image:
+ height: 500
+ width: 500
\ No newline at end of file
diff --git a/bwie-modules/pom.xml b/bwie-modules/pom.xml
new file mode 100644
index 0000000..d28dec8
--- /dev/null
+++ b/bwie-modules/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ com.bwie
+ day15-1
+ 1.0-SNAPSHOT
+
+
+ bwie-modules
+ pom
+
+ bwie-system
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..31ed86b
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,144 @@
+
+
+ 4.0.0
+
+ com.bwie
+ day15-1
+ 1.0-SNAPSHOT
+ pom
+
+ bwie-common
+ bwie-auth
+ bwie-api
+ bwie-gateway
+ bwie-modules
+
+
+
+ 8
+ 8
+ UTF-8
+ 2.6.2
+ 2021.0.0
+ 2021.1
+ 2.0.4
+ 1.0-SNAPSHOT
+ 0.9.1
+ 1.2.80
+ 5.8.3
+ 2.0.1
+ 1.2.8
+ 2.2.2
+ 1.4.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
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+
+ com.alibaba.nacos
+ nacos-client
+ ${nacos-client.version}
+
+
+
+ com.bwie
+ bwie-common
+ ${bwie-common.version}
+
+
+
+ io.jsonwebtoken
+ jjwt
+ ${jjwt.version}
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+ cn.hutool
+ hutool-all
+ ${hutool-all.version}
+
+
+
+ com.aliyun
+ dysmsapi20170525
+ ${dysmsapi.version}
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.version}
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ ${mybatis.version}
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ ${pagehelper.version}
+
+
+
+ javax.servlet
+ servlet-api
+ 2.5
+
+
+
+ com.bwie
+ bwie-system-api
+ 1.0-SNAPSHOT
+
+
+
+ com.bwie
+ bwie-common-core
+ 1.0-SNAPSHOT
+
+
+ com.bwie
+ bwie-common-log
+ 1.0-SNAPSHOT
+
+
+
+
+