Compare commits
136 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccfdd18516 | ||
|
|
c724387a16 | ||
|
|
ced025e292 | ||
|
|
37e264491f | ||
|
|
be4adbe00b | ||
| 33fc749363 | |||
|
|
eb5978eb9d | ||
|
|
db7dbcc97e | ||
|
|
cba659010a | ||
| 0a8c05e1df | |||
|
|
7a961d63a6 | ||
|
|
16779413a6 | ||
|
|
c0c2e492b8 | ||
|
|
023d35fecd | ||
| 895ae7383a | |||
|
|
0d12345ed4 | ||
| e6c1041202 | |||
| d7b36d9f59 | |||
| fb81670776 | |||
| f22189bc00 | |||
|
|
74d030a97e | ||
|
|
609bef8a87 | ||
| 0fa91a472d | |||
|
|
bdd3f251a2 | ||
| 4a0b1499c7 | |||
| 74064a4dc4 | |||
| 4c4f1acf32 | |||
|
|
92246a6767 | ||
|
|
6419f88c63 | ||
|
|
eee546fcc4 | ||
| 714b759050 | |||
|
|
2d3024b3e7 | ||
|
|
8b79ae515d | ||
|
|
8ccfe35b49 | ||
|
|
b12f104161 | ||
|
|
a9bb36dacc | ||
| 8a73e9bec4 | |||
| 0002cf457d | |||
| 01748fe738 | |||
| bf2956c51c | |||
| 1e9baade51 | |||
| 0babec14cf | |||
| 4806918ef9 | |||
| 0c87b1d63e | |||
| cbaa3e7c42 | |||
| 30f8584d33 | |||
|
|
29e43f6e36 | ||
|
|
985b82c604 | ||
|
|
54cc4c4ba5 | ||
|
|
302e085a18 | ||
|
|
ff174056a0 | ||
|
|
c2a9f58926 | ||
| c80d8909dd | |||
| e04a663fdb | |||
| b92f6a6f53 | |||
| 99e64a9295 | |||
| c13efa788c | |||
| ea916df3ce | |||
| 3b7501458a | |||
| f301ea5840 | |||
| 084dad491e | |||
|
|
0bb060b273 | ||
|
|
4e9ab30d68 | ||
|
|
454bdd44bc | ||
|
|
2fa20aaaf3 | ||
|
|
d017e2bb64 | ||
|
|
e2f398b794 | ||
|
|
664d845ea4 | ||
|
|
5b3809abd9 | ||
|
|
9fbc14c171 | ||
|
|
bc1b97f720 | ||
|
|
f5c6125d74 | ||
|
|
4ed71fdf5d | ||
|
|
ab3bcda857 | ||
|
|
68575d141c | ||
|
|
dd535bfa50 | ||
|
|
47394d92ae | ||
|
|
2644ed4368 | ||
|
|
c09c7e4ca8 | ||
|
|
ce83324c44 | ||
|
|
9ad9895510 | ||
|
|
f489ef45fd | ||
|
|
f1b3ca650d | ||
|
|
42bf932d86 | ||
|
|
1ccbfa2881 | ||
|
|
6e4155a146 | ||
|
|
0bc4148a34 | ||
|
|
6a4245f541 | ||
|
|
660dfa6a1e | ||
|
|
62f81adc74 | ||
|
|
21ed5ef781 | ||
|
|
073cda31e8 | ||
|
|
a845cf66ce | ||
|
|
d2eb733ab3 | ||
|
|
f09c1fa47f | ||
|
|
4716b3c977 | ||
|
|
aa2de6a6f2 | ||
|
|
e9df8f01a1 | ||
|
|
9793f97613 | ||
|
|
ea6117cf4e | ||
|
|
a8afdce2fa | ||
|
|
7b78527e6d | ||
|
|
5a20edaff8 | ||
|
|
c054f3e3e8 | ||
|
|
1ba6a55e93 | ||
|
|
72cde4c5cf | ||
|
|
050905fbc0 | ||
|
|
135a135d0f | ||
|
|
0c4f58fd23 | ||
|
|
a6344a2662 | ||
|
|
9527c95734 | ||
|
|
fcf41c68da | ||
|
|
c7436ec289 | ||
|
|
90f80a7d27 | ||
|
|
4aeafb8ab1 | ||
|
|
d8093fffe9 | ||
|
|
33ce250371 | ||
|
|
88841b7ed0 | ||
|
|
1a93fe4d95 | ||
|
|
251db3a146 | ||
|
|
18cba6b975 | ||
|
|
a6792705ba | ||
|
|
02fb771994 | ||
|
|
6ebea15fb3 | ||
|
|
76f1ddc9fe | ||
|
|
198b0856af | ||
|
|
0ab467dc6c | ||
|
|
3b091cbd4a | ||
|
|
df4996096c | ||
|
|
fb40f307b9 | ||
|
|
2e435497b9 | ||
|
|
bcc9d7c757 | ||
|
|
8d214bc4d1 | ||
|
|
7bb6d625e4 | ||
|
|
88e22c270d | ||
|
|
37e297626b |
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,36 +0,0 @@
|
||||
---
|
||||
name: Bug 报告
|
||||
about: 创建BUG报告以改进项目
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**BUG描述**
|
||||
关于BUG清晰简洁的描述。
|
||||
|
||||
**复现步骤**
|
||||
详细的复现步骤。
|
||||
|
||||
|
||||
**正确的行为**
|
||||
你认为这个修复这个BUG后,正确的行为应该是什么。
|
||||
|
||||
|
||||
**详细截图**
|
||||
如果可以的话,请添加截图以帮助调查BUG.
|
||||
|
||||
**桌面端:**
|
||||
- 操作系统: [例如. iOS]
|
||||
- 浏览器及版本 [例如. chrome 11]
|
||||
- 项目版本 [例如. 1.6.0]
|
||||
|
||||
**手机端:**
|
||||
- 设备: [例如. iPhone6]
|
||||
- 操作系统: [例如. iOS8.1]
|
||||
- 浏览器及版本 [例如.safari 8]
|
||||
- 项目版本 [例如. 1.6.0]
|
||||
|
||||
**Additional context**
|
||||
任何其他你认为有助于排查错误的信息,或者你的猜测。
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: 功能建议
|
||||
about: 关于该项目的建议
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**您的功能请求是否与问题相关? 请描述。**
|
||||
清楚简明地描述问题所在。
|
||||
|
||||
**描述您想要的解决方案**
|
||||
对您所设想的问题的清晰简洁的描述。
|
||||
|
||||
**描述您考虑过的替代方案**
|
||||
对您考虑过的任何替代解决方案或功能的清晰简洁的描述。
|
||||
|
||||
**附加上下文**
|
||||
在此处添加有关功能请求的任何其他上下文或屏幕截图。
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -45,6 +45,6 @@ nbdist/
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
!*/build/*.xml
|
||||
/agileboot-admin/src/main/resources/application-dev.yml
|
||||
/agileboot-infrastructure/src/main/resources/application-prod.yml
|
||||
/agileboot-infrastructure/src/main/resources/logback-prod.xml
|
||||
|
||||
/agileboot-admin/src/main/resources/application-prod.yml
|
||||
|
||||
|
||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM amazoncorretto:17
|
||||
ADD agileboot-admin/target/agileboot-admin-1.0.0.jar /agileboot-admin.jar
|
||||
|
||||
EXPOSE 18080
|
||||
#ENV CONTEXT_PATH /
|
||||
# ENV NACOS_ENABLED true
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
ENTRYPOINT ["java", "-jar", "/agileboot-admin.jar"]
|
||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 valarchie
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
60
README.md
60
README.md
@@ -15,8 +15,7 @@
|
||||
|
||||
<img alt="logo" height="200" src="https://oscimg.oschina.net/oscnet/up-eda2a402cc061f1f5f40d9ac4c084f4c98c.png">
|
||||
</p>
|
||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">AgileBoot v1.8.0</h1>
|
||||
|
||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">AgileBoot v2.0.0 </h1>
|
||||
<h4 align="center">基于SpringBoot+Vue3前后端分离的Java快速开发脚手架</h4>
|
||||
<p align="center">
|
||||
</p>
|
||||
@@ -27,7 +26,8 @@ AgileBoot是一套开源的全栈精简快速开发平台,毫无保留给个
|
||||
适合个人开发者的小型项目或者公司内部项目使用。也可作为供初学者学习使用的案例。
|
||||
|
||||
|
||||
* 前端采用Vue3、Element Plus。对应前端仓库 [AgileBoot-Front-End](https://github.com/valarchie/AgileBoot-Front-End) ,保持同步更新。
|
||||
* 前端是基于优秀的开源项目[Pure-Admin](https://github.com/pure-admin/vue-pure-admin)开发而成。在此感谢Pure-Admin作者。
|
||||
* 前端采用Vue3、Element Plus、TypeScript、Pinia。对应前端仓库 [AgileBoot-Front-End](https://github.com/valarchie/AgileBoot-Front-End) ,保持同步更新。
|
||||
* 后端采用Spring Boot、Spring Security & Jwt、Redis & MySql、Mybatis Plus、Hutool工具包。
|
||||
* 权限认证使用Jwt,支持多终端认证系统。
|
||||
* 支持注解式主从数据库切换,注解式请求限流,注解式重复请求拦截。
|
||||
@@ -35,6 +35,9 @@ AgileBoot是一套开源的全栈精简快速开发平台,毫无保留给个
|
||||
* 支持加载动态权限菜单,实时权限控制。
|
||||
* ***有大量的单元测试,集成测试覆盖确保业务逻辑正确***。
|
||||
|
||||
***V1.0.0版本使用JS开发,V2.0.0版本使用TS开发***。
|
||||
***V1.0.0地址:[后端(AgileBoot-Back-End-Basic)](https://github.com/valarchie/AgileBoot-Back-End-Basic) - [前端(AgileBoot-Front-End-Basic)](https://github.com/valarchie/AgileBoot-Front-End-Basic)***
|
||||
|
||||
> 有任何问题或者建议,可以在 _Issues_ 中提给作者。
|
||||
>
|
||||
> 您的Issue比Star更重要
|
||||
@@ -148,9 +151,9 @@ git clone https://github.com/valarchie/AgileBoot-Front-End
|
||||
#### 后端启动
|
||||
```
|
||||
1. 生成所需的数据库表
|
||||
找到后端项目根目录下的sql目录中的agileboot_xxxxx.sql脚本文件。 导入到你新建的数据库中。
|
||||
找到后端项目根目录下的sql目录中的agileboot_xxxxx.sql脚本文件(取最新的sql文件)。 导入到你新建的数据库中。
|
||||
|
||||
2. 在infrastructure模块底下,找到resource目录下的application-dev.yml文件
|
||||
2. 在admin模块底下,找到resource目录下的application-dev.yml文件
|
||||
配置数据库以及Redis的 地址、端口、账号密码
|
||||
|
||||
3. 在根目录执行mvn install
|
||||
@@ -168,16 +171,18 @@ git clone https://github.com/valarchie/AgileBoot-Front-End
|
||||
```
|
||||
|
||||
#### 前端启动
|
||||
```
|
||||
1. npm install
|
||||
详细步骤请查看对应前端部分
|
||||
|
||||
2. npm run dev
|
||||
```
|
||||
1. pnpm install
|
||||
|
||||
2. pnpm run dev
|
||||
|
||||
3. 当出现以下字样时即为启动成功
|
||||
|
||||
vite v2.6.14 dev server running at:
|
||||
|
||||
> Local: http://127.0.0.1:3000/
|
||||
> Local: http://127.0.0.1:80/
|
||||
|
||||
ready in 4376ms.
|
||||
|
||||
@@ -232,8 +237,6 @@ agileboot.embedded.redis: true
|
||||
| | 连接池监视 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 |
|
||||
|
||||
|
||||
目前版本是V1.8.0,将在2.0版本后陆续新增新功能。
|
||||
|
||||
## 🐯 工程结构 🐯
|
||||
|
||||
```
|
||||
@@ -244,25 +247,20 @@ agileboot
|
||||
│
|
||||
├── agileboot-common -- 精简基础工具模块
|
||||
│
|
||||
├── agileboot-infrastructure -- 基础设施模块(主要是配置和集成)
|
||||
├── agileboot-infrastructure -- 基础设施模块(主要是配置和集成,不包含业务逻辑)
|
||||
│
|
||||
├── agileboot-domain -- 业务模块
|
||||
├ ├── user -- 用户模块(举例)
|
||||
├ ├── command -- 命令参数接收模型(命令)
|
||||
├ ├── dto -- 返回数据类
|
||||
├ ├── db -- DB操作类
|
||||
├ ├── entity -- 实体类
|
||||
├ ├── service -- DB Service
|
||||
├ ├── mapper -- DB Dao
|
||||
├ ├── model -- 领域模型类
|
||||
├ ├── query -- 查询参数模型(查询)
|
||||
│ ├────── UserApplicationService -- 应用服务(事务层,操作领域模型类完成业务逻辑)
|
||||
│
|
||||
├── agileboot-integration-test -- 集成测试模块
|
||||
│
|
||||
├── agileboot-orm -- 数据映射模块(仅包含数据相关逻辑)
|
||||
├ ├── entiy -- 实体类
|
||||
├ ├── enums -- 数据相关枚举
|
||||
├ ├── mapper -- DAO
|
||||
├ ├── query -- 封装查询对象
|
||||
├ ├── result -- 封装多表查询对象
|
||||
└── └── service -- 服务层
|
||||
|
||||
```
|
||||
|
||||
### 代码流转
|
||||
@@ -286,11 +284,16 @@ agileboot
|
||||
│ ├── member -- 会员模块
|
||||
│
|
||||
├── agileboot-domain --
|
||||
├ ├── member -- 会员模块
|
||||
│
|
||||
├── agileboot-orm --
|
||||
│ ├── member -- 会员模块
|
||||
│
|
||||
├ ├── member -- 会员模块(举例)
|
||||
├ ├── command -- 命令参数接收模型(命令)
|
||||
├ ├── dto -- 返回数据类
|
||||
├ ├── db -- DB操作类
|
||||
├ ├── entity -- 实体类
|
||||
├ ├── service -- DB Service
|
||||
├ ├── mapper -- DB Dao
|
||||
├ ├── model -- 领域模型类
|
||||
├ ├── query -- 查询参数模型(查询)
|
||||
│ ├────── MemberApplicationService -- 应用服务(事务层,操作领域模型类完成业务逻辑)
|
||||
└─
|
||||
```
|
||||
|
||||
@@ -315,11 +318,12 @@ agileboot
|
||||
- 请导入统一的代码格式化模板(Google): Settings > Editor > Code Style > Java > 设置按钮 > import schema > 选择项目根目录下的GoogleStyle.xml文件
|
||||
- 如需要生成新的表,请使用CodeGenerator类进行生成。
|
||||
- 填入数据库地址,账号密码,库名。然后填入所需的表名执行代码即可。(大概看一下代码就知道怎么填啦)
|
||||
- 生成的类在orm模块下的target/classes目录下
|
||||
- 生成的类在infrastructure模块下的target/classes目录下
|
||||
- 不同的数据库keywordsHandler方法请填入对应不同数据库handler。(搜索keywordsHandler关键字)
|
||||
- 项目基础环境搭建,请参考docker目录下的指南搭建。保姆级启动说明:
|
||||
- [AgileBoot - 手把手一步一步带你Run起全栈项目(SpringBoot+Vue3)](https://juejin.cn/post/7153812187834744845)
|
||||
- 注意:管理后台的后端启动类是AgileBoot**Admin**Application
|
||||
- Swagger的API地址为 http://localhost:8080/v3/api-docs
|
||||
|
||||
## 🎬 AgileBoot全栈交流群 🎬
|
||||
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-infrastructure</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务领域 -->
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
@@ -61,6 +55,15 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven.surefire.plugin.version}</version>
|
||||
<!-- 想跑test的话 设置成false -->
|
||||
<configuration>
|
||||
<skipTests>false</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -16,7 +16,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.agileboot.admin.customize.service.login.LoginService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
|
||||
@@ -12,9 +12,8 @@ import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import lombok.NonNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -13,8 +13,7 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.NonNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -10,15 +10,15 @@ import com.agileboot.domain.system.log.LogApplicationService;
|
||||
import com.agileboot.domain.system.log.dto.LoginLogDTO;
|
||||
import com.agileboot.domain.system.log.query.LoginLogQuery;
|
||||
import com.agileboot.domain.system.log.dto.OperationLogDTO;
|
||||
import com.agileboot.domain.system.log.dto.OperationLogQuery;
|
||||
import com.agileboot.domain.system.log.query.OperationLogQuery;
|
||||
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -16,9 +16,8 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.PositiveOrZero;
|
||||
import lombok.NonNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.PositiveOrZero;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -17,9 +17,8 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Positive;
|
||||
import lombok.NonNull;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.agileboot.admin.controller.system;
|
||||
|
||||
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.core.base.BaseController;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.post.PostApplicationService;
|
||||
@@ -10,13 +12,12 @@ import com.agileboot.domain.system.post.command.AddPostCommand;
|
||||
import com.agileboot.domain.system.post.command.UpdatePostCommand;
|
||||
import com.agileboot.domain.system.post.dto.PostDTO;
|
||||
import com.agileboot.domain.system.post.query.PostQuery;
|
||||
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.NonNull;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
@@ -54,13 +56,20 @@ public class SysPostController extends BaseController {
|
||||
return ResponseDTO.ok(pageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出查询到的所有岗位信息到excel文件
|
||||
* @param response http响应
|
||||
* @param query 查询参数
|
||||
* @author Kevin Zhang
|
||||
* @date 2023-10-02
|
||||
*/
|
||||
@Operation(summary = "职位列表导出")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.EXPORT)
|
||||
@PreAuthorize("@permission.has('system:post:export')")
|
||||
@PostMapping("/export")
|
||||
@GetMapping("/excel")
|
||||
public void export(HttpServletResponse response, PostQuery query) {
|
||||
PageDTO<PostDTO> pageDTO = postApplicationService.getPostList(query);
|
||||
CustomExcelUtil.writeToResponse(pageDTO.getRows(), PostDTO.class, response);
|
||||
List<PostDTO> all = postApplicationService.getPostListAll(query);
|
||||
CustomExcelUtil.writeToResponse(all, PostDTO.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,9 +113,9 @@ public class SysPostController extends BaseController {
|
||||
@Operation(summary = "删除职位")
|
||||
@PreAuthorize("@permission.has('system:post:remove')")
|
||||
@AccessLog(title = "岗位管理", businessType = BusinessTypeEnum.DELETE)
|
||||
@DeleteMapping("/{postIds}")
|
||||
public ResponseDTO<Void> remove(@PathVariable List<Long> postIds) {
|
||||
postApplicationService.deletePost(new BulkOperationCommand<>(postIds));
|
||||
@DeleteMapping
|
||||
public ResponseDTO<Void> remove(@RequestParam @NotNull @NotEmpty List<Long> ids) {
|
||||
postApplicationService.deletePost(new BulkOperationCommand<>(ids));
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -19,9 +19,8 @@ import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import lombok.NonNull;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -93,7 +92,7 @@ public class SysRoleController extends BaseController {
|
||||
*/
|
||||
@Operation(summary = "删除角色")
|
||||
@PreAuthorize("@permission.has('system:role:remove')")
|
||||
@AccessLog(title = "角色管理", businessType = BusinessTypeEnum.ADD)
|
||||
@AccessLog(title = "角色管理", businessType = BusinessTypeEnum.DELETE)
|
||||
@DeleteMapping(value = "/{roleId}")
|
||||
public ResponseDTO<Void> remove(@PathVariable("roleId") List<Long> roleIds) {
|
||||
roleApplicationService.deleteRoleByBulk(roleIds);
|
||||
|
||||
@@ -22,8 +22,7 @@ import com.agileboot.domain.system.user.db.SearchUserDO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.NonNull;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.agileboot.admin.customize.aop.accessLog;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.common.utils.ServletHolderUtil;
|
||||
import com.agileboot.infrastructure.user.AuthenticationUtils;
|
||||
@@ -18,8 +17,8 @@ import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -35,7 +34,7 @@ public class OperationLogModel extends SysOperationLogEntity {
|
||||
|
||||
public void fillOperatorInfo() {
|
||||
// 获取当前的用户
|
||||
String ip = ServletUtil.getClientIP(request);
|
||||
String ip = ServletHolderUtil.getClientIp();
|
||||
setOperatorIp(ip);
|
||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||
if (loginUser != null) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.agileboot.admin.customize.async;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.agileboot.common.utils.ServletHolderUtil;
|
||||
import com.agileboot.common.utils.ip.IpRegionUtil;
|
||||
@@ -38,7 +37,7 @@ public class AsyncTaskFactory {
|
||||
ServletHolderUtil.getRequest().getHeader("User-Agent"));
|
||||
// 获取客户端浏览器
|
||||
final String browser = userAgent.getBrowser() != null ? userAgent.getBrowser().getName() : "";
|
||||
final String ip = ServletUtil.getClientIP(ServletHolderUtil.getRequest());
|
||||
final String ip = ServletHolderUtil.getClientIp();
|
||||
final String address = IpRegionUtil.getBriefLocationByIp(ip);
|
||||
// 获取客户端操作系统
|
||||
final String os = userAgent.getOperatingSystem() != null ? userAgent.getOperatingSystem().getName() : "";
|
||||
|
||||
@@ -4,11 +4,10 @@ import com.agileboot.infrastructure.user.AuthenticationUtils;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.login.TokenService;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import lombok.NonNull;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.agileboot.infrastructure.thread.ThreadPoolManager;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.login.TokenService;
|
||||
import com.agileboot.common.enums.common.LoginStatusEnum;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -9,7 +9,7 @@ import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import com.agileboot.common.utils.ServletHolderUtil;
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.constant.Constants.Captcha;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
@@ -31,8 +31,7 @@ import com.agileboot.common.enums.common.LoginStatusEnum;
|
||||
import com.agileboot.domain.system.user.db.SysUserEntity;
|
||||
import com.google.code.kaptcha.Producer;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.NonNull;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
@@ -204,7 +203,7 @@ public class LoginService {
|
||||
|
||||
SysUserEntity entity = redisCache.userCache.getObjectById(loginUser.getUserId());
|
||||
|
||||
entity.setLoginIp(ServletUtil.getClientIP(ServletHolderUtil.getRequest()));
|
||||
entity.setLoginIp(ServletHolderUtil.getClientIp());
|
||||
entity.setLoginDate(DateUtil.date());
|
||||
entity.updateById();
|
||||
}
|
||||
|
||||
@@ -16,9 +16,8 @@ import io.jsonwebtoken.SignatureException;
|
||||
import io.jsonwebtoken.UnsupportedJwtException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.agileboot.admin.customize.service.login;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import java.util.Collections;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
@@ -22,10 +23,8 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
@@ -87,7 +86,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
Set<Long> allMenuIds = allMenus.stream().map(SysMenuEntity::getMenuId).collect(Collectors.toSet());
|
||||
|
||||
return new RoleInfo(RoleInfo.ADMIN_ROLE_ID, RoleInfo.ADMIN_ROLE_KEY, DataScopeEnum.ALL, SetUtils.emptySet(),
|
||||
return new RoleInfo(RoleInfo.ADMIN_ROLE_ID, RoleInfo.ADMIN_ROLE_KEY, DataScopeEnum.ALL, Collections.emptySet(),
|
||||
RoleInfo.ADMIN_PERMISSIONS, allMenuIds);
|
||||
|
||||
}
|
||||
@@ -105,7 +104,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
DataScopeEnum dataScopeEnum = BasicEnumUtil.fromValue(DataScopeEnum.class, roleEntity.getDataScope());
|
||||
|
||||
Set<Long> deptIdSet = SetUtils.emptySet();
|
||||
Set<Long> deptIdSet = Collections.emptySet();
|
||||
if (StrUtil.isNotEmpty(roleEntity.getDeptIdSet())) {
|
||||
deptIdSet = StrUtil.split(roleEntity.getDeptIdSet(), ",").stream()
|
||||
.map(Convert::toLong).collect(Collectors.toSet());
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.agileboot.admin.customize.service.permission.model.checker.OnlySelfDa
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.SingleDeptDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.DataScopeEnum;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import javax.annotation.PostConstruct;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.domain.system.user.db.SysUserEntity;
|
||||
import com.agileboot.domain.system.user.db.SysUserService;
|
||||
import java.util.List;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -50,25 +50,21 @@ spring:
|
||||
datasource:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://localhost:33067/agileboot-pure?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 12345
|
||||
url: jdbc:mysql://mysql2.sqlpub.com:3307/agileboot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sslMode=REQUIRED
|
||||
username: ENC(s4kjpEsplGGLeV3YRNvJpJhDSOAO0tEf)
|
||||
password: ENC(hg/hxmducWsI8u83/eXgAi8yHBDFbB5z0xzwNtBejPc=)
|
||||
# 从库数据源
|
||||
# slave:
|
||||
# url: jdbc:mysql://localhost:33067/agileboot2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: root
|
||||
# password: 12345
|
||||
# slave:
|
||||
# url: jdbc:mysql://localhost:33067/agileboot2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
# username: root
|
||||
# password: 12345
|
||||
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
# 端口,默认为6379
|
||||
port: 36379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码
|
||||
password: 12345
|
||||
host: redis
|
||||
port: 6379
|
||||
database: 1
|
||||
password: ENC(s3HU866TUAjzrWStN7kpQQ==)
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
@@ -84,7 +80,7 @@ spring:
|
||||
|
||||
logging:
|
||||
file:
|
||||
path: D:/logs/agileboot-dev
|
||||
path: ./logs/agileboot-dev
|
||||
|
||||
|
||||
springdoc:
|
||||
@@ -103,3 +99,6 @@ agileboot:
|
||||
# 前端url请求转发前缀
|
||||
api-prefix: /dev-api
|
||||
demo-enabled: false
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: ${JASYPT_ENCRYPTOR_PASSWORD:}
|
||||
|
||||
@@ -10,7 +10,7 @@ spring:
|
||||
datasource:
|
||||
master:
|
||||
# h2 内存数据库 内存模式连接配置 库名: agileboot
|
||||
url: jdbc:h2:mem:agileboot;DB_CLOSE_DELAY=-1
|
||||
url: jdbc:h2:mem:agileboot;DB_CLOSE_DELAY=-1;MODE=MySQL
|
||||
h2:
|
||||
# 开启console 访问 默认false
|
||||
console:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8080
|
||||
port: 18080
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.agileboot.admin.config;
|
||||
|
||||
|
||||
import com.agileboot.admin.AgileBootAdminApplication;
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.constant.Constants.UploadSubDir;
|
||||
import java.io.File;
|
||||
import javax.annotation.Resource;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = AgileBootAdminApplication.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public class AgileBootConfigTest {
|
||||
|
||||
@Resource
|
||||
private AgileBootConfig config;
|
||||
|
||||
@Test
|
||||
public void testConfig() {
|
||||
String fileBaseDir = "D:\\agileboot\\profile";
|
||||
|
||||
Assertions.assertEquals("AgileBoot", config.getName());
|
||||
Assertions.assertEquals("1.0.0", config.getVersion());
|
||||
Assertions.assertEquals("2022", config.getCopyrightYear());
|
||||
Assertions.assertTrue(config.isDemoEnabled());
|
||||
Assertions.assertEquals(fileBaseDir, AgileBootConfig.getFileBaseDir());
|
||||
Assertions.assertFalse(AgileBootConfig.isAddressEnabled());
|
||||
Assertions.assertEquals("math", AgileBootConfig.getCaptchaType());
|
||||
Assertions.assertEquals("math", AgileBootConfig.getCaptchaType());
|
||||
Assertions.assertEquals(fileBaseDir + "\\import",
|
||||
AgileBootConfig.getFileBaseDir() + File.separator + UploadSubDir.IMPORT_PATH);
|
||||
Assertions.assertEquals(fileBaseDir + "\\avatar",
|
||||
AgileBootConfig.getFileBaseDir() + File.separator + UploadSubDir.AVATAR_PATH);
|
||||
Assertions.assertEquals(fileBaseDir + "\\download",
|
||||
AgileBootConfig.getFileBaseDir() + File.separator + UploadSubDir.DOWNLOAD_PATH);
|
||||
Assertions.assertEquals(fileBaseDir + "\\upload",
|
||||
AgileBootConfig.getFileBaseDir() + File.separator + UploadSubDir.UPLOAD_PATH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.CustomDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.apache.commons.collections4.SetUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CustomDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = customChecker.check(null, null);
|
||||
boolean check2 = customChecker.check(loginUser, null);
|
||||
boolean check3 = customChecker.check(null, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenTargetDeptIdNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(null, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenRoleIsNull() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
when(loginUser.getRoleInfo()).thenReturn(null);
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenNotContainTargetDeptId() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
loginUser.getRoleInfo().setDeptIdSet(SetUtils.hashSet(2L));
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenContainTargetDeptId() {
|
||||
CustomDataPermissionChecker customChecker = new CustomDataPermissionChecker(deptService);
|
||||
|
||||
loginUser.getRoleInfo().setDeptIdSet(SetUtils.hashSet(1L));
|
||||
boolean check = customChecker.check(loginUser, new DataCondition(1L, 1L));
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.DeptTreeDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DeptTreeDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
boolean check3 = checker.check(null, new DataCondition());
|
||||
boolean check4 = checker.check(loginUser, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
assertFalse(check4);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenIsChildOfDept() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(true);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenIsSameDept() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(false);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(1L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenFailed() {
|
||||
DeptTreeDataPermissionChecker checker = new DeptTreeDataPermissionChecker(deptService);
|
||||
|
||||
when(deptService.isChildOfTheDept(any(), any())).thenReturn(false);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.OnlySelfDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class OnlySelfDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
boolean check3 = checker.check(null, new DataCondition());
|
||||
boolean check4 = checker.check(new SystemLoginUser(), new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
assertFalse(check4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenSameUserId() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
SystemLoginUser loginUser = new SystemLoginUser();
|
||||
loginUser.setUserId(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetUserId(1L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenDifferentUserId() {
|
||||
OnlySelfDataPermissionChecker checker = new OnlySelfDataPermissionChecker(deptService);
|
||||
SystemLoginUser loginUser = new SystemLoginUser();
|
||||
loginUser.setUserId(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.agileboot.admin.customize.service.permission;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.agileboot.admin.customize.service.permission.model.checker.SingleDeptDataPermissionChecker;
|
||||
import com.agileboot.infrastructure.user.web.SystemLoginUser;
|
||||
import com.agileboot.infrastructure.user.web.RoleInfo;
|
||||
import com.agileboot.admin.customize.service.permission.model.DataCondition;
|
||||
import com.agileboot.domain.system.dept.db.SysDeptService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SingleDeptDataPermissionCheckerTest {
|
||||
|
||||
private final SysDeptService deptService = mock(SysDeptService.class);
|
||||
|
||||
public SystemLoginUser loginUser = mock(SystemLoginUser.class);
|
||||
|
||||
@BeforeEach
|
||||
public void mockBefore() {
|
||||
when(loginUser.getRoleInfo()).thenReturn(RoleInfo.EMPTY_ROLE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenParameterNull() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
|
||||
boolean check1 = checker.check(null, null);
|
||||
boolean check2 = checker.check(new SystemLoginUser(), null);
|
||||
boolean check3 = checker.check(null, new DataCondition());
|
||||
boolean check4 = checker.check(loginUser, new DataCondition());
|
||||
|
||||
assertFalse(check1);
|
||||
assertFalse(check2);
|
||||
assertFalse(check3);
|
||||
assertFalse(check4);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckWhenSameDeptId() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetDeptId(1L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertTrue(check);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCheckWhenDifferentDeptId() {
|
||||
SingleDeptDataPermissionChecker checker = new SingleDeptDataPermissionChecker(deptService);
|
||||
when(loginUser.getDeptId()).thenReturn(1L);
|
||||
DataCondition dataCondition = new DataCondition();
|
||||
dataCondition.setTargetUserId(2L);
|
||||
|
||||
boolean check = checker.check(loginUser, dataCondition);
|
||||
|
||||
assertFalse(check);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import com.agileboot.api.customize.service.JwtTokenService;
|
||||
import com.agileboot.infrastructure.user.app.AppLoginUser;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode.Client;
|
||||
import com.agileboot.common.utils.ServletHolderUtil;
|
||||
import com.agileboot.common.utils.jackson.JacksonUtil;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -13,9 +13,8 @@ import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import io.jsonwebtoken.SignatureException;
|
||||
import io.jsonwebtoken.UnsupportedJwtException;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
33
agileboot-boot-start/pom.xml
Normal file
33
agileboot-boot-start/pom.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>agileboot-boot-start</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-system-base</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-module-ai</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-satoken</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.agileboot;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-08-12 18:07
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class AgilebootBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AgilebootBootApplication.class, args);
|
||||
String successMsg = " ____ _ _ __ _ _ \n"
|
||||
+ " / ___| | |_ __ _ _ __ | |_ _ _ _ __ ___ _ _ ___ ___ ___ ___ ___ / _| _ _ | || |\n"
|
||||
+ " \\___ \\ | __|/ _` || '__|| __| | | | || '_ \\ / __|| | | | / __|/ __|/ _ \\/ __|/ __|| |_ | | | || || |\n"
|
||||
+ " ___) || |_| (_| || | | |_ | |_| || |_) | \\__ \\| |_| || (__| (__| __/\\__ \\\\__ \\| _|| |_| || ||_|\n"
|
||||
+ " |____/ \\__|\\__,_||_| \\__| \\__,_|| .__/ |___/ \\__,_| \\___|\\___|\\___||___/|___/|_| \\__,_||_|(_)\n"
|
||||
+ " |_| ";
|
||||
|
||||
System.out.println(successMsg);
|
||||
}
|
||||
}
|
||||
70
agileboot-boot-start/src/main/resources/application-dev.yml
Normal file
70
agileboot-boot-start/src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
webStatFilter:
|
||||
enabled: true
|
||||
statViewServlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: agileboot
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
dynamic:
|
||||
primary: master
|
||||
strict: false
|
||||
druid:
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
minIdle: 10
|
||||
# 最大连接池数量
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
maxEvictableIdleTimeMillis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://121.41.64.98:3306/agileboot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&sslMode=REQUIRED
|
||||
username: agileboot
|
||||
password: 123456
|
||||
|
||||
data:
|
||||
redis:
|
||||
database: 3
|
||||
host: 121.41.64.98
|
||||
port: 6379
|
||||
password: 'Wyy123123'
|
||||
|
||||
|
||||
sa-token:
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
||||
token-name: Authorization
|
||||
jasypt:
|
||||
encryptor:
|
||||
password: ${JASYPT_ENCRYPTOR_PASSWORD:}
|
||||
13
agileboot-boot-start/src/main/resources/application.yml
Normal file
13
agileboot-boot-start/src/main/resources/application.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
server:
|
||||
port: 8088
|
||||
servlet:
|
||||
context-path: /api
|
||||
tomcat:
|
||||
uri-encoding: UTF-8 # tomcat的URI编码
|
||||
accept-count: 1000 # 连接数满后的排队数,默认为100
|
||||
threads:
|
||||
max: 800 # tomcat最大线程数,默认为200
|
||||
min-spare: 100 # Tomcat启动初始化的线程数,默认值10
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
8
agileboot-boot-start/src/main/resources/banner.txt
Normal file
8
agileboot-boot-start/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Application Version: ${revision}
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
_ _ _ ____ _
|
||||
/ \ __ _ (_)| | ___ | __ ) ___ ___ | |_
|
||||
/ _ \ / _` || || | / _ \| _ \ / _ \ / _ \ | __|
|
||||
/ ___ \| (_| || || || __/| |_) || (_) || (_) || |_
|
||||
/_/ \_\\__, ||_||_| \___||____/ \___/ \___/ \__|
|
||||
|___/
|
||||
18
agileboot-cloud/agileboot-cloud-start/pom.xml
Normal file
18
agileboot-cloud/agileboot-cloud-start/pom.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-cloud</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>agileboot-cloud-start</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.agileboot;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author cuiJiaWang
|
||||
* @Create 2025-08-12 17:35
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class AgilebootCloudApplication {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
15
agileboot-cloud/pom.xml
Normal file
15
agileboot-cloud/pom.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>agileboot-cloud</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>agileboot-cloud-start</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
@@ -9,6 +9,18 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<modules>
|
||||
<module>wol-common-box</module>
|
||||
<module>wol-common-core</module>
|
||||
<module>wol-common-doc</module>
|
||||
<module>wol-common-web</module>
|
||||
<module>wol-common-mybatis</module>
|
||||
<module>wol-common-redis</module>
|
||||
<module>wol-common-json</module>
|
||||
<module>wol-common-satoken</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<artifactId>agileboot-common</artifactId>
|
||||
|
||||
<description>
|
||||
@@ -17,176 +29,78 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Spring框架基本的核心工具 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringWeb模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring security 安全认证 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-security</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 文件上传工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>commons-fileupload</groupId>-->
|
||||
<!-- <artifactId>commons-fileupload</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- yml解析器 -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.yaml</groupId>-->
|
||||
<!-- <artifactId>snakeyaml</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- Token生成与解析-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.jsonwebtoken</groupId>-->
|
||||
<!-- <artifactId>jjwt</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- Jaxb -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.xml.bind</groupId>-->
|
||||
<!-- <artifactId>jaxb-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- redis 缓存操作 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- pool 对象池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- 解析客户端操作系统、浏览器等 -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>eu.bitwalker</groupId>-->
|
||||
<!-- <artifactId>UserAgentUtils</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- servlet包 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>it.ozimov</groupId>-->
|
||||
<!-- <artifactId>embedded-redis</artifactId>-->
|
||||
<!-- <!– 不排除掉slf4j的话 会冲突–>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.slf4j</groupId>-->
|
||||
<!-- <artifactId>slf4j-simple</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- <!– 排除掉guava依赖,以本项目的guava依赖为准 –>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>com.google.guava</groupId>-->
|
||||
<!-- <artifactId>guava</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-parameter-names</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jdk8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>it.ozimov</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<!-- 不排除掉slf4j的话 会冲突-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
</exclusion>
|
||||
<!-- 排除掉guava依赖,以本项目的guava依赖为准 -->
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 多数据源 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>dynamic-datasource-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- swagger注解 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
<!--ENC加密-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.ulisesbocchio</groupId>-->
|
||||
<!-- <artifactId>jasypt-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>2.1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.agileboot.common.constant;
|
||||
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
public class Constants {
|
||||
private Constants() {
|
||||
}
|
||||
|
||||
public static final int KB = 1024;
|
||||
|
||||
public static final int MB = KB * 1024;
|
||||
|
||||
public static final int GB = MB * 1024;
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
|
||||
public static class Token {
|
||||
|
||||
private Token() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String PREFIX = "Bearer ";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
|
||||
}
|
||||
|
||||
public static class Captcha {
|
||||
|
||||
private Captcha() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
public static final String MATH_TYPE = "math";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String CHAR_TYPE = "char";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "profile";
|
||||
|
||||
public static class UploadSubDir {
|
||||
|
||||
private UploadSubDir() {
|
||||
}
|
||||
|
||||
public static final String IMPORT_PATH = "import";
|
||||
|
||||
public static final String AVATAR_PATH = "avatar";
|
||||
|
||||
public static final String DOWNLOAD_PATH = "download";
|
||||
|
||||
public static final String UPLOAD_PATH = "upload";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.agileboot.common.core.base;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class BaseEntity<T extends Model<?>> extends Model<T> {
|
||||
|
||||
@ApiModelProperty("创建者ID")
|
||||
@TableField(value = "creator_id", fill = FieldFill.INSERT)
|
||||
private Long creatorId;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("更新者ID")
|
||||
@TableField(value = "updater_id", fill = FieldFill.UPDATE, updateStrategy = FieldStrategy.NOT_NULL)
|
||||
private Long updaterId;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
@TableField(value = "update_time", fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* deleted字段请在数据库中 设置为tinyInt 并且非null 默认值为0
|
||||
*/
|
||||
@ApiModelProperty("删除标志(0代表存在 1代表删除)")
|
||||
@TableField("deleted")
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.agileboot.common.core.dto;
|
||||
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ResponseDTO<T> {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JsonInclude
|
||||
private T data;
|
||||
|
||||
public static <T> ResponseDTO<T> ok() {
|
||||
return build(null, ErrorCode.SUCCESS.code(), ErrorCode.SUCCESS.message());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> ok(T data) {
|
||||
return build(data, ErrorCode.SUCCESS.code(), ErrorCode.SUCCESS.message());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> fail() {
|
||||
return build(null, ErrorCode.FAILED.code(), ErrorCode.FAILED.message());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> fail(T data) {
|
||||
return build(data, ErrorCode.FAILED.code(), ErrorCode.FAILED.message());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> fail(ApiException exception) {
|
||||
return build(null, exception.getErrorCode().code(), exception.getMessage());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> fail(ApiException exception, T data) {
|
||||
return build(data, exception.getErrorCode().code(), exception.getMessage());
|
||||
}
|
||||
|
||||
public static <T> ResponseDTO<T> build(T data, Integer code, String msg) {
|
||||
return new ResponseDTO<>(code, msg, data);
|
||||
}
|
||||
|
||||
// 去掉直接填充错误码的方式, 这种方式不能拿到i18n的错误消息 统一通过ApiException来构造错误消息
|
||||
// public static <T> ResponseDTO<T> fail(ErrorCodeInterface code, Object... args) {
|
||||
// return build(null, code, args);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.agileboot.common.core.page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public abstract class AbstractPageQuery<T> extends AbstractQuery<T> {
|
||||
|
||||
public static final int MAX_PAGE_NUM = 200;
|
||||
public static final int MAX_PAGE_SIZE = 500;
|
||||
|
||||
@Max(MAX_PAGE_NUM)
|
||||
protected Integer pageNum = 1;
|
||||
@Max(MAX_PAGE_SIZE)
|
||||
protected Integer pageSize = 10;
|
||||
|
||||
public Page<T> toPage() {
|
||||
return new Page<>(pageNum, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.agileboot.common.core.page;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.utils.time.DatePickUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 如果是简单的排序 和 时间范围筛选 可以使用内置的这几个字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public abstract class AbstractQuery<T> {
|
||||
|
||||
protected String orderColumn;
|
||||
|
||||
protected String orderDirection;
|
||||
|
||||
protected String timeRangeColumn;
|
||||
|
||||
@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date beginTime;
|
||||
|
||||
@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
private static final String ASC = "ascending";
|
||||
private static final String DESC = "descending";
|
||||
|
||||
/**
|
||||
* 生成query conditions
|
||||
*
|
||||
* @return 添加条件后的QueryWrapper
|
||||
*/
|
||||
public QueryWrapper<T> toQueryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = addQueryCondition();
|
||||
addSortCondition(queryWrapper);
|
||||
addTimeCondition(queryWrapper);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
public abstract QueryWrapper<T> addQueryCondition();
|
||||
|
||||
public void addSortCondition(QueryWrapper<T> queryWrapper) {
|
||||
if (queryWrapper == null || StrUtil.isEmpty(orderColumn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Boolean sortDirection = convertSortDirection();
|
||||
if (sortDirection != null) {
|
||||
queryWrapper.orderBy(StrUtil.isNotEmpty(orderColumn), sortDirection,
|
||||
StrUtil.toUnderlineCase(orderColumn));
|
||||
}
|
||||
}
|
||||
|
||||
public void addTimeCondition(QueryWrapper<T> queryWrapper) {
|
||||
if (queryWrapper != null
|
||||
&& StrUtil.isNotEmpty(this.timeRangeColumn)) {
|
||||
queryWrapper
|
||||
.ge(beginTime != null, StrUtil.toUnderlineCase(timeRangeColumn),
|
||||
DatePickUtil.getBeginOfTheDay(beginTime))
|
||||
.le(endTime != null, StrUtil.toUnderlineCase(timeRangeColumn), DatePickUtil.getEndOfTheDay(endTime));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前端传来的排序方向 转换成MyBatisPlus所需的排序参数 boolean=isAsc
|
||||
* @return 排序顺序, null为无排序
|
||||
*/
|
||||
public Boolean convertSortDirection() {
|
||||
Boolean isAsc = null;
|
||||
if (StrUtil.isEmpty(this.orderDirection)) {
|
||||
return isAsc;
|
||||
}
|
||||
|
||||
if (ASC.equals(this.orderDirection)) {
|
||||
isAsc = true;
|
||||
}
|
||||
if (DESC.equals(this.orderDirection)) {
|
||||
isAsc = false;
|
||||
}
|
||||
|
||||
return isAsc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.agileboot.common.core.page;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分页模型类
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class PageDTO<T> {
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private Long total;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<T> rows;
|
||||
|
||||
public PageDTO(List<T> list) {
|
||||
this.rows = list;
|
||||
this.total = (long) list.size();
|
||||
}
|
||||
|
||||
public PageDTO(Page<T> page) {
|
||||
this.rows = page.getRecords();
|
||||
this.total = page.getTotal();
|
||||
}
|
||||
|
||||
public PageDTO(List<T> list, Long count) {
|
||||
this.rows = list;
|
||||
this.total = count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_operation_log的business_type
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysOperationLog.businessType")
|
||||
public enum BusinessTypeEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
OTHER(0, "其他操作", CssTag.INFO),
|
||||
ADD(1, "添加", CssTag.PRIMARY),
|
||||
MODIFY(2, "修改", CssTag.PRIMARY),
|
||||
DELETE(3, "删除", CssTag.DANGER),
|
||||
GRANT(4, "授权", CssTag.PRIMARY),
|
||||
EXPORT(5, "导出", CssTag.WARNING),
|
||||
IMPORT(6, "导入", CssTag.WARNING),
|
||||
FORCE_LOGOUT(7, "强退", CssTag.DANGER),
|
||||
CLEAN(8, "清空", CssTag.DANGER),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
BusinessTypeEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_user的sex字段
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysUser.sex")
|
||||
public enum GenderEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
MALE(1, "男", CssTag.PRIMARY),
|
||||
FEMALE(2, "女", CssTag.PRIMARY),
|
||||
UNKNOWN(0, "未知", CssTag.PRIMARY);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
GenderEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
* @author valarchie
|
||||
*/
|
||||
// TODO 表记得改成LoginLog
|
||||
@Dictionary(name = "sysLoginLog.status")
|
||||
public enum LoginStatusEnum implements DictionaryEnum<Integer> {
|
||||
/**
|
||||
* status of user
|
||||
*/
|
||||
LOGIN_SUCCESS(1, "登录成功", CssTag.SUCCESS),
|
||||
LOGOUT(2, "退出成功", CssTag.INFO),
|
||||
REGISTER(3, "注册", CssTag.PRIMARY),
|
||||
LOGIN_FAIL(0, "登录失败", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String msg;
|
||||
private final String cssTag;
|
||||
|
||||
LoginStatusEnum(int status, String msg, String cssTag) {
|
||||
this.value = status;
|
||||
this.msg = msg;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.BasicEnum;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Deprecated
|
||||
public enum MenuComponentEnum implements BasicEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 菜单组件类型
|
||||
*/
|
||||
LAYOUT(1,"Layout"),
|
||||
PARENT_VIEW(2,"ParentView"),
|
||||
INNER_LINK(3,"InnerLink");
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
MenuComponentEnum(int value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.BasicEnum;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
* 对应 sys_menu表的menu_type字段
|
||||
*/
|
||||
public enum MenuTypeEnum implements BasicEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
MENU(1, "页面"),
|
||||
CATALOG(2, "目录"),
|
||||
IFRAME(3, "内嵌Iframe"),
|
||||
OUTSIDE_LINK_REDIRECT(4, "外链跳转");
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
MenuTypeEnum(int value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_notice的 status字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysNotice.status")
|
||||
public enum NoticeStatusEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 通知状态
|
||||
*/
|
||||
OPEN(1, "正常", CssTag.PRIMARY),
|
||||
CLOSE(0, "关闭", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
NoticeStatusEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_notice的 notice_type字段
|
||||
* 名称一般由对应的表名.字段构成
|
||||
* 全局的话使用common作为表名
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysNotice.noticeType")
|
||||
public enum NoticeTypeEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
NOTIFICATION(1, "通知", CssTag.WARNING),
|
||||
ANNOUNCEMENT(2, "公告", CssTag.SUCCESS);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
NoticeTypeEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_operation_log的status字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysOperationLog.status")
|
||||
public enum OperationStatusEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*/
|
||||
SUCCESS(1, "成功", CssTag.PRIMARY),
|
||||
FAIL(0, "失败", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
OperationStatusEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.BasicEnum;
|
||||
|
||||
/**
|
||||
* 操作者类型
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysOperationLog.operatorType")
|
||||
public enum OperatorTypeEnum implements BasicEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
OTHER(1, "其他"),
|
||||
WEB(2, "Web用户"),
|
||||
MOBILE(3, "手机端用户");
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
OperatorTypeEnum(int value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.BasicEnum;
|
||||
|
||||
/**
|
||||
* Http Method
|
||||
* @author valarchie
|
||||
*/
|
||||
public enum RequestMethodEnum implements BasicEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
GET(1, "GET"),
|
||||
POST(2, "POST"),
|
||||
PUT(3, "PUT"),
|
||||
DELETE(4, "DELETE"),
|
||||
UNKNOWN(-1, "UNKNOWN");
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
RequestMethodEnum(int value, String description) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 除非表有特殊指明的话,一般用这个枚举代表 status字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "common.status")
|
||||
public enum StatusEnum implements DictionaryEnum<Integer> {
|
||||
/**
|
||||
* 开关状态
|
||||
*/
|
||||
ENABLE(1, "正常", CssTag.PRIMARY),
|
||||
DISABLE(0, "停用", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
StatusEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_user的status字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "sysUser.status")
|
||||
public enum UserStatusEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 用户账户状态
|
||||
*/
|
||||
NORMAL(1, "正常", CssTag.PRIMARY),
|
||||
DISABLED(2, "禁用", CssTag.DANGER),
|
||||
FROZEN(3, "冻结", CssTag.WARNING);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
|
||||
private final String cssTag;
|
||||
|
||||
UserStatusEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
|
||||
/**
|
||||
* 对应sys_menu表的is_visible字段
|
||||
* @author valarchie
|
||||
*/
|
||||
@Deprecated
|
||||
@Dictionary(name = "sysMenu.isVisible")
|
||||
public enum VisibleStatusEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 显示与否
|
||||
*/
|
||||
SHOW(1, "显示", CssTag.PRIMARY),
|
||||
HIDE(0, "隐藏", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
VisibleStatusEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.agileboot.common.enums.common;
|
||||
|
||||
import com.agileboot.common.enums.DictionaryEnum;
|
||||
import com.agileboot.common.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.enums.dictionary.Dictionary;
|
||||
|
||||
/**
|
||||
* 系统内代表是与否的枚举
|
||||
* @author valarchie
|
||||
*/
|
||||
@Dictionary(name = "common.yesOrNo")
|
||||
public enum YesOrNoEnum implements DictionaryEnum<Integer> {
|
||||
/**
|
||||
* 是与否
|
||||
*/
|
||||
YES(1, "是", CssTag.PRIMARY),
|
||||
NO(0, "否", CssTag.DANGER);
|
||||
|
||||
private final int value;
|
||||
private final String description;
|
||||
private final String cssTag;
|
||||
|
||||
YesOrNoEnum(int value, String description, String cssTag) {
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
this.cssTag = cssTag;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String cssTag() {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.agileboot.common.core.exception;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ApiExceptionTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void testVarargsWithArrayArgs() {
|
||||
String errorMsg = "these parameters are null: %s, %s, %s.";
|
||||
Object[] array = new Object[] { "param1" , "param2" , "param3"};
|
||||
|
||||
String formatWithArray = String.format(errorMsg, array);
|
||||
String formatWithVarargs = String.format(errorMsg, "param1", "param2", "param3");
|
||||
|
||||
Assert.assertEquals(formatWithVarargs, formatWithArray);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVarargsWithNullArgs() {
|
||||
String errorMsg = "these parameters are null: %s, %s, %s.";
|
||||
|
||||
String format = String.format(errorMsg, "param1", null, null);
|
||||
|
||||
Assert.assertEquals("these parameters are null: param1, null, null.", format);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.agileboot.common.enums;
|
||||
|
||||
|
||||
import com.agileboot.common.enums.common.YesOrNoEnum;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BasicEnumUtilTest {
|
||||
|
||||
@Test
|
||||
public void testFromValue() {
|
||||
|
||||
YesOrNoEnum yes = BasicEnumUtil.fromValue(YesOrNoEnum.class, 1);
|
||||
YesOrNoEnum no = BasicEnumUtil.fromValue(YesOrNoEnum.class, 0);
|
||||
|
||||
Assert.assertEquals(yes.description(), "是");
|
||||
Assert.assertEquals(no.description(), "否");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.agileboot.common.exception.error;
|
||||
|
||||
import com.agileboot.common.exception.error.ErrorCode.Client;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ErrorCodeInterfaceTest {
|
||||
|
||||
@Test
|
||||
void testI18nKey() {
|
||||
String i18nKey = Client.COMMON_FORBIDDEN_TO_CALL.i18nKey();
|
||||
Assertions.assertEquals("20001_COMMON_FORBIDDEN_TO_CALL", i18nKey);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.agileboot.common.query;
|
||||
|
||||
|
||||
import com.agileboot.common.core.page.AbstractQuery;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import java.util.Date;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class AbstractQueryTest {
|
||||
|
||||
private AbstractQuery query;
|
||||
|
||||
@BeforeEach
|
||||
public void getNewQuery() {
|
||||
query = new AbstractQuery<Object>() {
|
||||
@Override
|
||||
public QueryWrapper addQueryCondition() {
|
||||
return new QueryWrapper();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void addTimeConditionWithNull() {
|
||||
query.setTimeRangeColumn("loginTime");
|
||||
QueryWrapper<Object> queryWrapper = query.toQueryWrapper();
|
||||
|
||||
String targetSql = queryWrapper.getTargetSql();
|
||||
Assertions.assertEquals("", targetSql);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void addTimeConditionWithBothValue() {
|
||||
query.setBeginTime(new Date());
|
||||
query.setEndTime(new Date());
|
||||
query.setTimeRangeColumn("loginTime");
|
||||
|
||||
QueryWrapper<Object> queryWrapper = query.toQueryWrapper();
|
||||
|
||||
String targetSql = queryWrapper.getTargetSql();
|
||||
Assertions.assertEquals("(login_time >= ? AND login_time <= ?)", targetSql);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void addTimeConditionWithBeginValueOnly() {
|
||||
query.setBeginTime(new Date());
|
||||
query.setTimeRangeColumn("loginTime");
|
||||
|
||||
QueryWrapper<Object> queryWrapper = query.toQueryWrapper();
|
||||
|
||||
String targetSql = queryWrapper.getTargetSql();
|
||||
Assertions.assertEquals("(login_time >= ?)", targetSql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void testConvertSortDirection() {
|
||||
query.setOrderDirection("ascending");
|
||||
Assertions.assertTrue(query.convertSortDirection());
|
||||
|
||||
query.setOrderDirection("descending");
|
||||
Assertions.assertFalse(query.convertSortDirection());
|
||||
|
||||
query.setOrderDirection("");
|
||||
Assertions.assertNull(query.convertSortDirection());
|
||||
|
||||
query.setOrderDirection(null);
|
||||
Assertions.assertNull(query.convertSortDirection());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.agileboot.common.utils.file;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.constant.Constants.UploadSubDir;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode.Business;
|
||||
import com.agileboot.common.exception.error.ErrorCode.Internal;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
class FileUploadUtilsTest {
|
||||
|
||||
@Test
|
||||
void testIsAllowedExtension() {
|
||||
String[] imageTypes = new String[]{"img", "gif"};
|
||||
|
||||
boolean isAllow = FileUploadUtils.isExtensionAllowed("img", imageTypes);
|
||||
boolean isNotAllow = FileUploadUtils.isExtensionAllowed("png", imageTypes);
|
||||
|
||||
Assertions.assertTrue(isAllow);
|
||||
Assertions.assertFalse(isNotAllow);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsAllowedExtensionWhenNull() {
|
||||
String[] imageTypes = null;
|
||||
|
||||
boolean isAllow = FileUploadUtils.isExtensionAllowed("img", imageTypes);
|
||||
|
||||
Assertions.assertTrue(isAllow);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetRelativeFileUrl() {
|
||||
String relativeFilePath = FileUploadUtils.getRelativeFileUrl(UploadSubDir.UPLOAD_PATH, "test.jpg");
|
||||
|
||||
Assertions.assertEquals("/profile/upload/test.jpg", relativeFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSaveFileToLocal() {
|
||||
MultipartFile fileMock = Mockito.mock(MultipartFile.class);
|
||||
|
||||
ApiException exceptionWithNullSubDir = Assertions.assertThrows(ApiException.class,
|
||||
() -> FileUploadUtils.saveFileToLocal(fileMock, "", ""));
|
||||
ApiException exceptionWitEmptyFileName = Assertions.assertThrows(ApiException.class,
|
||||
() -> FileUploadUtils.saveFileToLocal(fileMock, "", ""));
|
||||
|
||||
Assertions.assertEquals(Internal.INVALID_PARAMETER, exceptionWithNullSubDir.getErrorCode());
|
||||
Assertions.assertEquals(Internal.INVALID_PARAMETER, exceptionWitEmptyFileName.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsAllowedUploadWhenFileNameTooLong() {
|
||||
MultipartFile fileMock = Mockito.mock(MultipartFile.class);
|
||||
String longFileName = "this is a very very long sentence, this is a very very long sentence, "
|
||||
+ "this is a very very long sentence, this is a very very long sentence, ";
|
||||
|
||||
Mockito.when(fileMock.getOriginalFilename()).thenReturn(longFileName);
|
||||
|
||||
ApiException exception = Assertions.assertThrows(ApiException.class,
|
||||
() -> FileUploadUtils.isAllowedUpload(fileMock, null));
|
||||
Assertions.assertEquals(Business.UPLOAD_FILE_NAME_EXCEED_MAX_LENGTH, exception.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsAllowedUploadWhenFileTooBig() {
|
||||
MultipartFile fileMock = Mockito.mock(MultipartFile.class);
|
||||
Mockito.when(fileMock.getOriginalFilename()).thenReturn("test.jpg");
|
||||
Mockito.when(fileMock.getSize()).thenReturn(FileUploadUtils.MAX_FILE_SIZE + 1);
|
||||
|
||||
ApiException exception = Assertions.assertThrows(ApiException.class,
|
||||
() -> FileUploadUtils.isAllowedUpload(fileMock, null));
|
||||
Assertions.assertEquals(Business.UPLOAD_FILE_SIZE_EXCEED_MAX_SIZE, exception.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testisAllowDownload() {
|
||||
Assertions.assertFalse(FileUploadUtils.isAllowDownload("../test.jpg"));
|
||||
Assertions.assertFalse(FileUploadUtils.isAllowDownload("../test.exe"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetFileExtension() {
|
||||
MultipartFile fileMock = Mockito.mock(MultipartFile.class);
|
||||
Mockito.when(fileMock.getOriginalFilename()).thenReturn("test.jpg");
|
||||
|
||||
String fileExtension = FileUploadUtils.getFileExtension(fileMock);
|
||||
|
||||
Assertions.assertEquals("jpg", fileExtension);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateFilename() {
|
||||
String fileName = "test.jpg";
|
||||
MultipartFile fileMock = Mockito.mock(MultipartFile.class);
|
||||
Mockito.when(fileMock.getOriginalFilename()).thenReturn(fileName);
|
||||
|
||||
String randomFileName = FileUploadUtils.generateFilename(fileMock);
|
||||
|
||||
String[] nameParts = randomFileName.split("_");
|
||||
Assertions.assertEquals("test", nameParts[1]);
|
||||
Assertions.assertTrue(StrUtil.endWith(nameParts[2], ".jpg"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void getFileAbsolutePath() {
|
||||
AgileBootConfig agileBootConfig = new AgileBootConfig();
|
||||
agileBootConfig.setFileBaseDir("D:\\agileboot");
|
||||
|
||||
String fileAbsolutePath = FileUploadUtils.getFileAbsolutePath(UploadSubDir.AVATAR_PATH, "test.jpg");
|
||||
|
||||
Assertions.assertEquals("D:\\agileboot\\profile\\avatar\\test.jpg", fileAbsolutePath);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.agileboot.common.utils.ip;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class IpRegionUtilTest {
|
||||
|
||||
@Test
|
||||
void testGetIpRegion() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion("110.81.189.80");
|
||||
|
||||
Assertions.assertEquals("中国", ipRegion.getCountry());
|
||||
Assertions.assertEquals("福建省", ipRegion.getProvince());
|
||||
Assertions.assertEquals("泉州市", ipRegion.getCity());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWhenLocalHost() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion("127.0.0.1");
|
||||
Assertions.assertEquals("内网IP", ipRegion.briefLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithIpv6() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion("2001:0DB8:0000:0023:0008:0800:200C:417A");
|
||||
|
||||
Assertions.assertNotNull(ipRegion);
|
||||
Assertions.assertNull(ipRegion.getCountry());
|
||||
Assertions.assertEquals("未知 未知", ipRegion.briefLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithEmpty() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion("");
|
||||
|
||||
Assertions.assertNotNull(ipRegion);
|
||||
Assertions.assertNull(ipRegion.getCountry());
|
||||
Assertions.assertEquals("未知 未知", ipRegion.briefLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithNull() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion(null);
|
||||
|
||||
Assertions.assertNotNull(ipRegion);
|
||||
Assertions.assertNull(ipRegion.getCountry());
|
||||
Assertions.assertEquals("未知 未知", ipRegion.briefLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithWrongIpString() {
|
||||
IpRegion ipRegion = IpRegionUtil.getIpRegion("xsdfwefsfsd");
|
||||
|
||||
Assertions.assertNotNull(ipRegion);
|
||||
Assertions.assertNull(ipRegion.getCountry());
|
||||
Assertions.assertEquals("未知 未知", ipRegion.briefLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBriefLocationByIp() {
|
||||
String briefLocationByIp = IpRegionUtil.getBriefLocationByIp("110.81.189.80");
|
||||
|
||||
Assertions.assertEquals("福建省 泉州市", briefLocationByIp);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.agileboot.common.utils.ip;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class IpUtilTest {
|
||||
|
||||
@Test
|
||||
void isInnerIp() {
|
||||
boolean innerIp1 = IpUtil.isLocalHost("127.0.0.1");
|
||||
boolean innerIp2 = IpUtil.isLocalHost("0:0:0:0:0:0:0:1");
|
||||
boolean innerIp3 = IpUtil.isLocalHost("localhost");
|
||||
boolean innerIp4 = IpUtil.isLocalHost("192.168.1.1");
|
||||
boolean innerIp5 = IpUtil.isLocalHost("10.32.1.1");
|
||||
boolean innerIp6 = IpUtil.isLocalHost("172.16.1.1");
|
||||
boolean notInnerIP = IpUtil.isLocalHost("110.81.189.80");
|
||||
|
||||
Assertions.assertTrue(innerIp1);
|
||||
Assertions.assertTrue(innerIp2);
|
||||
Assertions.assertTrue(innerIp3);
|
||||
Assertions.assertTrue(innerIp4);
|
||||
Assertions.assertTrue(innerIp5);
|
||||
Assertions.assertTrue(innerIp6);
|
||||
Assertions.assertFalse(notInnerIP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isLocalHost() {
|
||||
boolean localHost1 = IpUtil.isLocalHost("127.0.0.1");
|
||||
boolean localHost2 = IpUtil.isLocalHost("0:0:0:0:0:0:0:1");
|
||||
boolean localHost4 = IpUtil.isLocalHost("localhost");
|
||||
boolean notLocalHost = IpUtil.isLocalHost("110.81.189.80");
|
||||
|
||||
Assertions.assertTrue(localHost1);
|
||||
Assertions.assertTrue(localHost2);
|
||||
Assertions.assertTrue(localHost4);
|
||||
Assertions.assertFalse(notLocalHost);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.agileboot.common.utils.ip;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class OfflineIpRegionUtilTest {
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWhenIpv4() {
|
||||
IpRegion ipRegion = OfflineIpRegionUtil.getIpRegion("110.81.189.80");
|
||||
|
||||
Assertions.assertEquals("中国", ipRegion.getCountry());
|
||||
Assertions.assertEquals("福建省", ipRegion.getProvince());
|
||||
Assertions.assertEquals("泉州市", ipRegion.getCity());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithIpv6() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OfflineIpRegionUtil.getIpRegion("2001:0DB8:0000:0023:0008:0800:200C:417A")
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithEmpty() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OfflineIpRegionUtil.getIpRegion("")
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithNull() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OfflineIpRegionUtil.getIpRegion(null)
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetIpRegionWithWrongIpString() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OfflineIpRegionUtil.getIpRegion("asfdsfdsff")
|
||||
);
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.agileboot.common.utils.ip;
|
||||
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class OnlineIpRegionUtilTest {
|
||||
|
||||
@BeforeEach
|
||||
public void enableOnlineAddressQuery() {
|
||||
AgileBootConfig agileBootConfig = new AgileBootConfig();
|
||||
agileBootConfig.setAddressEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void getIpRegionWithIpv6() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OnlineIpRegionUtil.getIpRegion("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789")
|
||||
);
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIpRegionWithIpv4() {
|
||||
IpRegion ipRegion = OnlineIpRegionUtil.getIpRegion("120.42.247.130");
|
||||
|
||||
Assertions.assertEquals("福建省", ipRegion.getProvince());
|
||||
Assertions.assertEquals("泉州市", ipRegion.getCity());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIpRegionWithEmpty() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OnlineIpRegionUtil.getIpRegion("")
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void getIpRegionWithNull() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OnlineIpRegionUtil.getIpRegion(null)
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getIpRegionWithWrongIpString() {
|
||||
IpRegion region = Assertions.assertDoesNotThrow(() ->
|
||||
OnlineIpRegionUtil.getIpRegion("seffsdfsdf")
|
||||
);
|
||||
|
||||
Assertions.assertNull(region);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.agileboot.common.utils.jackson;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author duanxinyuan 2019/1/21 18:17
|
||||
*/
|
||||
public class JacksonUtilTest {
|
||||
|
||||
@Test
|
||||
public void testObjectToJson() {
|
||||
Person person = Person.newPerson();
|
||||
|
||||
String jacksonStr = JacksonUtil.to(person);
|
||||
Assert.assertEquals(DateUtil.formatDateTime(person.getDate()), JacksonUtil.getAsString(jacksonStr, "date"));
|
||||
Assert.assertEquals(DateUtil.formatLocalDateTime(person.getLocalDateTime()),
|
||||
JacksonUtil.getAsString(jacksonStr, "localDateTime"));
|
||||
Assert.assertEquals(person.getName(), JacksonUtil.getAsString(jacksonStr, "name"));
|
||||
Assert.assertEquals(person.getAge(), JacksonUtil.getAsInt(jacksonStr, "age"));
|
||||
Assert.assertEquals(person.isMan(), JacksonUtil.getAsBoolean(jacksonStr, "man"));
|
||||
Assert.assertEquals(person.getMoney(), JacksonUtil.getAsBigDecimal(jacksonStr, "money"));
|
||||
Assert.assertEquals(person.getTrait(), JacksonUtil.getAsList(jacksonStr, "trait", String.class));
|
||||
|
||||
Assert.assertNotNull(JacksonUtil.getAsString(jacksonStr, "name"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试兼容情况
|
||||
*/
|
||||
@Test
|
||||
public void testAllPrimitiveTypeToJson() {
|
||||
String json = "{\n"
|
||||
+ "\"code\": \"200\",\n"
|
||||
+ "\"id\": \"2001215464647687987\",\n"
|
||||
+ "\"message\": \"success\",\n"
|
||||
+ "\"amount\": \"1.12345\",\n"
|
||||
+ "\"amount1\": \"0.12345\",\n"
|
||||
+ "\"isSuccess\": \"true\",\n"
|
||||
+ "\"isSuccess1\": \"1\",\n"
|
||||
+ "\"key\": \"8209167202090377654857374178856064487200234961995543450245362822537162918731039965956758726661669012305745755921310000297396309887550627402157318910581311\"\n"
|
||||
+ "}";
|
||||
Assert.assertEquals(200, JacksonUtil.getAsInt(json, "code"));
|
||||
Assert.assertEquals(2001215464647687987L,JacksonUtil.getAsLong(json, "id"));
|
||||
Assert.assertEquals("success", JacksonUtil.getAsString(json, "message"));
|
||||
Assert.assertEquals(new BigDecimal("1.12345"), JacksonUtil.getAsBigDecimal(json, "amount"));
|
||||
Assert.assertEquals(new BigDecimal("0.12345"), JacksonUtil.getAsBigDecimal(json, "amount1"));
|
||||
Assert.assertEquals(1.12345d, JacksonUtil.getAsDouble(json, "amount"), 0.00001);
|
||||
Assert.assertEquals(0.12345d, JacksonUtil.getAsDouble(json, "amount1"), 0.00001);
|
||||
Assert.assertTrue(JacksonUtil.getAsBoolean(json, "isSuccess"));
|
||||
Assert.assertTrue(JacksonUtil.getAsBoolean(json, "isSuccess1"));
|
||||
Assert.assertEquals(new BigInteger(
|
||||
"8209167202090377654857374178856064487200234961995543450245362822537162918731039965956758726661669012305745755921310000297396309887550627402157318910581311"),
|
||||
JacksonUtil.getAsBigInteger(json, "key"));
|
||||
Assert.assertEquals("1", JacksonUtil.getAsString(json, "isSuccess1"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.agileboot.common.utils.jackson;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author duanxinyuan
|
||||
* 2018/6/29 14:17
|
||||
*/
|
||||
@Data
|
||||
public class Person {
|
||||
public String name;
|
||||
public Date date;
|
||||
public LocalDateTime localDateTime;
|
||||
public int age;
|
||||
public BigDecimal money;
|
||||
public boolean man;
|
||||
public ArrayList<String> trait;
|
||||
public HashMap<String, String> cards;
|
||||
|
||||
public static Person newPerson() {
|
||||
Person person = new Person();
|
||||
person.name = "张三";
|
||||
person.date = new Date();
|
||||
person.localDateTime = LocalDateTime.now();
|
||||
person.age = 100;
|
||||
person.money = BigDecimal.valueOf(500.21);
|
||||
person.man = true;
|
||||
person.trait = new ArrayList<>();
|
||||
person.trait.add("淡然");
|
||||
person.trait.add("温和");
|
||||
person.cards = new HashMap<>();
|
||||
person.cards.put("身份证", "4a6d456as");
|
||||
person.cards.put("建行卡", "649874545");
|
||||
return person;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.agileboot.common.utils.poi;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.http.HtmlUtil;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CustomExcelUtilTest {
|
||||
|
||||
@Test
|
||||
void testImportAndExport() {
|
||||
PostDTO post1 = new PostDTO(1L, "admin1", "管理员1", "1", "无备注", "1", "正常");
|
||||
PostDTO post2 = new PostDTO(2L, "admin2", "管理员2<script>alert(1)</script>", "2", "无备注", "1", "正常");
|
||||
|
||||
List<PostDTO> postDTOList = new ArrayList<>();
|
||||
postDTOList.add(post1);
|
||||
postDTOList.add(post2);
|
||||
|
||||
File file = FileUtil.createTempFile();
|
||||
|
||||
CustomExcelUtil.writeToOutputStream(postDTOList, PostDTO.class, FileUtil.getOutputStream(file));
|
||||
|
||||
List<PostDTO> postListFromExcel = CustomExcelUtil.readFromInputStream(PostDTO.class, FileUtil.getInputStream(file));
|
||||
|
||||
PostDTO post1fromExcel = postListFromExcel.get(0);
|
||||
PostDTO post2fromExcel = postListFromExcel.get(1);
|
||||
|
||||
Assertions.assertEquals(post1.getPostId(), post1fromExcel.getPostId());
|
||||
Assertions.assertEquals(post1.getPostCode(), post1fromExcel.getPostCode());
|
||||
Assertions.assertEquals(post2.getPostId(), post2fromExcel.getPostId());
|
||||
Assertions.assertEquals(post2.getPostCode(), post2fromExcel.getPostCode());
|
||||
// 检查脚本注入的字符串是否被去除
|
||||
Assertions.assertNotEquals(post2.getPostName(), post2fromExcel.getPostName());
|
||||
Assertions.assertEquals(HtmlUtil.cleanHtmlTag(post2.getPostName()), post2fromExcel.getPostName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.agileboot.common.utils.poi;
|
||||
|
||||
import com.agileboot.common.annotation.ExcelColumn;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class PostDTO {
|
||||
|
||||
@ExcelColumn(name = "岗位ID")
|
||||
private Long postId;
|
||||
|
||||
|
||||
@ExcelColumn(name = "岗位编码")
|
||||
private String postCode;
|
||||
|
||||
@ExcelColumn(name = "岗位名称")
|
||||
private String postName;
|
||||
|
||||
|
||||
@ExcelColumn(name = "岗位排序")
|
||||
private String postSort;
|
||||
|
||||
@ExcelColumn(name = "备注")
|
||||
private String remark;
|
||||
|
||||
private String status;
|
||||
|
||||
@ExcelColumn(name = "状态")
|
||||
private String statusStr;
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.agileboot.common.utils.time;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DatePickUtilTest {
|
||||
|
||||
@Test
|
||||
void testGetBeginOfTheDay() {
|
||||
Date beginOfTheDay = DatePickUtil.getBeginOfTheDay(new Date());
|
||||
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(beginOfTheDay);
|
||||
|
||||
Assertions.assertEquals(0, instance.get(Calendar.HOUR));
|
||||
Assertions.assertEquals(0, instance.get(Calendar.MINUTE));
|
||||
Assertions.assertEquals(0, instance.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetBeginOfTheDayWhenNull() {
|
||||
Assertions.assertDoesNotThrow(() -> DatePickUtil.getBeginOfTheDay(null)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetEndOfTheDay() {
|
||||
Date endOfTheDay = DatePickUtil.getEndOfTheDay(new Date());
|
||||
|
||||
Calendar instance = Calendar.getInstance();
|
||||
instance.setTime(endOfTheDay);
|
||||
|
||||
Assertions.assertEquals(23, instance.get(Calendar.HOUR_OF_DAY));
|
||||
Assertions.assertEquals(59, instance.get(Calendar.MINUTE));
|
||||
Assertions.assertEquals(59, instance.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetEndOfTheDayWhenNull() {
|
||||
Assertions.assertDoesNotThrow(() -> DatePickUtil.getEndOfTheDay(null)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
60
agileboot-common/wol-common-box/pom.xml
Normal file
60
agileboot-common/wol-common-box/pom.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-box</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<revision>1.0.0</revision>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-doc</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-mybatis</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-redis</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-json</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>wol-common-satoken</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
||||
106
agileboot-common/wol-common-core/pom.xml
Normal file
106
agileboot-common/wol-common-core/pom.xml
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.agileboot</groupId>
|
||||
<artifactId>agileboot-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>wol-common-core</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring框架基本的核心工具 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<!-- servlet包 -->
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringWeb模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<!-- pool 对象池 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
</dependency>
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
</dependency>
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<!--常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-parameter-names</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jdk8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
<!--ENC加密-->
|
||||
<dependency>
|
||||
<groupId>com.github.ulisesbocchio</groupId>
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger注解 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.common.annotation;
|
||||
package com.agileboot.common.core.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.common.annotation;
|
||||
package com.agileboot.common.core.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.agileboot.common.config;
|
||||
package com.agileboot.common.core.config;
|
||||
|
||||
import com.agileboot.common.constant.Constants;
|
||||
import com.agileboot.common.core.constant.Constants;
|
||||
import java.io.File;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.agileboot.common.core.constant;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface Constants {
|
||||
|
||||
int KB = 1024;
|
||||
int MB = KB * 1024;
|
||||
int GB = MB * 1024;
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
String RESOURCE_PREFIX = "profile";
|
||||
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* GBK 字符集
|
||||
*/
|
||||
String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* www主域
|
||||
*/
|
||||
String WWW = "www.";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 通用成功标识
|
||||
*/
|
||||
String SUCCESS = "0";
|
||||
String NORMAL = "0"; // 正常状态
|
||||
|
||||
/**
|
||||
* 通用失败标识
|
||||
*/
|
||||
String FAIL = "1";
|
||||
String DISABLE = "1"; // 异常/停用状态
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*/
|
||||
String LOGIN_SUCCESS = "Success";
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
String REGISTER = "Register";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*/
|
||||
String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
Integer CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
/**
|
||||
* 顶级部门id
|
||||
*/
|
||||
Long TOP_PARENT_ID = 0L;
|
||||
/**
|
||||
* 超级管理员ID
|
||||
*/
|
||||
Long SUPER_ADMIN_ID = 1L;
|
||||
/**
|
||||
* 超级管理员角色 roleKey
|
||||
*/
|
||||
String SUPER_ADMIN_ROLE_KEY = "superadmin";
|
||||
|
||||
/**
|
||||
* 租户管理员角色 roleKey
|
||||
*/
|
||||
String TENANT_ADMIN_ROLE_KEY = "admin";
|
||||
|
||||
/**
|
||||
* 租户管理员角色名称
|
||||
*/
|
||||
String TENANT_ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
/**
|
||||
* 默认租户ID
|
||||
*/
|
||||
String DEFAULT_TENANT_ID = "000000";
|
||||
|
||||
interface Cache {
|
||||
/**
|
||||
* 全局 redis key (业务无关的key)
|
||||
*/
|
||||
String GLOBAL_REDIS_KEY = "global:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
String CAPTCHA_CODE_KEY = GLOBAL_REDIS_KEY + "captcha_codes:";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.agileboot.common.core.constant;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface HttpStatus {
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 对象创建成功
|
||||
*/
|
||||
int CREATED = 201;
|
||||
|
||||
/**
|
||||
* 请求已经被接受
|
||||
*/
|
||||
int ACCEPTED = 202;
|
||||
|
||||
/**
|
||||
* 操作已经执行成功,但是没有返回数据
|
||||
*/
|
||||
int NO_CONTENT = 204;
|
||||
|
||||
/**
|
||||
* 资源已被移除
|
||||
*/
|
||||
int MOVED_PERM = 301;
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
*/
|
||||
int SEE_OTHER = 303;
|
||||
|
||||
/**
|
||||
* 资源没有被修改
|
||||
*/
|
||||
int NOT_MODIFIED = 304;
|
||||
|
||||
/**
|
||||
* 参数列表错误(缺少,格式不匹配)
|
||||
*/
|
||||
int BAD_REQUEST = 400;
|
||||
|
||||
/**
|
||||
* 未授权
|
||||
*/
|
||||
int UNAUTHORIZED = 401;
|
||||
|
||||
/**
|
||||
* 访问受限,授权过期
|
||||
*/
|
||||
int FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* 资源,服务未找到
|
||||
*/
|
||||
int NOT_FOUND = 404;
|
||||
|
||||
/**
|
||||
* 不允许的http方法
|
||||
*/
|
||||
int BAD_METHOD = 405;
|
||||
|
||||
/**
|
||||
* 资源冲突,或者资源被锁
|
||||
*/
|
||||
int CONFLICT = 409;
|
||||
|
||||
/**
|
||||
* 不支持的数据,媒体类型
|
||||
*/
|
||||
int UNSUPPORTED_TYPE = 415;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
int ERROR = 500;
|
||||
|
||||
/**
|
||||
* 接口未实现
|
||||
*/
|
||||
int NOT_IMPLEMENTED = 501;
|
||||
|
||||
/**
|
||||
* 系统警告消息
|
||||
*/
|
||||
int WARN = 601;
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.agileboot.common.core.core;
|
||||
|
||||
import com.agileboot.common.core.constant.HttpStatus;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int FAIL = 500;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 数据对象
|
||||
*/
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, SUCCESS, "操作成功");
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, SUCCESS, "操作成功");
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(String msg) {
|
||||
return restResult(null, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(String msg, T data) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, "操作失败");
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data) {
|
||||
return restResult(data, FAIL, "操作失败");
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg, T data) {
|
||||
return restResult(data, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static <T> R<T> warn(String msg) {
|
||||
return restResult(null, HttpStatus.WARN, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回警告消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static <T> R<T> warn(String msg, T data) {
|
||||
return restResult(data, HttpStatus.WARN, msg);
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> r = new R<>();
|
||||
r.setCode(code);
|
||||
r.setData(data);
|
||||
r.setMsg(msg);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static <T> Boolean isError(R<T> ret) {
|
||||
return !isSuccess(ret);
|
||||
}
|
||||
|
||||
public static <T> Boolean isSuccess(R<T> ret) {
|
||||
return R.SUCCESS == ret.getCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.common.core.base;
|
||||
package com.agileboot.common.core.core.base;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.common.enums;
|
||||
package com.agileboot.common.core.enums;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
@@ -18,7 +18,7 @@ public interface BasicEnum<T>{
|
||||
* 获取枚举的描述
|
||||
* @return 描述
|
||||
*/
|
||||
String description();
|
||||
String getDesc();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.agileboot.common.enums;
|
||||
package com.agileboot.common.core.enums;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.common.enums.BasicEnum;
|
||||
import com.agileboot.common.core.exception.ApiException;
|
||||
import com.agileboot.common.core.exception.error.ErrorCode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -55,7 +54,7 @@ public class BasicEnumUtil {
|
||||
public static <E extends Enum<E>> String getDescriptionByValue(Class<E> enumClass, Object value) {
|
||||
E basicEnum = fromValueSafely(enumClass, value);
|
||||
if (basicEnum != null) {
|
||||
return ((BasicEnum<?>) basicEnum).description();
|
||||
return ((BasicEnum<?>) basicEnum).getDesc();
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.common.enums;
|
||||
package com.agileboot.common.core.enums;
|
||||
|
||||
/**
|
||||
* 字典类型 接口
|
||||
@@ -10,6 +10,6 @@ public interface DictionaryEnum<T> extends BasicEnum<T> {
|
||||
* 获取css标签
|
||||
* @return css标签
|
||||
*/
|
||||
String cssTag();
|
||||
String getCssTag();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.agileboot.common.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 登录类型
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginType {
|
||||
|
||||
/**
|
||||
* 密码登录
|
||||
*/
|
||||
PASSWORD("user.password.retry.limit.exceed", "user.password.retry.limit.count"),
|
||||
|
||||
/**
|
||||
* 短信登录
|
||||
*/
|
||||
SMS("sms.code.retry.limit.exceed", "sms.code.retry.limit.count"),
|
||||
|
||||
/**
|
||||
* 邮箱登录
|
||||
*/
|
||||
EMAIL("email.code.retry.limit.exceed", "email.code.retry.limit.count"),
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
*/
|
||||
XCX("", "");
|
||||
|
||||
/**
|
||||
* 登录重试超出限制提示
|
||||
*/
|
||||
final String retryLimitExceed;
|
||||
|
||||
/**
|
||||
* 登录重试限制计数提示
|
||||
*/
|
||||
final String retryLimitCount;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.agileboot.common.core.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum UserType {
|
||||
|
||||
/**
|
||||
* 后台系统用户
|
||||
*/
|
||||
SYS_USER("sys_user"),
|
||||
|
||||
/**
|
||||
* 移动客户端用户
|
||||
*/
|
||||
APP_USER("app_user");
|
||||
|
||||
/**
|
||||
* 用户类型标识(用于 token、权限识别等)
|
||||
*/
|
||||
private final String userType;
|
||||
|
||||
public static UserType getUserType(String str) {
|
||||
for (UserType value : values()) {
|
||||
if (StringUtils.contains(str, value.getUserType())) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("'UserType' not found By " + str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.agileboot.common.core.enums.common;
|
||||
|
||||
import com.agileboot.common.core.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.core.enums.dictionary.Dictionary;
|
||||
import com.agileboot.common.core.enums.DictionaryEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 对应sys_operation_log的business_type
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@Dictionary(name = "sysOperationLog.businessType")
|
||||
public enum BusinessTypeEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
OTHER(0, "其他操作", CssTag.INFO),
|
||||
ADD(1, "添加", CssTag.PRIMARY),
|
||||
MODIFY(2, "修改", CssTag.PRIMARY),
|
||||
DELETE(3, "删除", CssTag.DANGER),
|
||||
GRANT(4, "授权", CssTag.PRIMARY),
|
||||
EXPORT(5, "导出", CssTag.WARNING),
|
||||
IMPORT(6, "导入", CssTag.WARNING),
|
||||
FORCE_LOGOUT(7, "强退", CssTag.DANGER),
|
||||
CLEAN(8, "清空", CssTag.DANGER),
|
||||
;
|
||||
|
||||
private final Integer value;
|
||||
private final String desc;
|
||||
private final String cssTag;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.agileboot.common.core.enums.common;
|
||||
|
||||
import com.agileboot.common.core.enums.DictionaryEnum;
|
||||
import com.agileboot.common.core.enums.dictionary.CssTag;
|
||||
import com.agileboot.common.core.enums.dictionary.Dictionary;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 对应sys_user的sex字段
|
||||
*
|
||||
* @author valarchie
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
@Dictionary(name = "sysUser.sex")
|
||||
public enum GenderEnum implements DictionaryEnum<Integer> {
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
MALE(1, "男", CssTag.PRIMARY),
|
||||
FEMALE(2, "女", CssTag.PRIMARY),
|
||||
UNKNOWN(0, "未知", CssTag.PRIMARY);
|
||||
|
||||
private final Integer value;
|
||||
private final String desc;
|
||||
private final String cssTag;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user