mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 12:19:27 +08:00
🎉 2.3.3.RELEASE
This commit is contained in:
parent
9d107e3696
commit
3f07d2d48d
179
README.md
179
README.md
@ -1,23 +1,38 @@
|
||||
## 简介
|
||||
blade-tool 是如梦技术团队作品, 是一个基于 Spring Boot 2 & Spring Cloud Finchley ,封装组合大量组件,用于快速构建中大型API、RESTful API项目的核心包。
|
||||
<p align="center">
|
||||
<img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status">
|
||||
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR2-blue.svg" alt="Coverage Status">
|
||||
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.6.RELEASE-blue.svg" alt="Downloads">
|
||||
</p>
|
||||
|
||||
## 鸣谢
|
||||
* mica([Mica](https://github.com/lets-mica/mica))
|
||||
* 如梦技术([DreamLu](https://www.dreamlu.net/))
|
||||
* pigx([Pig Microservice](https://www.pig4cloud.com/zh-cn/))
|
||||
* avue([avue](https://avue.top/))
|
||||
* gitee.ltd([gitee.ltd](https://gitee.ltd/))
|
||||
* 鲸宵(<a href="https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/jx.png" target="_blank">鲸宵</a>)
|
||||
## SpringBlade微服务开发平台
|
||||
* 采用前后端分离的模式,前端开源两个框架:[Sword](https://gitee.com/smallc/Sword) (基于 React、Ant Design)、[Saber](https://gitee.com/smallc/Saber) (基于 Vue、Element-UI)
|
||||
* 后端采用SpringCloud全家桶,并同时对其基础组件做了高度的封装,单独开源出一个框架:[BladeTool](https://github.com/chillzhuang/blade-tool)
|
||||
* [BladeTool](https://github.com/chillzhuang/blade-tool)已推送至Maven中央库,直接引入即可,减少了工程的臃肿,也可更注重于业务开发
|
||||
* 集成Sentinel从流量控制、熔断降级、系统负载等多个维度保护服务的稳定性。
|
||||
* 注册中心、配置中心选型Nacos,为工程瘦身的同时加强各模块之间的联动。
|
||||
* 使用Traefik进行反向代理,监听后台变化自动化应用新的配置文件。
|
||||
* 极简封装了多租户底层,用更少的代码换来拓展性更强的SaaS多租户系统。
|
||||
* 借鉴OAuth2,实现了多终端认证系统,可控制子系统的token权限互相隔离。
|
||||
* 借鉴Security,封装了Secure模块,采用JWT做Token认证,可拓展集成Redis等细颗粒度控制方案。
|
||||
* 稳定生产了一年,经历了从Camden -> Greenwich的技术架构,也经历了从fat jar -> docker -> k8s + jenkins的部署架构
|
||||
* 项目分包明确,规范微服务的开发模式,使包与包之间的分工清晰。
|
||||
|
||||
## 架构图
|
||||
<img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-framework.png"/>
|
||||
|
||||
## 工程结构
|
||||
```
|
||||
blade-tool
|
||||
├── blade-core-boot -- 业务包综合模块
|
||||
├── blade-core-cloud -- cloud封装模块
|
||||
├── blade-core-develop -- 代码生成封装模块
|
||||
├── blade-core-launch -- 基础启动模块
|
||||
├── blade-core-log -- 日志封装模块
|
||||
├── blade-core-mybatis -- mybatis拓展封装模块
|
||||
├── blade-core-oss -- 对象存储封装模块
|
||||
├── blade-core-secure -- 安全模块
|
||||
├── blade-core-swagger -- swagger拓展封装模块
|
||||
├── blade-core-test -- 单元测试封装模块
|
||||
└── blade-core-tool -- 工具包模块
|
||||
|
||||
```
|
||||
@ -29,34 +44,126 @@ LGPL是GPL的一个为主要为类库使用设计的开源协议。和GPL要求
|
||||
|
||||
但是如果修改LGPL协议的代码或者衍生,则所有修改的代码,涉及修改部分的额外代码和衍生的代码都必须采用LGPL协议。因此LGPL协议的开源代码很适合作为第三方类库被商业软件引用,但不适合希望以LGPL协议代码为基础,通过修改和衍生的方式做二次开发的商业软件采用。
|
||||
|
||||
## 用户权益
|
||||
* 允许以引入不改源码的形式免费用于学习、毕设、公司项目、私活等。
|
||||
* 特殊情况修改代码,但仍然想闭源需经过作者同意。
|
||||
## 官网
|
||||
* 官网地址:[https://bladex.vip](https://bladex.vip)
|
||||
* 问答社区:[https://sns.bladex.vip](https://sns.bladex.vip)
|
||||
* 会员计划:[SpringBlade会员计划](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade会员计划)
|
||||
* 交流群:`477853168`
|
||||
|
||||
## 禁止事项
|
||||
* 直接将本项目挂淘宝等商业平台出售。
|
||||
## 在线演示
|
||||
* Sword演示地址:[https://sword.bladex.vip](https://sword.bladex.vip)
|
||||
* Saber演示地址:[https://saber.bladex.vip](https://saber.bladex.vip)
|
||||
|
||||
## 项目地址
|
||||
* 后端Gitee地址:[https://gitee.com/smallc/SpringBlade](https://gitee.com/smallc/SpringBlade)
|
||||
* 后端Github地址:[https://github.com/chillzhuang/SpringBlade](https://github.com/chillzhuang/SpringBlade)
|
||||
* 后端SpringBoot版:[https://gitee.com/smallc/SpringBlade/tree/2.0-boot/](https://gitee.com/smallc/SpringBlade/tree/2.0-boot/)
|
||||
* 前端框架Sword(基于React):[https://gitee.com/smallc/Sword](https://gitee.com/smallc/Sword)
|
||||
* 前端框架Saber(基于Vue):[https://gitee.com/smallc/Saber](https://gitee.com/smallc/Saber)
|
||||
* 核心框架项目地址:[https://github.com/chillzhuang/blade-tool](https://github.com/chillzhuang/blade-tool)
|
||||
|
||||
## 技术文档
|
||||
* [SpringBlade开发手册](https://gitee.com/smallc/SpringBlade/wikis/SpringBlade开发手册)
|
||||
|
||||
## 用户权益
|
||||
* 允许免费用于学习、毕设、公司项目、私活等。
|
||||
* 代码文件需保留相关license信息。
|
||||
* 禁止直接将本项目挂淘宝等商业平台出售。
|
||||
* 非界面代码50%以上相似度的二次开源,二次开源需先联系作者。
|
||||
|
||||
注意:若禁止条款被发现有权追讨19999的授权费。
|
||||
# 界面
|
||||
|
||||
## [SpringBlade2.0](https://gitee.com/smallc/SpringBlade) 界面一览(开源协议为Apache License)
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-k8s.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-traefik.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-traefik-health.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-harbor.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-consul.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-consul-nodes1.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-consul-nodes2.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-admin1.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-admin2.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-swagger1.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/springblade-swagger2.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-menu.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-menu-edit.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-menu-icon.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-role.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-user.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-dict.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-locale-cn.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-locale-us.png "业务系统")
|
||||
![业务系统](https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/sword-log.png "业务系统")
|
||||
## [BladeX](https://bladex.vip/#/vip) 工作流一览
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow1.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow2.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow3.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow4.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow5.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/bladex-flow6.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## [Sword](https://gitee.com/smallc/Sword) 界面一览
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-main.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-edit.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-menu-icon.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-role.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-user.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-dict.png "/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-log.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-cn.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/sword-locale-us.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## [Saber](https://gitee.com/smallc/Saber) 界面一览
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-user.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-role.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-dict-select.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-log.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/saber-code.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 监控界面一览
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s1.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-k8s2.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-grafana.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-harbor.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-traefik-health.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-nacos.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-sentinel.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin1.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-admin2.png"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger1.png"/></td>
|
||||
<td><img src="https://gitee.com/smallc/SpringBlade/raw/master/pic/springblade-swagger2.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 鸣谢
|
||||
* mica([Mica](https://github.com/lets-mica/mica))
|
||||
* 如梦技术([DreamLu](https://www.dreamlu.net/))
|
||||
* pigx([Pig Microservice](https://www.pig4cloud.com/zh-cn/))
|
||||
* avue([avue](https://avue.top/))
|
||||
* gitee.ltd([gitee.ltd](https://gitee.ltd/))
|
||||
* 鲸宵(<a href="https://raw.githubusercontent.com/chillzhuang/blade-tool/master/pic/jx.png" target="_blank">鲸宵</a>)
|
||||
|
||||
## 关注我们
|
||||
![](https://images.gitee.com/uploads/images/2019/0330/065148_f0ada806_410595.jpeg)
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springblade.core.boot.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
@ -40,11 +39,6 @@ public class MybatisPlusConfiguration {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LogicSqlInjector logicSqlInjector() {
|
||||
return new LogicSqlInjector();
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL执行效率插件
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ mybatis-plus:
|
||||
swagger:
|
||||
title: SpringBlade 接口文档系统
|
||||
description: SpringBlade 接口文档系统
|
||||
version: 2.3.2
|
||||
version: 2.3.3
|
||||
license: Powered By SpringBlade
|
||||
licenseUrl: https://bladex.vip
|
||||
terms-of-service-url: https://bladex.vip
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class BladeFeignRequestHeaderInterceptor implements RequestInterceptor {
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String name = headerNames.nextElement();
|
||||
String value = request.getHeader(name);
|
||||
if ("blade-auth".equals(name)) {
|
||||
if ("blade-auth".equals(name.toLowerCase())) {
|
||||
requestTemplate.header(name, value);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -17,6 +17,7 @@ package $!{package.Controller};
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import javax.validation.Valid;
|
||||
@ -68,6 +69,7 @@ public class $!{table.controllerName} {
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "详情", notes = "传入$!{table.entityPath}", position = 1)
|
||||
public R<$!{entity}VO> detail($!{entity} $!{table.entityPath}) {
|
||||
$!{entity} detail = $!{table.entityPath}Service.getOne(Condition.getQueryWrapper($!{table.entityPath}));
|
||||
@ -79,7 +81,8 @@ public class $!{table.controllerName} {
|
||||
* 分页 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}", position = 2)
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}")
|
||||
public R<IPage<$!{entity}VO>> list($!{entity} $!{table.entityPath}, Query query) {
|
||||
IPage<$!{entity}> pages = $!{table.entityPath}Service.page(Condition.getPage(query), Condition.getQueryWrapper($!{table.entityPath}));
|
||||
$!{entity}Wrapper $!{table.entityPath}Wrapper = new $!{entity}Wrapper(dictClient);
|
||||
@ -90,7 +93,8 @@ public class $!{table.controllerName} {
|
||||
* 自定义分页 $!{table.comment}
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}", position = 3)
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "分页", notes = "传入$!{table.entityPath}")
|
||||
public R<IPage<$!{entity}VO>> page($!{entity}VO $!{table.entityPath}, Query query) {
|
||||
IPage<$!{entity}VO> pages = $!{table.entityPath}Service.select$!{entity}Page(Condition.getPage(query), $!{table.entityPath});
|
||||
return R.data(pages);
|
||||
@ -100,7 +104,8 @@ public class $!{table.controllerName} {
|
||||
* 新增 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}", position = 4)
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperation(value = "新增", notes = "传入$!{table.entityPath}")
|
||||
public R save(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
|
||||
return R.status($!{table.entityPath}Service.save($!{table.entityPath}));
|
||||
}
|
||||
@ -109,7 +114,8 @@ public class $!{table.controllerName} {
|
||||
* 修改 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}", position = 5)
|
||||
@ApiOperationSupport(order = 5)
|
||||
@ApiOperation(value = "修改", notes = "传入$!{table.entityPath}")
|
||||
public R update(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
|
||||
return R.status($!{table.entityPath}Service.updateById($!{table.entityPath}));
|
||||
}
|
||||
@ -118,7 +124,8 @@ public class $!{table.controllerName} {
|
||||
* 新增或修改 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperation(value = "新增或修改", notes = "传入$!{table.entityPath}", position = 6)
|
||||
@ApiOperationSupport(order = 6)
|
||||
@ApiOperation(value = "新增或修改", notes = "传入$!{table.entityPath}")
|
||||
public R submit(@Valid @RequestBody $!{entity} $!{table.entityPath}) {
|
||||
return R.status($!{table.entityPath}Service.saveOrUpdate($!{table.entityPath}));
|
||||
}
|
||||
@ -129,7 +136,8 @@ public class $!{table.controllerName} {
|
||||
* 删除 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids", position = 7)
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status($!{table.entityPath}Service.deleteLogic(Func.toIntList(ids)));
|
||||
}
|
||||
@ -140,7 +148,8 @@ public class $!{table.controllerName} {
|
||||
* 删除 $!{table.comment}
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperation(value = "删除", notes = "传入ids", position = 7)
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperation(value = "删除", notes = "传入ids")
|
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status($!{table.entityPath}Service.removeByIds(Func.toIntList(ids)));
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -25,7 +25,7 @@ public interface AppConstant {
|
||||
/**
|
||||
* 应用版本
|
||||
*/
|
||||
String APPLICATION_VERSION = "2.3.2";
|
||||
String APPLICATION_VERSION = "2.3.3";
|
||||
|
||||
/**
|
||||
* 基础包
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.utils.SecureUtil;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@ -28,7 +27,6 @@ import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 业务封装基础类
|
||||
@ -51,12 +49,16 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
|
||||
@Override
|
||||
public boolean save(T entity) {
|
||||
BladeUser user = SecureUtil.getUser();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
entity.setCreateUser(Objects.requireNonNull(user).getUserId());
|
||||
entity.setCreateTime(now);
|
||||
if (user != null) {
|
||||
entity.setCreateUser(user.getUserId());
|
||||
entity.setUpdateUser(user.getUserId());
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
entity.setCreateTime(now);
|
||||
entity.setUpdateTime(now);
|
||||
if (entity.getStatus() == null) {
|
||||
entity.setStatus(BladeConstant.DB_STATUS_NORMAL);
|
||||
}
|
||||
entity.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
||||
return super.save(entity);
|
||||
}
|
||||
@ -64,17 +66,15 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
|
||||
@Override
|
||||
public boolean updateById(T entity) {
|
||||
BladeUser user = SecureUtil.getUser();
|
||||
entity.setUpdateUser(Objects.requireNonNull(user).getUserId());
|
||||
if (user != null) {
|
||||
entity.setUpdateUser(user.getUserId());
|
||||
}
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteLogic(@NotEmpty List<Integer> ids) {
|
||||
BladeUser user = SecureUtil.getUser();
|
||||
T entity = BeanUtil.newInstance(modelClass);
|
||||
entity.setUpdateUser(Objects.requireNonNull(user).getUserId());
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
return super.removeByIds(ids);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -31,6 +31,8 @@ public class AuthInfo {
|
||||
private String accessToken;
|
||||
@ApiModelProperty(value = "令牌类型")
|
||||
private String tokenType;
|
||||
@ApiModelProperty(value = "刷新令牌")
|
||||
private String refreshToken;
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String avatar = "https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png";
|
||||
@ApiModelProperty(value = "角色名")
|
||||
|
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.secure;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* TokenInfo
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
public class TokenInfo {
|
||||
|
||||
/**
|
||||
* 令牌值
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 过期秒数
|
||||
*/
|
||||
private int expire;
|
||||
|
||||
}
|
@ -43,6 +43,7 @@ public class SecureRegistry {
|
||||
this.defaultExcludePatterns.add("/token/**");
|
||||
this.defaultExcludePatterns.add("/log/**");
|
||||
this.defaultExcludePatterns.add("/user/user-info");
|
||||
this.defaultExcludePatterns.add("/user/user-info-by-id");
|
||||
this.defaultExcludePatterns.add("/menu/auth-routes");
|
||||
this.defaultExcludePatterns.add("/error/**");
|
||||
this.defaultExcludePatterns.add("/assets/**");
|
||||
|
@ -22,6 +22,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springblade.core.launch.constant.TokenConstant;
|
||||
import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.TokenInfo;
|
||||
import org.springblade.core.secure.constant.SecureConstant;
|
||||
import org.springblade.core.secure.exception.SecureException;
|
||||
import org.springblade.core.secure.provider.IClientDetails;
|
||||
@ -296,18 +297,21 @@ public class SecureUtil {
|
||||
* @param user user
|
||||
* @param audience audience
|
||||
* @param issuer issuer
|
||||
* @param isExpire isExpire
|
||||
* @param tokenType tokenType
|
||||
* @return jwt
|
||||
*/
|
||||
public static String createJWT(Map<String, String> user, String audience, String issuer, boolean isExpire) {
|
||||
public static TokenInfo createJWT(Map<String, String> user, String audience, String issuer, String tokenType) {
|
||||
|
||||
String[] tokens = extractAndDecodeHeader();
|
||||
assert tokens.length == 2;
|
||||
String clientId = tokens[0];
|
||||
String clientSecret = tokens[1];
|
||||
|
||||
// 获取客户端信息
|
||||
IClientDetails clientDetails = clientDetails(clientId);
|
||||
|
||||
// 校验客户端信息
|
||||
if (!validateClient(clientId, clientSecret)) {
|
||||
if (!validateClient(clientDetails, clientId, clientSecret)) {
|
||||
throw new SecureException("客户端认证失败!");
|
||||
}
|
||||
|
||||
@ -333,14 +337,24 @@ public class SecureUtil {
|
||||
builder.claim(CLIENT_ID, clientId);
|
||||
|
||||
//添加Token过期时间
|
||||
if (isExpire) {
|
||||
long expMillis = nowMillis + getExpire();
|
||||
long expireMillis;
|
||||
if (tokenType.equals(TokenConstant.ACCESS_TOKEN)) {
|
||||
expireMillis = clientDetails.getAccessTokenValidity() * 1000;
|
||||
} else if (tokenType.equals(TokenConstant.REFRESH_TOKEN)) {
|
||||
expireMillis = clientDetails.getRefreshTokenValidity() * 1000;
|
||||
} else {
|
||||
expireMillis = getExpire();
|
||||
}
|
||||
long expMillis = nowMillis + expireMillis;
|
||||
Date exp = new Date(expMillis);
|
||||
builder.setExpiration(exp).setNotBefore(now);
|
||||
}
|
||||
|
||||
//生成JWT
|
||||
return builder.compact();
|
||||
// 组装Token信息
|
||||
TokenInfo tokenInfo = new TokenInfo();
|
||||
tokenInfo.setToken(builder.compact());
|
||||
tokenInfo.setExpire((int) expireMillis / 1000);
|
||||
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -358,15 +372,6 @@ public class SecureUtil {
|
||||
return cal.getTimeInMillis() - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过期时间的秒数(次日凌晨3点)
|
||||
*
|
||||
* @return expire
|
||||
*/
|
||||
public static int getExpireSeconds() {
|
||||
return (int) (getExpire() / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端信息解码
|
||||
*/
|
||||
@ -404,6 +409,16 @@ public class SecureUtil {
|
||||
return tokens[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端信息
|
||||
*
|
||||
* @param clientId 客户端id
|
||||
* @return clientDetails
|
||||
*/
|
||||
private static IClientDetails clientDetails(String clientId) {
|
||||
return clientDetailsService.loadClientByClientId(clientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验Client
|
||||
*
|
||||
@ -411,8 +426,7 @@ public class SecureUtil {
|
||||
* @param clientSecret 客户端密钥
|
||||
* @return boolean
|
||||
*/
|
||||
private static boolean validateClient(String clientId, String clientSecret) {
|
||||
IClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId);
|
||||
private static boolean validateClient(IClientDetails clientDetails, String clientId, String clientSecret) {
|
||||
if (clientDetails != null) {
|
||||
return StringUtil.equals(clientId, clientDetails.getClientId()) && StringUtil.equals(clientSecret, clientDetails.getClientSecret());
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -26,7 +26,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.*;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||
@ -79,7 +78,7 @@ public class SwaggerAutoConfiguration {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.host(swaggerProperties.getHost())
|
||||
.apiInfo(apiInfo(swaggerProperties)).select()
|
||||
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()))
|
||||
.apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages()))
|
||||
.paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
|
||||
.build()
|
||||
.securitySchemes(Collections.singletonList(securitySchema()))
|
||||
|
@ -17,9 +17,11 @@ package org.springblade.core.swagger;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -33,7 +35,7 @@ public class SwaggerProperties {
|
||||
/**
|
||||
* swagger会解析的包路径
|
||||
**/
|
||||
private String basePackage = "org.springblade";
|
||||
private List<String> basePackages = new ArrayList<>(Collections.singletonList(AppConstant.BASE_PACKAGES));
|
||||
/**
|
||||
* swagger会解析的url规则
|
||||
**/
|
||||
@ -53,7 +55,7 @@ public class SwaggerProperties {
|
||||
/**
|
||||
* 版本
|
||||
**/
|
||||
private String version = "2.3.2";
|
||||
private String version = "2.3.3";
|
||||
/**
|
||||
* 许可证
|
||||
**/
|
||||
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2018-2028, lengleng (wangiegie@gmail.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springblade.core.swagger;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import springfox.documentation.RequestHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class SwaggerUtil {
|
||||
|
||||
/**
|
||||
* 获取包集合
|
||||
*
|
||||
* @param basePackages 多个包名集合
|
||||
*/
|
||||
public static Predicate<RequestHandler> basePackages(final List<String> basePackages) {
|
||||
return input -> declaringClass(input).transform(handlerPackage(basePackages)).or(true);
|
||||
}
|
||||
|
||||
private static Function<Class<?>, Boolean> handlerPackage(final List<String> basePackages) {
|
||||
return input -> {
|
||||
// 循环判断匹配
|
||||
for (String strPackage : basePackages) {
|
||||
boolean isMatch = input.getPackage().getName().startsWith(strPackage);
|
||||
if (isMatch) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
private static Optional<? extends Class<?>> declaringClass(RequestHandler input) {
|
||||
return Optional.fromNullable(input.declaringClass());
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
14
pom.xml
14
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-tool</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<version>2.3.3</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>blade-tool</name>
|
||||
<description>
|
||||
@ -36,24 +36,24 @@
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<blade.tool.version>2.3.2</blade.tool.version>
|
||||
<blade.tool.version>2.3.3</blade.tool.version>
|
||||
|
||||
<java.version>1.8</java.version>
|
||||
<maven.plugin.version>3.8.0</maven.plugin.version>
|
||||
<swagger.version>2.9.2</swagger.version>
|
||||
<swagger.models.version>1.5.21</swagger.models.version>
|
||||
<swagger.bootstrapui.version>1.9.4</swagger.bootstrapui.version>
|
||||
<mybatis.plus.version>3.1.0</mybatis.plus.version>
|
||||
<mybatis.plus.version>3.1.2</mybatis.plus.version>
|
||||
<curator.framework.version>4.0.1</curator.framework.version>
|
||||
<protostuff.version>1.6.0</protostuff.version>
|
||||
<disruptor.version>3.4.2</disruptor.version>
|
||||
<spring.boot.admin.version>2.1.4</spring.boot.admin.version>
|
||||
<spring.boot.admin.version>2.1.5</spring.boot.admin.version>
|
||||
<mica.auto.version>1.1.0</mica.auto.version>
|
||||
<alibaba.cloud.version>0.9.0.RELEASE</alibaba.cloud.version>
|
||||
|
||||
<spring.boot.version>2.1.5.RELEASE</spring.boot.version>
|
||||
<spring.cloud.version>Greenwich.SR1</spring.cloud.version>
|
||||
<spring.platform.version>Cairo-SR7</spring.platform.version>
|
||||
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
|
||||
<spring.cloud.version>Greenwich.SR2</spring.cloud.version>
|
||||
<spring.platform.version>Cairo-SR8</spring.platform.version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
|
Loading…
Reference in New Issue
Block a user