|
|
2 年之前 | |
|---|---|---|
| db | 2 年之前 | |
| drone | 2 年之前 | |
| kxs-common | 2 年之前 | |
| kxs-gateway | 2 年之前 | |
| kxs-product | 2 年之前 | |
| kxs-quartz | 2 年之前 | |
| kxs-store | 2 年之前 | |
| kxs-system | 2 年之前 | |
| kxs-transfer | 2 年之前 | |
| kxs-user | 2 年之前 | |
| kxs-visual | 2 年之前 | |
| .drone.yml | 2 年之前 | |
| .gitignore | 2 年之前 | |
| 1700399839501.jpg | 2 年之前 | |
| LICENSE | 2 年之前 | |
| README.md | 2 年之前 | |
| docker-compose.yml | 2 年之前 | |
| install.txt | 2 年之前 | |
| pom.xml | 2 年之前 |
可无缝对接nacos、dubbo、spring-cloud
| Jdk | 17 |
|---|---|
| Spring Boot | 3.1.5 |
| Mybatis Plus | 3.5.4 |
| hutool | 5.8.2 |
| Spring Authorization Server | 1.1.3 |
kxs
└── kxs-admin-ui-- 后台管理页面
└── kxs-codegen-- 代码生成模块[4002]
└── kxs-common -- 系统公共模块
├── kxs-common-core -- 公共工具核心包
├── kxs-common-datasource -- 动态数据源
├── kxs-common-log -- 异步日志服务
├── kxs-common-mybatis -- mybatis 扩展封装
├── kxs-common-security -- oauth2 工具包 鉴权登录
├── kxs-gateway -- Gateway网关[9999]
├── kxs-quartz-- 定时任务模块[4000]
└── kxs-system-- 通用用户权限管理模块
└── kxs-system-api -- 通用用户权限管理系统公共api模块
└── kxs-system-biz -- 通用用户权限管理系统业务处理模块[8080]
导入db文件下的sql语句
开启本地redis
### 后端启动
1.kxs-gateway/KxsGatewayApplication.java
2.kxs-system-biz/KxsAdminApplication.java
3.kxs-codegen/KxsCodeGenApplication.java 代码生成按需启动
4.kxs-quartz/KxsQuartzApplication.java 定时任务按需启动
# 检查node版本 = 16
node -v
# 若高版本node 可执行n 命令切换至 16 版本
n 16.17.1
# 切换到kxs-admin-ui目录下依次执行
npm install --registry=https://registry.npmmirror.com
npm run dev
浏览器访问: http://localhost:8888
默认用户名: admin
默认密码: 123456
网关采用的是spring官方的网关组件,通过异步背压的高性能网关。路由配置是整个架构最为核心的功能
网关内置了图形验证码以及验证逻辑,基于webflux 响应式接口实现
路由及限流配置
routes:
#ADMIN 模块
- id: kxs-system-biz # 唯一的服务ID
uri: lb://kxs-system-biz # instances下的服务名称,实现负载均衡
predicates:
- Path=/v1/kxs/admin/** #当前服务的请求前缀,
filters:
# 过滤前缀
- StripPrefix=3
# 限流配置
- name: RequestRateLimiter
args:
key-resolver: '#{@remoteAddrKeyResolver}' #SPEL表达式去的对应的bean
redis-rate-limiter.replenishRate: 100 # 令牌桶每秒填充平均速率
redis-rate-limiter.burstCapacity: 200 # 令牌桶总容量
# 验证码处理
- ValidateCodeGatewayFilter #如果该服务需要验证码则开启此过滤器
# 解密过滤器
- RequestDecoderFilter
网关跨域支持
spring:
cloud:
gateway:
globalcors:
corsConfigurations:
'[/**]':
allowedOriginPatterns: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
exposedHeaders: "Content-Disposition,Content-Type,Cache-Control"
网关加解密
解密使用的是标准的aes对称加密
解密关键方法
BodyInserter<Mono<String>, ReactiveHttpOutputMessage> bodyInserter = BodyInserters
.fromPublisher(modifiedBody, String.class);
HttpHeaders headers = new HttpHeaders();
headers.putAll(exchange.getRequest().getHeaders());
headers.remove(HttpHeaders.CONTENT_LENGTH);
// 创建CachedBodyOutputMessage并且把请求param加入
CachedBodyOutputMessage outputMessage = new CachedBodyOutputMessage(exchange, headers);
return bodyInserter.insert(outputMessage, new BodyInserterContext()).then(Mono.defer(() -> {
ServerHttpRequestDecorator decorator = new ServerHttpRequestDecorator(exchange.getRequest()) {
@Override
public Flux<DataBuffer> getBody() {
return outputMessage.getBody();
}
};
return chain.filter(exchange.mutate().request(decorator).build());
}));
登陆授权流程图
后续文档编写中...