mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-11-12 06:57:10 +08:00
Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0c449870f | |||
| 67edb0828d | |||
| e05e0de7b8 | |||
| 2f2aae08ab | |||
| 3f7f118d3e | |||
| 17272a7809 | |||
| 07e1637363 | |||
| a0b64b81d5 | |||
| 778a861fa9 | |||
| d32c05166d | |||
| 4719a349dd | |||
| b4cb147a77 | |||
| aefd61b855 | |||
| 3be0d90018 | |||
| 34deff959a | |||
| 3dad27df3f | |||
| dcd185f532 | |||
| 69dbd0703c | |||
| a0ace7d60c | |||
| 0729be287c | |||
| e1c9a91c77 | |||
| 68f1f41cc9 | |||
| cce1b5560b | |||
| 223236aad3 | |||
| 78a7904c2f | |||
| 54ef6c6652 | |||
| 27dc2294e6 | |||
| f84a1dddfd | |||
|
|
8d5d97dcf6 | ||
| fa7af8e7b7 | |||
| 5ae5b2602a | |||
| 5a53d953da | |||
| 8806eb9942 | |||
|
|
df9255ca3d | ||
|
|
ffa484d945 | ||
| bc53d5bfff | |||
| a7d1e71ab3 | |||
| 1d47cc6f9c | |||
| 08abe94c85 | |||
| 079adb8b2c | |||
| e6ab8cd198 | |||
| c01ba23463 | |||
|
|
c0aa86327a | ||
|
|
c843434720 |
68
CHANGELOG.md
68
CHANGELOG.md
@@ -1,3 +1,71 @@
|
||||
## [v2.13.1](https://github.com/continew-org/continew-starter/compare/v2.13.0...v2.13.1) (2025-07-17)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
- 【validation】增强 EnumValue 枚举校验器,支持枚举值的数组和集合校验,增加对 BaseEnum 接口的支持 ([3dad27d](https://github.com/continew-org/continew-starter/commit/3dad27df3f747d60f47c1504286c86f6636e7242))
|
||||
- 【extension/tenant】新增 TenantIgnoreAspect 切面,完善定时任务等需要忽略租户的场景 ([07e1637](https://github.com/continew-org/continew-starter/commit/07e1637363bce4cac3f215384c8bbf6235a30778))
|
||||
- 【core】SpringUtils 工具类新增 getBean(Class<T> clazz, boolean ignoreNoSuchBeanEx) 方法 ([17272a7](https://github.com/continew-org/continew-starter/commit/17272a780905b554b1fb47e52667a51be0af7bbe))
|
||||
- 【core】新增集合工具类 CollUtils(mapToList、mapToSet) ([3f7f118](https://github.com/continew-org/continew-starter/commit/3f7f118d3e6b38c2cb13a2661a37eda3325894a7))
|
||||
- 【extension/tenant】新增 TenantUtils 替换 TenantHandler 接口及其实现类 DefaultTenantHandler ([2f2aae0](https://github.com/continew-org/continew-starter/commit/2f2aae08ab934009cd39bbe7ec3823c594fa48f8))
|
||||
- 【core】ServletUtils 新增应 JSON 数据给客户端方法 ([67edb08](https://github.com/continew-org/continew-starter/commit/67edb0828dee355ff46d055935a76a42a5a6ebd8))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
- 【extension/crud】完善树配置相关注释 ([3be0d90](https://github.com/continew-org/continew-starter/commit/3be0d900180e4ed528f32f2350b150552aee0420))
|
||||
- 【extension/crud】移除 Crane4j 依赖方便使用者自定义实现 ([aefd61b](https://github.com/continew-org/continew-starter/commit/aefd61b855e376b0f509d34d441b1d1d5b831a39))
|
||||
- 【extension/tenant】将"多租户"描述统一为"租户" ([d32c051](https://github.com/continew-org/continew-starter/commit/d32c05166d297d1665436eae63f41277f6dca2af))
|
||||
- 【extension/tenant】将 dynamic-datasource 依赖设置为 optional ([778a861](https://github.com/continew-org/continew-starter/commit/778a861fa9f97a99a7014b72a37e984145872421))
|
||||
- 【extension/datapermission】UserContext、RoleContext 重命名为 UserData、RoleData,以避免和应用冲突 ([a0b64b8](https://github.com/continew-org/continew-starter/commit/a0b64b81d560c3c4e7175685f66ab98406a31dcc))
|
||||
- 使用 CollUtils 替代部分 Stream 集合转换 ([e05e0de](https://github.com/continew-org/continew-starter/commit/e05e0de7b81329512ea1f0ad5e9ed3c04bdfe752))
|
||||
|
||||
### 🐛 问题修复
|
||||
|
||||
- 【security/mask】修复部分注释错误 ([34deff9](https://github.com/continew-org/continew-starter/commit/34deff959aa9ba817d05b552b173b4cbaebd289a))
|
||||
- 【dependencies】指定 Apache POI 依赖版本(解决版本冲突)并移除冗余包 ([b4cb147](https://github.com/continew-org/continew-starter/commit/b4cb147a77cdfeb754c061eab888eb10314231be))
|
||||
|
||||
## [v2.13.0](https://github.com/continew-org/continew-starter/compare/v2.12.2...v2.13.0) (2025-07-05)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
- 【excel/poi】新增 continew-starter-excel-poi 模块,并使用 FastExcel 替换 EasyExcel (Gitee#64@jiang4yu)
|
||||
- 【api-doc】ApiDocUtils 新增 buildGroupedOpenApi(构建分组接口文档) 方法 ([08abe94](https://github.com/continew-org/continew-starter/commit/08abe94c85f098c3a797fa5b3255136654dc2720))
|
||||
- 【extension/crud】新增 Api.BATCH_DELETE 批量删除枚举,拆分单个删除和批量删除接口 ([bc53d5b](https://github.com/continew-org/continew-starter/commit/bc53d5bfffda10ace055817f0249995296675ac1))
|
||||
- 【json/jackson】添加对Instant、Duration的序列化和反序列化处理 (Gitee#68@jiang4yu) ([ffa484d](https://github.com/continew-org/continew-starter/commit/ffa484d9452c176489b77d1bea892b33d35a7019)) ([df9255c](https://github.com/continew-org/continew-starter/commit/df9255ca3de2452f0de68e4ae35282a1a7727b65))
|
||||
- 【validation】新增校验模块并引入 SpEL Validator 用于复杂校验场景 ([5ae5b26](https://github.com/continew-org/continew-starter/commit/5ae5b2602aaa8e08c03fa8881c8109b0a1831966)) ([68f1f41](https://github.com/continew-org/continew-starter/commit/68f1f41cc991e81179f475111403d8917b17c55f))
|
||||
- 【validation】新增 Phone 手机号校验注解,支持校验座机号码、手机号码(中国大陆)、手机号码(中国香港)、手机号码(中国台湾)、手机号码(中国澳门) ([fa7af8e](https://github.com/continew-org/continew-starter/commit/fa7af8e7b7eed91d2917688817885349a2965f16)) ([8d5d97d](https://github.com/continew-org/continew-starter/commit/8d5d97dcf6c102217aa9a8b745f891b388da8a10))
|
||||
- 【extension/crud】CrudService 增加 Valid 校验注解,Controller 层使用 Valid 替换部分 Validated 注解 ([cce1b55](https://github.com/continew-org/continew-starter/commit/cce1b5560b3f468998d38609fc30a01ebcb9aa20))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
- 【extension/crud】AbstractBaseController => AbstractCrudController,BaseService => CrudService ([a7d1e71](https://github.com/continew-org/continew-starter/commit/a7d1e71ab39652a93653e127bfe4a1c167342743))
|
||||
- 【excel】file 模块重命名为 excel ([5a53d95](https://github.com/continew-org/continew-starter/commit/5a53d953da8d0bb158bd94820a45c7b26887328f))
|
||||
- 【core】ProjectProperties => ApplicationProperties ([27dc229](https://github.com/continew-org/continew-starter/commit/27dc2294e6a90c2a6b0e95b58e816ab6cb5cce26))
|
||||
- 【core】调整 CheckUtils 等校验类到 util.validation 包下 ([78a7904](https://github.com/continew-org/continew-starter/commit/78a7904c2fba7c18869afb3f089b23b79666a3a7))
|
||||
- 简化 package,对于互斥包不再单独命名,例如:data.mp、data.mf,统一为 data ([223236a](https://github.com/continew-org/continew-starter/commit/223236aad31c32a8e2c49802dbd1f2f34a3ca275))
|
||||
- 【data/mp】将 MP 的 CrudRepository 迁移至 ServiceImpl 类中,减少两层继承,解决层级过多出现 Sonar 警告的问题 ([e1c9a91](https://github.com/continew-org/continew-starter/commit/e1c9a91c77127a1f2a87f6c2effa813a82fc1877))
|
||||
|
||||
### 📦 依赖升级
|
||||
|
||||
- 调整 groupId top.continew => top.continew.starter ([a0ace7d](https://github.com/continew-org/continew-starter/commit/a0ace7d60c06b38a2535a5f48e3dbd1f87e9faa7))
|
||||
- commons-beanutils 1.9.4 => 1.11.0 ([f84a1dd](https://github.com/continew-org/continew-starter/commit/f84a1dddfd27e6d4c1ddd3469866e01f6ddd2931))
|
||||
- spring-boot 3.3.11 => 3.3.12 ([1d47cc6](https://github.com/continew-org/continew-starter/commit/1d47cc6f9ccf9c0ed6e02744e56063876f9a1200))
|
||||
- redisson 3.46.0 => 3.49.0
|
||||
- cosid 2.12.3 => 2.13.0
|
||||
- sa-token 1.42.0 => 1.44.0
|
||||
- mybatis-plus 3.5.8 => 3.5.12 ([1d47cc6](https://github.com/continew-org/continew-starter/commit/1d47cc6f9ccf9c0ed6e02744e56063876f9a1200)) ([8806eb9](https://github.com/continew-org/continew-starter/commit/8806eb9942df210788510489e24cc5636b0fb77a))
|
||||
- mybatis-flex 1.10.8 => 1.10.9
|
||||
- snail-job 1.4.0 => 1.5.0
|
||||
- sms4j 3.3.4 => 3.3.5
|
||||
- aws-sdk 2.31.35 => 2.31.63
|
||||
- aws-crt 0.36.1 => 0.38.1
|
||||
- hutool 5.8.37 => 5.8.38
|
||||
|
||||
## [v2.12.2](https://github.com/continew-org/continew-starter/compare/v2.12.1...v2.12.2) (2025-06-13)
|
||||
|
||||
### 🐛 问题修复
|
||||
|
||||
- 【extension/datapermission】修复构建本部门及以下数据权限表达式问题。 (Gitee#65@httpsjt) ([c0aa863](https://github.com/continew-org/continew-starter/commit/c0aa86327acac94b55e2f7c4fa193da4e38af986))
|
||||
|
||||
## [v2.12.1](https://github.com/continew-org/continew-starter/compare/v2.12.0...v2.12.1) (2025-06-09)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
27
README.md
27
README.md
@@ -4,7 +4,7 @@
|
||||
<img src="https://img.shields.io/maven-central/v/top.continew/continew-starter.svg?label=Maven%20Central&logo=sonatype&logoColor=FFF" alt="Release" />
|
||||
</a>
|
||||
<a href="https://spring.io/projects/spring-boot" title="Spring Boot" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Spring Boot-3.3.9-%236CB52D.svg?logo=Spring-Boot" alt="Spring Boot" />
|
||||
<img src="https://img.shields.io/badge/Spring Boot-3.3.12-%236CB52D.svg?logo=Spring-Boot" alt="Spring Boot" />
|
||||
</a>
|
||||
<a href="https://github.com/continew-org/continew-starter" title="Open JDK" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Open JDK-17-%236CB52D.svg?logo=OpenJDK&logoColor=FFF" alt="Open JDK" />
|
||||
@@ -83,7 +83,7 @@ ContiNew Starter 就是将脚手架项目中的通用基础配置进行了封装
|
||||
|
||||
```xml
|
||||
<parent>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>{latest-version}</version>
|
||||
</parent>
|
||||
@@ -103,7 +103,7 @@ ContiNew Starter 就是将脚手架项目中的通用基础配置进行了封装
|
||||
<dependencies>
|
||||
<!-- ContiNew Starter Dependencies -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-dependencies</artifactId>
|
||||
<version>{latest-version}</version>
|
||||
<type>pom</type>
|
||||
@@ -119,7 +119,7 @@ ContiNew Starter 就是将脚手架项目中的通用基础配置进行了封装
|
||||
<dependencies>
|
||||
<!-- Web 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -152,6 +152,7 @@ continew-starter
|
||||
├─ continew-starter-json(JSON 模块)
|
||||
│ └─ continew-starter-json-jackson
|
||||
├─ continew-starter-api-doc(接口文档模块:Spring Doc + Knife4j)
|
||||
├─ continew-starter-validation(校验模块:Hibernate Validator)
|
||||
├─ continew-starter-web(Web 开发模块:包含跨域、全局异常+响应、链路追踪等自动配置)
|
||||
├─ continew-starter-cache(缓存模块)
|
||||
│ ├─ continew-starter-cache-redisson(Redisson)
|
||||
@@ -161,7 +162,7 @@ continew-starter
|
||||
│ ├─ continew-starter-auth-satoken(国产轻量认证鉴权)
|
||||
│ └─ continew-starter-auth-justauth(第三方登录)
|
||||
├─ continew-starter-data(数据访问模块)
|
||||
│ ├─ continew-starter-data-core(通用模块)
|
||||
│ ├─ continew-starter-data-core(核心模块)
|
||||
│ ├─ continew-starter-data-mp(MyBatis Plus)
|
||||
│ └─ continew-starter-data-mf(MyBatis Flex)
|
||||
├─ continew-starter-security(安全模块)
|
||||
@@ -179,11 +180,13 @@ continew-starter
|
||||
│ ├─ continew-starter-messaging-mail(邮件)
|
||||
│ └─ continew-starter-messaging-websocket(WebSocket)
|
||||
├─ continew-starter-log(日志模块)
|
||||
│ ├─ continew-starter-log-core(通用模块)
|
||||
│ ├─ continew-starter-log-core(核心模块)
|
||||
│ ├─ continew-starter-log-aop(基于 AOP 实现)
|
||||
│ └─ continew-starter-log-interceptor(基于拦截器实现(Spring Boot Actuator HttpTrace 增强版))
|
||||
├─ continew-starter-file(文件处理模块)
|
||||
│ └─ continew-starter-file-excel(Easy Excel)
|
||||
├─ continew-starter-excel(Excel 文件处理模块)
|
||||
│ ├─ continew-starter-excel-core(核心模块)
|
||||
│ ├─ continew-starter-excel-fastexcel(FastExcel)
|
||||
│ └─ continew-starter-excel-poi(POI)
|
||||
├─ continew-starter-storage(存储模块)
|
||||
│ └─ continew-starter-storage-local(本地存储)
|
||||
├─ continew-starter-license(License 模块)
|
||||
@@ -192,13 +195,13 @@ continew-starter
|
||||
│ └─ continew-starter-license-verifier(License 校验器)
|
||||
└─ continew-starter-extension(扩展模块)
|
||||
├─ continew-starter-extension-datapermission(数据权限模块)
|
||||
│ ├─ continew-starter-extension-datapermission-core(通用模块)
|
||||
│ ├─ continew-starter-extension-datapermission-core(核心模块)
|
||||
│ └─ continew-starter-extension-datapermission-mp(MyBatis Plus)
|
||||
├─ continew-starter-extension-tenant(多租户模块)
|
||||
│ ├─ continew-starter-extension-tenant-core(通用模块)
|
||||
├─ continew-starter-extension-tenant(租户模块)
|
||||
│ ├─ continew-starter-extension-tenant-core(核心模块)
|
||||
│ └─ continew-starter-extension-tenant-mp(MyBatis Plus)
|
||||
└─ continew-starter-extension-crud(CRUD 模块)
|
||||
├─ continew-starter-extension-crud-core(通用模块)
|
||||
├─ continew-starter-extension-crud-core(核心模块)
|
||||
├─ continew-starter-extension-crud-mp(MyBatis Plus)
|
||||
└─ continew-starter-extension-crud-mf(MyBatis Flex)
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import top.continew.starter.apidoc.handler.BaseEnumParameterHandler;
|
||||
import top.continew.starter.apidoc.handler.OpenApiHandler;
|
||||
import top.continew.starter.core.autoconfigure.project.ProjectProperties;
|
||||
import top.continew.starter.core.autoconfigure.application.ApplicationProperties;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
import top.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||
|
||||
import java.util.List;
|
||||
@@ -83,15 +84,15 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionProperties properties) {
|
||||
Info info = new Info().title("%s %s".formatted(projectProperties.getName(), "API 文档"))
|
||||
.version(projectProperties.getVersion())
|
||||
.description(projectProperties.getDescription());
|
||||
ProjectProperties.Contact contact = projectProperties.getContact();
|
||||
public OpenAPI openApi(ApplicationProperties applicationProperties, SpringDocExtensionProperties properties) {
|
||||
Info info = new Info().title("%s %s".formatted(applicationProperties.getName(), "API 文档"))
|
||||
.version(applicationProperties.getVersion())
|
||||
.description(applicationProperties.getDescription());
|
||||
ApplicationProperties.Contact contact = applicationProperties.getContact();
|
||||
if (contact != null) {
|
||||
info.contact(new Contact().name(contact.getName()).email(contact.getEmail()).url(contact.getUrl()));
|
||||
}
|
||||
ProjectProperties.License license = projectProperties.getLicense();
|
||||
ApplicationProperties.License license = applicationProperties.getLicense();
|
||||
if (license != null) {
|
||||
info.license(new License().name(license.getName()).url(license.getUrl()));
|
||||
}
|
||||
@@ -104,7 +105,7 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
||||
if (MapUtil.isNotEmpty(securitySchemeMap)) {
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
List<String> list = securitySchemeMap.values().stream().map(SecurityScheme::getName).toList();
|
||||
List<String> list = CollUtils.mapToList(securitySchemeMap.values(), SecurityScheme::getName);
|
||||
list.forEach(securityRequirement::addList);
|
||||
openApi.addSecurityItem(securityRequirement);
|
||||
}
|
||||
@@ -127,10 +128,8 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
Map<String, SecurityScheme> securitySchemeMap = components.getSecuritySchemes();
|
||||
pathItem.readOperations().forEach(operation -> {
|
||||
SecurityRequirement securityRequirement = new SecurityRequirement();
|
||||
List<String> list = securitySchemeMap.values()
|
||||
.stream()
|
||||
.map(SecurityScheme::getName)
|
||||
.toList();
|
||||
List<String> list = CollUtils.mapToList(securitySchemeMap
|
||||
.values(), SecurityScheme::getName);
|
||||
list.forEach(securityRequirement::addList);
|
||||
operation.addSecurityItem(securityRequirement);
|
||||
});
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import org.springdoc.core.customizers.ParameterCustomizer;
|
||||
import org.springdoc.core.customizers.PropertyCustomizer;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import top.continew.starter.apidoc.util.DocUtils;
|
||||
import top.continew.starter.apidoc.util.ApiDocUtils;
|
||||
import top.continew.starter.core.enums.BaseEnum;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@@ -84,9 +84,9 @@ public class BaseEnumParameterHandler implements ParameterCustomizer, PropertyCu
|
||||
BaseEnum[] enums = (BaseEnum[])enumClass.getEnumConstants();
|
||||
List<String> valueList = Arrays.stream(enums).map(e -> e.getValue().toString()).toList();
|
||||
schema.setEnum(valueList);
|
||||
String enumValueType = DocUtils.getEnumValueTypeAsString(enumClass);
|
||||
String enumValueType = ApiDocUtils.getEnumValueTypeAsString(enumClass);
|
||||
schema.setType(enumValueType);
|
||||
schema.setFormat(DocUtils.resolveFormat(enumValueType));
|
||||
schema.setFormat(ApiDocUtils.resolveFormat(enumValueType));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ public class BaseEnumParameterHandler implements ParameterCustomizer, PropertyCu
|
||||
* @return 追加后的描述字符串
|
||||
*/
|
||||
private String appendEnumDescription(String originalDescription, Class<?> enumClass) {
|
||||
return originalDescription + "<span style='color:red'>" + DocUtils.getDescMap(enumClass) + "</span>";
|
||||
return originalDescription + "<span style='color:red'>" + ApiDocUtils.getDescMap(enumClass) + "</span>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,11 +37,11 @@ import org.springdoc.core.utils.PropertyResolverUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import top.continew.starter.core.util.CollUtils;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -176,11 +176,8 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
buildTagsFromClass(handlerMethod.getBeanType(), tags, tagsStr, locale);
|
||||
|
||||
if (CollUtil.isNotEmpty(tagsStr)) {
|
||||
tagsStr = tagsStr.stream()
|
||||
.map(str -> propertyResolverUtils.resolve(str, locale))
|
||||
.collect(Collectors.toSet());
|
||||
tagsStr = CollUtils.mapToSet(tagsStr, str -> propertyResolverUtils.resolve(str, locale));
|
||||
}
|
||||
|
||||
if (springdocTags.containsKey(handlerMethod)) {
|
||||
Tag tag = springdocTags.get(handlerMethod);
|
||||
tagsStr.add(tag.getName());
|
||||
@@ -256,7 +253,7 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
methodTags.addAll(AnnotatedElementUtils
|
||||
.findAllMergedAnnotations(method, io.swagger.v3.oas.annotations.tags.Tag.class));
|
||||
if (CollUtil.isNotEmpty(methodTags)) {
|
||||
tagsStr.addAll(toSet(methodTags, tag -> propertyResolverUtils.resolve(tag.name(), locale)));
|
||||
tagsStr.addAll(CollUtils.mapToSet(methodTags, tag -> propertyResolverUtils.resolve(tag.name(), locale)));
|
||||
List<io.swagger.v3.oas.annotations.tags.Tag> allTags = new ArrayList<>(methodTags);
|
||||
addTags(allTags, tags, locale);
|
||||
}
|
||||
@@ -275,22 +272,4 @@ public class OpenApiHandler extends OpenAPIService {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 将collection转化为Set集合,但是两者的泛型不同<br>
|
||||
* <B>{@code Collection<E> ------> Set<T> } </B>
|
||||
*
|
||||
* @param collection 需要转化的集合
|
||||
* @param function collection中的泛型转化为set泛型的lambda表达式
|
||||
* @param <E> collection中的泛型
|
||||
* @param <T> Set中的泛型
|
||||
* @return 转化后的Set
|
||||
*/
|
||||
public static <E, T> Set<T> toSet(Collection<E> collection, Function<E, T> function) {
|
||||
if (CollUtil.isEmpty(collection) || function == null) {
|
||||
return CollUtil.newHashSet();
|
||||
}
|
||||
return collection.stream().map(function).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.starter.apidoc.util;
|
||||
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.continew.starter.core.enums.BaseEnum;
|
||||
|
||||
@@ -30,11 +31,37 @@ import java.util.stream.Collectors;
|
||||
* 接口文档工具类
|
||||
*
|
||||
* @author echo
|
||||
* @author Charles7c
|
||||
* @since 2.5.2
|
||||
*/
|
||||
public class DocUtils {
|
||||
public class ApiDocUtils {
|
||||
|
||||
private DocUtils() {
|
||||
private ApiDocUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建分组接口文档
|
||||
*
|
||||
* @param group 分组名称
|
||||
* @param pathsToMatch 路径匹配
|
||||
* @return GroupedOpenApi
|
||||
* @since 2.13.0
|
||||
*/
|
||||
public static GroupedOpenApi buildGroupedOpenApi(String group, String... pathsToMatch) {
|
||||
return buildGroupedOpenApi(group, group, pathsToMatch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建分组接口文档
|
||||
*
|
||||
* @param group 分组名称
|
||||
* @param displayName 分组显示名称
|
||||
* @param pathsToMatch 路径匹配
|
||||
* @return GroupedOpenApi
|
||||
* @since 2.13.0
|
||||
*/
|
||||
public static GroupedOpenApi buildGroupedOpenApi(String group, String displayName, String... pathsToMatch) {
|
||||
return GroupedOpenApi.builder().group(group).displayName(displayName).pathsToMatch(pathsToMatch).build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-auth</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-auth</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -23,7 +23,7 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-bom</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
@@ -13,276 +13,294 @@
|
||||
<description>ContiNew Starter BOM</description>
|
||||
|
||||
<properties>
|
||||
<revision>2.12.1</revision>
|
||||
<revision>2.13.1</revision>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON 模块 - Jackson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-json-jackson</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- API 文档模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-api-doc</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 校验模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-validation</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-web</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 缓存模块 - Spring Cache -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-springcache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 缓存模块 - JetCache -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-jetcache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 认证模块 - SaToken -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-auth-satoken</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 认证模块 - JustAuth -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-auth-justauth</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-mp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 数据访问模块 - MyBatis Flex -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-mf</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 安全模块 - 密码编码器 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-security-password</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 安全模块 - 加密 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-security-crypto</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 安全模块 - 脱敏 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-security-mask</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 安全模块 - XSS 过滤 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-security-xss</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 安全模块 - 敏感词 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-security-sensitivewords</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 限流模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-ratelimiter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 幂等模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-idempotent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 链路追踪模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-trace</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 验证码模块 - 图形验证码 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-captcha-graphic</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 验证码模块 - 行为验证码 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-captcha-behavior</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 消息模块 - 邮件 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-messaging-mail</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 消息模块 - WebSocket -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-messaging-websocket</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 日志模块 - 基于拦截器实现(Spring Boot Actuator HttpTrace 增强版) -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-log-interceptor</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 日志模块 - 基于 AOP 实现 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-log-aop</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 日志模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-log-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件处理模块 - Excel -->
|
||||
<!-- Excel 文件处理模块 - FastExcel -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<artifactId>continew-starter-file-excel</artifactId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-fastexcel</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- Excel 文件处理模块 - POI -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-poi</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- Excel 文件处理模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 存储模块 - 本地存储 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-storage-local</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 存储模块 - 对象存储 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-storage-oss</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 存储模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-storage-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- License 模块 - 生成器 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-license-generator</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- License 模块 - 校验器 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-license-verifier</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- License 模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-license-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 扩展模块 - CRUD - MyBatis Plus ORM 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud-mp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 扩展模块 - CRUD - MyBatis Flex ORM 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud-mf</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 扩展模块 - CRUD - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 扩展模块 - 数据权限 - MyBatis Plus ORM 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-datapermission-mp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 扩展模块 - 数据权限 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-datapermission-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 扩展模块 - 多租户 - MyBatis Plus ORM 模块 -->
|
||||
<!-- 扩展模块 - 租户 - MyBatis Plus ORM 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-tenant-mp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 扩展模块 - 多租户 - 核心模块 -->
|
||||
<!-- 扩展模块 - 租户 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-tenant-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-captcha</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 缓存模块 - Redisson -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-cache-redisson</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-captcha</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -23,7 +23,7 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.autoconfigure.project;
|
||||
package top.continew.starter.core.autoconfigure.application;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -22,7 +22,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 项目自动配置
|
||||
* 应用自动配置
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
@@ -30,5 +30,5 @@ import org.springframework.context.annotation.Import;
|
||||
@AutoConfiguration
|
||||
@ComponentScan("cn.hutool.extra.spring")
|
||||
@Import(cn.hutool.extra.spring.SpringUtil.class)
|
||||
@EnableConfigurationProperties(ProjectProperties.class)
|
||||
public class ProjectAutoConfiguration {}
|
||||
@EnableConfigurationProperties(ApplicationProperties.class)
|
||||
public class ApplicationAutoConfiguration {}
|
||||
@@ -14,18 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.autoconfigure.project;
|
||||
package top.continew.starter.core.autoconfigure.application;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 项目配置属性
|
||||
* 应用配置属性
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ConfigurationProperties("project")
|
||||
public class ProjectProperties {
|
||||
@ConfigurationProperties("application")
|
||||
public class ApplicationProperties {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
@@ -33,20 +38,15 @@ public class ProjectProperties {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 应用名称
|
||||
* 描述
|
||||
*/
|
||||
private String appName;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
@@ -147,6 +147,14 @@ public class ProjectProperties {
|
||||
}
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -155,12 +163,12 @@ public class ProjectProperties {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAppName() {
|
||||
return appName;
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setAppName(String appName) {
|
||||
this.appName = appName;
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
@@ -171,14 +179,6 @@ public class ProjectProperties {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
@@ -19,9 +19,10 @@ package top.continew.starter.core.constant;
|
||||
/**
|
||||
* 字符相关常量
|
||||
*
|
||||
* @see cn.hutool.core.text.CharPool
|
||||
*
|
||||
* @author looly(<a href="https://gitee.com/dromara/hutool">Hutool</a>)
|
||||
* @author Charles7c
|
||||
* @see cn.hutool.core.text.CharPool
|
||||
* @since 2.7.3
|
||||
*/
|
||||
public class CharConstants {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class PropertiesConstants {
|
||||
public static final String DATA_PERMISSION = CONTINEW_STARTER + StringConstants.DOT + "data-permission";
|
||||
|
||||
/**
|
||||
* 多租户配置
|
||||
* 租户配置
|
||||
*/
|
||||
public static final String TENANT = CONTINEW_STARTER + StringConstants.DOT + "tenant";
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@ package top.continew.starter.core.constant;
|
||||
/**
|
||||
* 字符串相关常量
|
||||
*
|
||||
* @see cn.hutool.core.text.StrPool
|
||||
*
|
||||
* @author looly(<a href="https://gitee.com/dromara/hutool">Hutool</a>)
|
||||
* @author Charles7c
|
||||
* @see cn.hutool.core.text.StrPool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class StringConstants {
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 集合相关工具类
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2.13.1
|
||||
*/
|
||||
public class CollUtils {
|
||||
|
||||
private CollUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 func 自定义一个规则,此规则将原集合中的元素转换成新的元素,生成新的列表返回<br>
|
||||
* 例如:提供一个 Bean 列表,通过 Function 接口实现获取某个字段值,返回这个字段值组成的新列表
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param <R> 返回集合元素类型
|
||||
* @param collection 原集合
|
||||
* @param func 编辑函数
|
||||
* @return 抽取后的新列表(默认去除 null 值)
|
||||
* @see CollUtil#map(Iterable, Function, boolean)
|
||||
*/
|
||||
public static <T, R> List<R> mapToList(Collection<T> collection, Function<? super T, ? extends R> func) {
|
||||
return mapToList(collection, func, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 func 自定义一个规则,此规则将原集合中的元素转换成新的元素,生成新的列表返回<br>
|
||||
* 例如:提供一个 Bean 列表,通过 Function 接口实现获取某个字段值,返回这个字段值组成的新列表
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param <R> 返回集合元素类型
|
||||
* @param collection 原集合
|
||||
* @param func 编辑函数
|
||||
* @param ignoreNull 是否忽略空值,这里的空值包括函数处理前和处理后的 null 值
|
||||
* @return 抽取后的新列表
|
||||
* @see CollUtil#map(Iterable, Function, boolean)
|
||||
*/
|
||||
public static <T, R> List<R> mapToList(Collection<T> collection,
|
||||
Function<? super T, ? extends R> func,
|
||||
boolean ignoreNull) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
Stream<T> stream = collection.stream();
|
||||
if (ignoreNull) {
|
||||
return stream.filter(Objects::nonNull).map(func).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
return stream.map(func).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 func 自定义一个规则,此规则将原集合中的元素转换成新的元素,生成新的集合返回<br>
|
||||
* 例如:提供一个 Bean 集合,通过 Function 接口实现获取某个字段值,返回这个字段值组成的新集合
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param <R> 返回集合元素类型
|
||||
* @param collection 原集合
|
||||
* @param func 编辑函数
|
||||
* @return 抽取后的新集合(默认去除 null 值)
|
||||
* @see CollUtil#map(Iterable, Function, boolean)
|
||||
*/
|
||||
public static <T, R> Set<R> mapToSet(Collection<T> collection, Function<? super T, ? extends R> func) {
|
||||
return mapToSet(collection, func, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 func 自定义一个规则,此规则将原集合中的元素转换成新的元素,生成新的集合返回<br>
|
||||
* 例如:提供一个 Bean 集合,通过 Function 接口实现获取某个字段值,返回这个字段值组成的新集合
|
||||
*
|
||||
* @param <T> 集合元素类型
|
||||
* @param <R> 返回集合元素类型
|
||||
* @param collection 原集合
|
||||
* @param func 编辑函数
|
||||
* @param ignoreNull 是否忽略空值,这里的空值包括函数处理前和处理后的 null 值
|
||||
* @return 抽取后的新集合
|
||||
* @see CollUtil#map(Iterable, Function, boolean)
|
||||
*/
|
||||
public static <T, R> Set<R> mapToSet(Collection<T> collection,
|
||||
Function<? super T, ? extends R> func,
|
||||
boolean ignoreNull) {
|
||||
if (CollUtil.isEmpty(collection)) {
|
||||
return new HashSet<>(0);
|
||||
}
|
||||
Stream<T> stream = collection.stream();
|
||||
if (ignoreNull) {
|
||||
return stream.filter(Objects::nonNull).map(func).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
}
|
||||
return stream.map(func).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class ReflectUtils {
|
||||
*/
|
||||
public static List<String> getNonStaticFieldsName(Class<?> beanClass) throws SecurityException {
|
||||
List<Field> nonStaticFields = getNonStaticFields(beanClass);
|
||||
return nonStaticFields.stream().map(Field::getName).collect(Collectors.toList());
|
||||
return CollUtils.mapToList(nonStaticFields, Field::getName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -36,7 +37,10 @@ import top.continew.starter.core.wrapper.RepeatReadResponseWrapper;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Servlet 工具类
|
||||
@@ -334,6 +338,18 @@ public class ServletUtils extends JakartaServletUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应 JSON 数据给客户端
|
||||
*
|
||||
* @param response 响应对象
|
||||
* @param data 响应数据
|
||||
* @since 2.13.1
|
||||
* @see #write(HttpServletResponse, String, String)
|
||||
*/
|
||||
public static void writeJSON(HttpServletResponse response, Object data) {
|
||||
write(response, JSONUtil.toJsonStr(data), MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加查询字符串
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package top.continew.starter.core.util;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
||||
/**
|
||||
* Spring 工具类
|
||||
@@ -40,4 +41,25 @@ public class SpringUtils {
|
||||
public static <T> T getProxy(T target) {
|
||||
return (T)SpringUtil.getBean(target.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 class 获取 Bean
|
||||
*
|
||||
* @param <T> Bean类型
|
||||
* @param clazz Bean类
|
||||
* @param ignoreNoSuchBeanEx 是否忽略 {@link NoSuchBeanDefinitionException}
|
||||
* @return Bean对象
|
||||
* @see SpringUtil#getBean(Class)
|
||||
* @since 2.13.1
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz, boolean ignoreNoSuchBeanEx) {
|
||||
try {
|
||||
return SpringUtil.getBean(clazz);
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
if (ignoreNoSuchBeanEx) {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.validation;
|
||||
package top.continew.starter.core.util.validation;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
@@ -25,8 +25,9 @@ import java.util.function.BooleanSupplier;
|
||||
/**
|
||||
* 业务参数校验工具类(抛出 500 ServiceException)
|
||||
*
|
||||
* @author Charles7c
|
||||
* @see BusinessException
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class CheckUtils extends Validator {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.validation;
|
||||
package top.continew.starter.core.util.validation;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import top.continew.starter.core.exception.BadRequestException;
|
||||
@@ -24,8 +24,9 @@ import java.util.function.BooleanSupplier;
|
||||
/**
|
||||
* 基本参数校验工具类(抛出 400 BadRequestException)
|
||||
*
|
||||
* @see top.continew.starter.core.exception.BadRequestException
|
||||
*
|
||||
* @author Charles7c
|
||||
* @see BadRequestException
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class ValidationUtils extends Validator {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.core.validation;
|
||||
package top.continew.starter.core.util.validation;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -1,4 +1,3 @@
|
||||
top.continew.starter.core.autoconfigure.project.ProjectAutoConfiguration
|
||||
top.continew.starter.core.autoconfigure.ValidatorAutoConfiguration
|
||||
top.continew.starter.core.autoconfigure.application.ApplicationAutoConfiguration
|
||||
top.continew.starter.core.autoconfigure.threadpool.ThreadPoolAutoConfiguration
|
||||
top.continew.starter.core.autoconfigure.threadpool.AsyncAutoConfiguration
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.annotation;
|
||||
package top.continew.starter.data.annotation;
|
||||
|
||||
import top.continew.starter.data.core.enums.QueryType;
|
||||
import top.continew.starter.data.enums.QueryType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.annotation;
|
||||
package top.continew.starter.data.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.enums;
|
||||
package top.continew.starter.data.enums;
|
||||
|
||||
import top.continew.starter.data.core.function.ISqlFunction;
|
||||
import top.continew.starter.data.function.ISqlFunction;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.enums;
|
||||
package top.continew.starter.data.enums;
|
||||
|
||||
/**
|
||||
* 查询类型枚举
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.function;
|
||||
package top.continew.starter.data.function;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.util;
|
||||
package top.continew.starter.data.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
@@ -25,7 +25,7 @@ import cn.hutool.db.meta.MetaUtil;
|
||||
import cn.hutool.db.meta.Table;
|
||||
import cn.hutool.db.meta.TableType;
|
||||
import top.continew.starter.core.exception.BusinessException;
|
||||
import top.continew.starter.data.core.enums.DatabaseType;
|
||||
import top.continew.starter.data.enums.DatabaseType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.core.util;
|
||||
package top.continew.starter.data.util;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import org.slf4j.Logger;
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.autoconfigure;
|
||||
package top.continew.starter.data.autoconfigure;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.autoconfigure;
|
||||
package top.continew.starter.data.autoconfigure;
|
||||
|
||||
import com.mybatisflex.core.dialect.DbType;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.autoconfigure;
|
||||
package top.continew.starter.data.autoconfigure;
|
||||
|
||||
import com.mybatisflex.core.dialect.DbType;
|
||||
import com.mybatisflex.core.dialect.DialectFactory;
|
||||
@@ -30,8 +30,8 @@ import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||
import top.continew.starter.data.mf.datapermission.DataPermissionDialect;
|
||||
import top.continew.starter.data.mf.datapermission.DataPermissionFilter;
|
||||
import top.continew.starter.data.datapermission.DataPermissionDialect;
|
||||
import top.continew.starter.data.datapermission.DataPermissionFilter;
|
||||
|
||||
/**
|
||||
* MyBatis Flex 自动配置
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.base;
|
||||
package top.continew.starter.data.base;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.base;
|
||||
package top.continew.starter.data.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
import org.aspectj.lang.annotation.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.mybatisflex.core.dialect.impl.CommonsDialectImpl;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
/**
|
||||
* 数据权限过滤器接口
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.datapermission;
|
||||
package top.continew.starter.data.datapermission;
|
||||
|
||||
/**
|
||||
* 数据权限枚举
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.service;
|
||||
package top.continew.starter.data.service;
|
||||
|
||||
/**
|
||||
* 通用业务接口
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.service.impl;
|
||||
package top.continew.starter.data.service.impl;
|
||||
|
||||
import top.continew.starter.core.util.ClassUtils;
|
||||
import top.continew.starter.data.mf.base.BaseMapper;
|
||||
import top.continew.starter.data.mf.service.IService;
|
||||
import top.continew.starter.data.base.BaseMapper;
|
||||
import top.continew.starter.data.service.IService;
|
||||
|
||||
/**
|
||||
* 通用业务实现类
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mf.util;
|
||||
package top.continew.starter.data.util;
|
||||
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -28,11 +28,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import top.continew.starter.core.exception.BadRequestException;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.data.core.annotation.Query;
|
||||
import top.continew.starter.data.core.annotation.QueryIgnore;
|
||||
import top.continew.starter.data.core.enums.QueryType;
|
||||
import top.continew.starter.data.core.util.SqlInjectionUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.data.annotation.Query;
|
||||
import top.continew.starter.data.annotation.QueryIgnore;
|
||||
import top.continew.starter.data.enums.QueryType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -1 +1 @@
|
||||
top.continew.starter.data.mf.autoconfigure.MybatisFlexAutoConfiguration
|
||||
top.continew.starter.data.autoconfigure.MybatisFlexAutoConfiguration
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- MyBatis Plus jsqlparser 适配(包含原扩展模块内容) -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- P6Spy(SQL 性能分析组件) -->
|
||||
<dependency>
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.autoconfigure;
|
||||
package top.continew.starter.data.autoconfigure;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import top.continew.starter.data.mp.autoconfigure.idgenerator.MyBatisPlusIdGeneratorProperties;
|
||||
import top.continew.starter.data.autoconfigure.idgenerator.MyBatisPlusIdGeneratorProperties;
|
||||
|
||||
/**
|
||||
* MyBatis Plus 扩展配置属性
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.autoconfigure;
|
||||
package top.continew.starter.data.autoconfigure;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
|
||||
@@ -38,8 +38,8 @@ import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.core.util.GeneralPropertySourceFactory;
|
||||
import top.continew.starter.data.mp.autoconfigure.idgenerator.MyBatisPlusIdGeneratorConfiguration;
|
||||
import top.continew.starter.data.mp.handler.CompositeBaseEnumTypeHandler;
|
||||
import top.continew.starter.data.autoconfigure.idgenerator.MyBatisPlusIdGeneratorConfiguration;
|
||||
import top.continew.starter.data.handler.CompositeBaseEnumTypeHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.autoconfigure.idgenerator;
|
||||
package top.continew.starter.data.autoconfigure.idgenerator;
|
||||
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import me.ahoo.cosid.snowflake.SnowflakeId;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.autoconfigure.idgenerator;
|
||||
package top.continew.starter.data.autoconfigure.idgenerator;
|
||||
|
||||
import cn.hutool.core.net.NetUtil;
|
||||
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.autoconfigure.idgenerator;
|
||||
package top.continew.starter.data.autoconfigure.idgenerator;
|
||||
|
||||
import top.continew.starter.data.mp.enums.MyBatisPlusIdGeneratorType;
|
||||
import top.continew.starter.data.enums.MyBatisPlusIdGeneratorType;
|
||||
|
||||
/**
|
||||
* MyBatis ID 生成器配置属性
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.enums;
|
||||
package top.continew.starter.data.enums;
|
||||
|
||||
/**
|
||||
* MyBatis ID 生成器类型枚举
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.handler;
|
||||
package top.continew.starter.data.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import org.apache.ibatis.type.EnumTypeHandler;
|
||||
@@ -33,9 +33,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* 复合枚举类型处理器(扩展 BaseEnum 支持)
|
||||
*
|
||||
* @see com.baomidou.mybatisplus.core.handlers.CompositeEnumTypeHandler
|
||||
*
|
||||
* @author miemie(<a href="https://gitee.com/baomidou/mybatis-plus">MyBatis Plus</a>)
|
||||
* @author Charles7c
|
||||
* @see com.baomidou.mybatisplus.core.handlers.CompositeEnumTypeHandler
|
||||
* @since 2.7.3
|
||||
*/
|
||||
public class CompositeBaseEnumTypeHandler<E extends Enum<E>> implements TypeHandler<E> {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.handler;
|
||||
package top.continew.starter.data.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.baomidou.mybatisplus.annotation.IEnum;
|
||||
@@ -45,9 +45,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* 枚举类型处理器(扩展 BaseEnum 支持)
|
||||
*
|
||||
* @see com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
|
||||
*
|
||||
* @author hubin(<a href="https://gitee.com/baomidou/mybatis-plus">MyBatis Plus</a>)
|
||||
* @author Charles7c
|
||||
* @see com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler
|
||||
* @since 2.4.0
|
||||
*/
|
||||
public class MybatisBaseEnumTypeHandler<E extends Enum<E>> extends BaseTypeHandler<E> {
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.base;
|
||||
package top.continew.starter.data.mapper;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.data.mp.base.BaseMapper;
|
||||
import top.continew.starter.data.mp.service.IService;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用业务实现类
|
||||
*
|
||||
* @param <M> Mapper 接口
|
||||
* @param <T> 实体类型
|
||||
* @author Charles7c
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class ServiceImpl<M extends BaseMapper<T>, T> extends com.baomidou.mybatisplus.extension.service.impl.ServiceImpl<M, T> implements IService<T> {
|
||||
|
||||
private List<Field> entityFields;
|
||||
|
||||
@Override
|
||||
public T getById(Serializable id) {
|
||||
return this.getById(id, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前实体类型字段
|
||||
*
|
||||
* @return 当前实体类型字段列表
|
||||
*/
|
||||
public List<Field> getEntityFields() {
|
||||
if (this.entityFields == null) {
|
||||
this.entityFields = ReflectUtils.getNonStaticFields(this.getEntityClass());
|
||||
}
|
||||
return this.entityFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 查询
|
||||
*
|
||||
* @param id ID
|
||||
* @param isCheckExists 是否检查存在
|
||||
* @return 实体信息
|
||||
*/
|
||||
protected T getById(Serializable id, boolean isCheckExists) {
|
||||
T entity = baseMapper.selectById(id);
|
||||
if (isCheckExists) {
|
||||
CheckUtils.throwIfNotExists(entity, ClassUtil.getClassName(this.getEntityClass(), true), "ID", id);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.service;
|
||||
package top.continew.starter.data.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.repository.IRepository;
|
||||
|
||||
/**
|
||||
* 通用业务接口
|
||||
@@ -23,4 +25,4 @@ package top.continew.starter.data.mp.service;
|
||||
* @author Charles7c
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public interface IService<T> extends com.baomidou.mybatisplus.extension.service.IService<T> {}
|
||||
public interface IService<T> extends IRepository<T> {}
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ClassUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.MapperProxyMetadata;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.*;
|
||||
import com.baomidou.mybatisplus.core.toolkit.reflect.GenericTypeUtils;
|
||||
import com.baomidou.mybatisplus.extension.repository.AbstractRepository;
|
||||
import com.baomidou.mybatisplus.extension.repository.CrudRepository;
|
||||
import com.baomidou.mybatisplus.extension.repository.IRepository;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
|
||||
import org.apache.ibatis.binding.MapperMethod;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
import org.apache.ibatis.logging.LogFactory;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.data.service.IService;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* 通用业务实现类
|
||||
*
|
||||
* <p>将 MP 的 {@link CrudRepository} 迁移至本类中,减少两层继承,解决层级过多出现 Sonar 警告的问题</p>
|
||||
*
|
||||
* @see CrudRepository
|
||||
*
|
||||
* @param <M> Mapper 接口
|
||||
* @param <T> 实体类型
|
||||
* @author hubin (<a href="https://gitee.com/baomidou/mybatis-plus">MyBatis Plus</a>)
|
||||
* @author Charles7c
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public abstract class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
|
||||
|
||||
@Autowired
|
||||
protected M baseMapper;
|
||||
private Class<T> entityClass;
|
||||
private Class<M> mapperClass;
|
||||
private List<Field> entityFields;
|
||||
private volatile SqlSessionFactory sqlSessionFactory;
|
||||
private final Log innerLog = LogFactory.getLog(getClass());
|
||||
|
||||
/**
|
||||
* TableId 注解存在更新记录,否插入一条记录
|
||||
*
|
||||
* @param entity 实体对象
|
||||
* @return boolean
|
||||
* @see AbstractRepository#saveOrUpdate(Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean saveOrUpdate(T entity) {
|
||||
return getBaseMapper().insertOrUpdate(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Wrapper,查询一条记录
|
||||
*
|
||||
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||
* @param throwEx 有多个 result 是否抛出异常
|
||||
* @return 单条数据
|
||||
* @see AbstractRepository#getOne(Wrapper, boolean)
|
||||
*/
|
||||
@Override
|
||||
public T getOne(Wrapper<T> queryWrapper, boolean throwEx) {
|
||||
return getBaseMapper().selectOne(queryWrapper, throwEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Wrapper,查询一条记录
|
||||
*
|
||||
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||
* @param throwEx 有多个 result 是否抛出异常
|
||||
* @return {@link Optional} 返回一个Optional对象
|
||||
* @see AbstractRepository#getOneOpt(Wrapper, boolean)
|
||||
*/
|
||||
@Override
|
||||
public Optional<T> getOneOpt(Wrapper<T> queryWrapper, boolean throwEx) {
|
||||
return Optional.ofNullable(getBaseMapper().selectOne(queryWrapper, throwEx));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Wrapper,查询一条记录
|
||||
*
|
||||
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||
* @return 单条数据
|
||||
* @see AbstractRepository#getMap(Wrapper)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getMap(Wrapper<T> queryWrapper) {
|
||||
return SqlHelper.getObject(innerLog, getBaseMapper().selectMaps(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Wrapper,查询一条记录
|
||||
*
|
||||
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
|
||||
* @param mapper 转换函数
|
||||
* @return 单条数据
|
||||
* @see AbstractRepository#getObj(Wrapper, Function)
|
||||
*/
|
||||
@Override
|
||||
public <V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) {
|
||||
return SqlHelper.getObject(innerLog, listObjs(queryWrapper, mapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行批量操作
|
||||
*
|
||||
* @param list 数据集合
|
||||
* @param batchSize 批量大小
|
||||
* @param consumer 执行方法
|
||||
* @param <E> 泛型
|
||||
* @return 操作结果
|
||||
* @see AbstractRepository#executeBatch(Collection, int, BiConsumer)
|
||||
*/
|
||||
protected <E> boolean executeBatch(Collection<E> list, int batchSize, BiConsumer<SqlSession, E> consumer) {
|
||||
return SqlHelper.executeBatch(getSqlSessionFactory(), this.innerLog, list, batchSize, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行批量操作(默认批次提交数量{@link IRepository#DEFAULT_BATCH_SIZE})
|
||||
*
|
||||
* @param list 数据集合
|
||||
* @param consumer 执行方法
|
||||
* @param <E> 泛型
|
||||
* @return 操作结果
|
||||
* @see AbstractRepository#executeBatch(Collection, BiConsumer)
|
||||
*/
|
||||
protected <E> boolean executeBatch(Collection<E> list, BiConsumer<SqlSession, E> consumer) {
|
||||
return executeBatch(list, DEFAULT_BATCH_SIZE, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 删除
|
||||
*
|
||||
* @param id 主键(类型必须与实体类型字段保持一致)
|
||||
* @param useFill 是否启用填充(为true的情况,会将入参转换实体进行delete删除)
|
||||
* @return 删除结果
|
||||
* @see AbstractRepository#removeById(Serializable, boolean)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeById(Serializable id, boolean useFill) {
|
||||
return SqlHelper.retBool(getBaseMapper().deleteById(id, useFill));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param entityList 数据集合
|
||||
* @param batchSize 批量大小
|
||||
* @return boolean
|
||||
* @see CrudRepository#saveBatch(Collection, int)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean saveBatch(Collection<T> entityList, int batchSize) {
|
||||
String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE);
|
||||
return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*
|
||||
* @param entityList 数据集合
|
||||
* @param batchSize 批量大小
|
||||
* @return boolean
|
||||
* @see CrudRepository#saveOrUpdateBatch(Collection, int)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {
|
||||
TableInfo tableInfo = TableInfoHelper.getTableInfo(this.getEntityClass());
|
||||
Assert.notNull(tableInfo, "error: can not execute. because can not find cache of TableInfo for entity!");
|
||||
String keyProperty = tableInfo.getKeyProperty();
|
||||
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!");
|
||||
return SqlHelper.saveOrUpdateBatch(getSqlSessionFactory(), this
|
||||
.getMapperClass(), this.innerLog, entityList, batchSize, (sqlSession, entity) -> {
|
||||
Object idVal = tableInfo.getPropertyValue(entity, keyProperty);
|
||||
return StringUtils.checkValNull(idVal) || CollectionUtils.isEmpty(sqlSession
|
||||
.selectList(getSqlStatement(SqlMethod.SELECT_BY_ID), entity));
|
||||
}, (sqlSession, entity) -> {
|
||||
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
||||
param.put(Constants.ENTITY, entity);
|
||||
sqlSession.update(getSqlStatement(SqlMethod.UPDATE_BY_ID), param);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
*
|
||||
* @param entityList 数据集合
|
||||
* @param batchSize 批量大小
|
||||
* @return boolean
|
||||
* @see CrudRepository#updateBatchById(Collection, int)
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean updateBatchById(Collection<T> entityList, int batchSize) {
|
||||
String sqlStatement = getSqlStatement(SqlMethod.UPDATE_BY_ID);
|
||||
return executeBatch(entityList, batchSize, (sqlSession, entity) -> {
|
||||
MapperMethod.ParamMap<T> param = new MapperMethod.ParamMap<>();
|
||||
param.put(Constants.ENTITY, entity);
|
||||
sqlSession.update(sqlStatement, param);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getById(Serializable id) {
|
||||
return this.getById(id, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public M getBaseMapper() {
|
||||
Assert.notNull(this.baseMapper, "baseMapper can not be null");
|
||||
return this.baseMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getEntityClass() {
|
||||
if (this.entityClass == null) {
|
||||
this.entityClass = (Class<T>)GenericTypeUtils.resolveTypeArguments(this
|
||||
.getMapperClass(), BaseMapper.class)[0];
|
||||
}
|
||||
return this.entityClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Mapper 类型
|
||||
*
|
||||
* @return 当前 Mapper 类型
|
||||
* @see CrudRepository#getMapperClass()
|
||||
*/
|
||||
public Class<M> getMapperClass() {
|
||||
if (this.mapperClass == null) {
|
||||
MapperProxyMetadata mapperProxyMetadata = MybatisUtils.getMapperProxy(this.getBaseMapper());
|
||||
this.mapperClass = (Class<M>)mapperProxyMetadata.getMapperInterface();
|
||||
}
|
||||
return this.mapperClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前实体类型字段
|
||||
*
|
||||
* @return 当前实体类型字段列表
|
||||
*/
|
||||
public List<Field> getEntityFields() {
|
||||
if (this.entityFields == null) {
|
||||
this.entityFields = ReflectUtils.getNonStaticFields(this.getEntityClass());
|
||||
}
|
||||
return this.entityFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 SqlSessionFactory
|
||||
*
|
||||
* @return SqlSessionFactory
|
||||
* @see AbstractRepository#getSqlSessionFactory()
|
||||
*/
|
||||
protected SqlSessionFactory getSqlSessionFactory() {
|
||||
if (this.sqlSessionFactory == null) {
|
||||
MapperProxyMetadata mapperProxyMetadata = MybatisUtils.getMapperProxy(this.getBaseMapper());
|
||||
this.sqlSessionFactory = MybatisUtils.getSqlSessionFactory(mapperProxyMetadata.getSqlSession());
|
||||
}
|
||||
return this.sqlSessionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取mapperStatementId
|
||||
*
|
||||
* @param sqlMethod 方法名
|
||||
* @return 命名id
|
||||
* @see CrudRepository#getSqlStatement(SqlMethod)
|
||||
*/
|
||||
protected String getSqlStatement(SqlMethod sqlMethod) {
|
||||
return SqlHelper.getSqlStatement(this.getMapperClass(), sqlMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ID 查询
|
||||
*
|
||||
* @param id ID
|
||||
* @param isCheckExists 是否检查存在
|
||||
* @return 实体信息
|
||||
*/
|
||||
protected T getById(Serializable id, boolean isCheckExists) {
|
||||
T entity = baseMapper.selectById(id);
|
||||
if (isCheckExists) {
|
||||
CheckUtils.throwIfNotExists(entity, ClassUtil.getClassName(this.getEntityClass(), true), "ID", id);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.data.mp.util;
|
||||
package top.continew.starter.data.util;
|
||||
|
||||
import cn.hutool.core.annotation.AnnotationUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -28,11 +28,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import top.continew.starter.core.exception.BadRequestException;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.data.core.annotation.Query;
|
||||
import top.continew.starter.data.core.annotation.QueryIgnore;
|
||||
import top.continew.starter.data.core.enums.QueryType;
|
||||
import top.continew.starter.data.core.util.SqlInjectionUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.data.annotation.Query;
|
||||
import top.continew.starter.data.annotation.QueryIgnore;
|
||||
import top.continew.starter.data.enums.QueryType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -1 +1 @@
|
||||
top.continew.starter.data.mp.autoconfigure.MybatisPlusAutoConfiguration
|
||||
top.continew.starter.data.autoconfigure.MybatisPlusAutoConfiguration
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -24,7 +24,7 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-dependencies</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
@@ -14,42 +14,44 @@
|
||||
|
||||
<properties>
|
||||
<!-- 项目版本号 -->
|
||||
<revision>2.12.1</revision>
|
||||
<spring-boot.version>3.3.11</spring-boot.version>
|
||||
<revision>2.13.1</revision>
|
||||
<spring-boot.version>3.3.12</spring-boot.version>
|
||||
<spring-cloud.version>2023.0.5</spring-cloud.version>
|
||||
<redisson.version>3.46.0</redisson.version>
|
||||
<redisson.version>3.49.0</redisson.version>
|
||||
<jetcache.version>2.7.8</jetcache.version>
|
||||
<cosid.version>2.12.3</cosid.version>
|
||||
<sa-token.version>1.42.0</sa-token.version>
|
||||
<cosid.version>2.13.0</cosid.version>
|
||||
<sa-token.version>1.44.0</sa-token.version>
|
||||
<just-auth.version>1.16.7</just-auth.version>
|
||||
<mybatis-plus.version>3.5.8</mybatis-plus.version>
|
||||
<mybatis-plus.version>3.5.12</mybatis-plus.version>
|
||||
<mybatis-flex.version>1.10.9</mybatis-flex.version>
|
||||
<dynamic-datasource.version>4.3.1</dynamic-datasource.version>
|
||||
<p6spy.version>3.9.1</p6spy.version>
|
||||
<snail-job.version>1.4.0</snail-job.version>
|
||||
<sms4j.version>3.3.4</sms4j.version>
|
||||
<snail-job.version>1.5.0</snail-job.version>
|
||||
<sms4j.version>3.3.5</sms4j.version>
|
||||
<aj-captcha.version>1.4.0</aj-captcha.version>
|
||||
<easy-captcha.version>1.6.2</easy-captcha.version>
|
||||
<nashorn.version>15.6</nashorn.version>
|
||||
<easy-excel.version>3.3.4</easy-excel.version>
|
||||
<fastexcel.version>1.2.0</fastexcel.version>
|
||||
<poi.version>5.4.1</poi.version>
|
||||
<x-file-storage.version>2.2.1</x-file-storage.version>
|
||||
<aws-s3.version>1.12.783</aws-s3.version>
|
||||
<s3.version>2.31.35</s3.version>
|
||||
<s3-crt.version>0.38.1</s3-crt.version>
|
||||
<aws-s3-v1.version>1.12.783</aws-s3-v1.version>
|
||||
<aws-sdk.version>2.31.63</aws-sdk.version>
|
||||
<aws-crt.version>0.38.5</aws-crt.version>
|
||||
<thumbnails.version>0.4.20</thumbnails.version>
|
||||
<graceful-response.version>5.0.5-boot3</graceful-response.version>
|
||||
<spel-validator.version>0.5.0-beta</spel-validator.version>
|
||||
<crane4j.version>2.9.0</crane4j.version>
|
||||
<knife4j.version>4.5.0</knife4j.version>
|
||||
<tlog.version>1.5.2</tlog.version>
|
||||
<truelicense.version>1.33</truelicense.version>
|
||||
<zip4j.version>2.11.5</zip4j.version>
|
||||
<okhttp.version>4.12.0</okhttp.version>
|
||||
<ttl.version>2.14.5</ttl.version>
|
||||
<ip2region.version>3.3.6</ip2region.version>
|
||||
<hutool.version>5.8.37</hutool.version>
|
||||
<hutool.version>5.8.38</hutool.version>
|
||||
<snakeyaml.version>2.4</snakeyaml.version>
|
||||
<truelicense.version>1.33</truelicense.version>
|
||||
<zip4j.version>2.11.5</zip4j.version>
|
||||
<!-- 解决部分传递依赖漏洞问题 -->
|
||||
<commons-beanutils.version>1.9.4</commons-beanutils.version>
|
||||
<commons-beanutils.version>1.11.0</commons-beanutils.version>
|
||||
<commons-io.version>2.17.0</commons-io.version>
|
||||
<commons-compress.version>1.26.0</commons-compress.version>
|
||||
<!-- Maven Plugin Versions -->
|
||||
@@ -131,9 +133,6 @@
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis Plus(MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,简化开发、提高效率) -->
|
||||
<!-- 注意:
|
||||
1、此注释在升级到 mybatis-plus 3.5.9 之后的版本时才进行启用,同时删掉后续相对应的mybatis-plus依赖
|
||||
2、不升级版本可忽略不计,此处仅为了后续升级,做准备
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-bom</artifactId>
|
||||
@@ -141,22 +140,6 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-core</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis Flex(MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,简化开发、提高效率) -->
|
||||
<dependency>
|
||||
@@ -226,11 +209,39 @@
|
||||
<version>${nashorn.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Easy Excel(基于 Java 的、快速、简洁、解决大文件内存溢出的 Excel 处理工具) -->
|
||||
<!-- FastExcel(基于 Java 的快速、简洁、解决大文件内存溢出的 Excel 处理工具) -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>${easy-excel.version}</version>
|
||||
<groupId>cn.idev.excel</groupId>
|
||||
<artifactId>fastexcel</artifactId>
|
||||
<version>${fastexcel.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache POI(适用于 Microsoft 文档的 Java API) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- X File Storage(一行代码将文件存储到本地、FTP、SFTP、WebDAV、阿里云 OSS、华为云 OBS...等其它兼容 S3 协议的存储平台) -->
|
||||
@@ -244,27 +255,23 @@
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>${aws-s3.version}</version>
|
||||
<version>${aws-s3-v1.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- S3 for Java 2.x -->
|
||||
<!-- Amazon SDK -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
<version>${s3.version}</version>
|
||||
</dependency>
|
||||
<!-- 基于 AWS CRT 的 S3 客户端的性能增强的 S3 传输管理器 -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3-transfer-manager</artifactId>
|
||||
<version>${s3.version}</version>
|
||||
<artifactId>bom</artifactId>
|
||||
<version>${aws-sdk.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 使用 AWS 基于 CRT 的 S3 客户端 -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk.crt</groupId>
|
||||
<artifactId>aws-crt</artifactId>
|
||||
<version>${s3-crt.version}</version>
|
||||
<version>${aws-crt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Thumbnailator(缩略图生成库) -->
|
||||
@@ -281,6 +288,13 @@
|
||||
<version>${graceful-response.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpEL Validator(基于 SpEL 的 jakarta.validation-api 扩展增强包) -->
|
||||
<dependency>
|
||||
<groupId>cn.sticki</groupId>
|
||||
<artifactId>spel-validator-jakarta</artifactId>
|
||||
<version>${spel-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Crane4j(基于注解的,用于完成一切 “根据 A 的 key 值拿到 B,再把 B 的属性映射到 A” 这类需求的字段填充框架) -->
|
||||
<dependency>
|
||||
<groupId>cn.crane4j</groupId>
|
||||
@@ -304,11 +318,17 @@
|
||||
<version>${tlog.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SnakeYAML(适用于 Java 的 YAML 1.1 解析器和发射器) -->
|
||||
<!-- TrueLicense (开源的证书管理引擎) -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${snakeyaml.version}</version>
|
||||
<groupId>de.schlichtherle.truelicense</groupId>
|
||||
<artifactId>truelicense-core</artifactId>
|
||||
<version>${truelicense.version}</version>
|
||||
</dependency>
|
||||
<!-- Zip4j (开源的 Java 处理 zip 压缩文件的开发包) -->
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>${zip4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- OkHTTP(默认高效的 HTTP 客户端) -->
|
||||
@@ -346,17 +366,11 @@
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TrueLicense (开源的证书管理引擎) -->
|
||||
<!-- SnakeYAML(适用于 Java 的 YAML 1.1 解析器和发射器) -->
|
||||
<dependency>
|
||||
<groupId>de.schlichtherle.truelicense</groupId>
|
||||
<artifactId>truelicense-core</artifactId>
|
||||
<version>${truelicense.version}</version>
|
||||
</dependency>
|
||||
<!-- Zip4j (开源的 Java 处理 zip 压缩文件的开发包) -->
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>${zip4j.version}</version>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${snakeyaml.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 解决部分传递依赖漏洞问题 -->
|
||||
@@ -380,7 +394,7 @@
|
||||
|
||||
<!-- ContiNew Starter 依赖 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-bom</artifactId>
|
||||
<version>${revision}</version>
|
||||
<type>pom</type>
|
||||
|
||||
17
continew-starter-excel/continew-starter-excel-core/pom.xml
Normal file
17
continew-starter-excel/continew-starter-excel-core/pom.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-excel-core</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>ContiNew Starter Excel 文件处理模块 - 核心模块</description>
|
||||
</project>
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.excel.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel导出注解
|
||||
*
|
||||
* @author jiang4yu
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelExport {
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
String value();
|
||||
|
||||
/**
|
||||
* 导出排序先后: 数字越小越靠前(默认按Java类字段顺序导出)
|
||||
*/
|
||||
int sort() default 0;
|
||||
|
||||
/**
|
||||
* 导出映射,格式如:0-未知;1-男;2-女
|
||||
*/
|
||||
String kv() default "";
|
||||
|
||||
/**
|
||||
* 导出模板示例值(有值的话,直接取该值,不做映射)
|
||||
*/
|
||||
String example() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.excel.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel 导入注解
|
||||
*
|
||||
* @author jiang4yu
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ExcelImport {
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
String value();
|
||||
|
||||
/**
|
||||
* 导出映射,格式如:0-未知;1-男;2-女
|
||||
*/
|
||||
String kv() default "";
|
||||
|
||||
/**
|
||||
* 是否为必填字段(默认为非必填)
|
||||
*/
|
||||
boolean required() default false;
|
||||
|
||||
/**
|
||||
* 最大长度(默认255)
|
||||
*/
|
||||
int maxLength() default 255;
|
||||
|
||||
/**
|
||||
* 导入唯一性验证(多个字段则取联合验证)
|
||||
*/
|
||||
boolean unique() default false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-excel-fastexcel</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>ContiNew Starter Excel 文件处理模块 - FastExcel</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- Excel 文件处理模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- FastExcel(基于 Java 的快速、简洁、解决大文件内存溢出的 Excel 处理工具) -->
|
||||
<dependency>
|
||||
<groupId>cn.idev.excel</groupId>
|
||||
<artifactId>fastexcel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -14,22 +14,23 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.file.excel.converter;
|
||||
package top.continew.starter.excel.converter;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import cn.idev.excel.converters.Converter;
|
||||
import cn.idev.excel.enums.CellDataTypeEnum;
|
||||
import cn.idev.excel.metadata.GlobalConfiguration;
|
||||
import cn.idev.excel.metadata.data.ReadCellData;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.metadata.property.ExcelContentProperty;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.enums.BaseEnum;
|
||||
|
||||
/**
|
||||
* Easy Excel 枚举接口转换器
|
||||
*
|
||||
* @author Charles7c
|
||||
* @see BaseEnum
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public class ExcelBaseEnumConverter implements Converter<BaseEnum<?>> {
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.file.excel.converter;
|
||||
package top.continew.starter.excel.converter;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import cn.idev.excel.converters.Converter;
|
||||
import cn.idev.excel.enums.CellDataTypeEnum;
|
||||
import cn.idev.excel.metadata.GlobalConfiguration;
|
||||
import cn.idev.excel.metadata.data.ReadCellData;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
/**
|
||||
* Easy Excel 大数值转换器
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.file.excel.converter;
|
||||
package top.continew.starter.excel.converter;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import cn.idev.excel.converters.Converter;
|
||||
import cn.idev.excel.enums.CellDataTypeEnum;
|
||||
import cn.idev.excel.metadata.GlobalConfiguration;
|
||||
import cn.idev.excel.metadata.data.ReadCellData;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.metadata.property.ExcelContentProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.file.excel.util;
|
||||
package top.continew.starter.excel.util;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.alibaba.excel.EasyExcelFactory;
|
||||
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import cn.idev.excel.FastExcelFactory;
|
||||
import cn.idev.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import top.continew.starter.core.exception.BaseException;
|
||||
import top.continew.starter.file.excel.converter.ExcelBigNumberConverter;
|
||||
import top.continew.starter.excel.converter.ExcelBigNumberConverter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -78,7 +78,7 @@ public class ExcelUtils {
|
||||
.format(new Date(), DatePattern.PURE_DATETIME_PATTERN)));
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + exportFileName);
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
EasyExcelFactory.write(response.getOutputStream(), clazz)
|
||||
FastExcelFactory.write(response.getOutputStream(), clazz)
|
||||
.autoCloseStream(false)
|
||||
// 自动适配宽度
|
||||
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
||||
35
continew-starter-excel/continew-starter-excel-poi/pom.xml
Normal file
35
continew-starter-excel/continew-starter-excel-poi/pom.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<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>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-excel-poi</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>ContiNew Starter Excel 文件处理模块 - POI</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- Excel 文件处理模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache POI(适用于 Microsoft 文档的 Java API) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件上传 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.excel.model;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* Excel 字段信息
|
||||
*
|
||||
* @author jiang4yu
|
||||
* @since 2.13.0
|
||||
*/
|
||||
public class ExcelClassField {
|
||||
|
||||
/**
|
||||
* 字段名称
|
||||
*/
|
||||
private String fieldName;
|
||||
|
||||
/**
|
||||
* 表头名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 映射关系
|
||||
*/
|
||||
private LinkedHashMap<String, String> kvMap;
|
||||
|
||||
/**
|
||||
* 示例值
|
||||
*/
|
||||
private Object example;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private int sort;
|
||||
|
||||
/**
|
||||
* 是否为注解字段:0-否,1-是
|
||||
*/
|
||||
private int hasAnnotation;
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LinkedHashMap<String, String> getKvMap() {
|
||||
return kvMap;
|
||||
}
|
||||
|
||||
public void setKvMap(LinkedHashMap<String, String> kvMap) {
|
||||
this.kvMap = kvMap;
|
||||
}
|
||||
|
||||
public Object getExample() {
|
||||
return example;
|
||||
}
|
||||
|
||||
public void setExample(Object example) {
|
||||
this.example = example;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(int sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public int getHasAnnotation() {
|
||||
return hasAnnotation;
|
||||
}
|
||||
|
||||
public void setHasAnnotation(int hasAnnotation) {
|
||||
this.hasAnnotation = hasAnnotation;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,25 +4,27 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-file</artifactId>
|
||||
<artifactId>continew-starter-excel</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>ContiNew Starter 文件处理模块</description>
|
||||
<description>ContiNew Starter Excel 文件处理模块</description>
|
||||
|
||||
<modules>
|
||||
<module>continew-starter-file-excel</module>
|
||||
<module>continew-starter-excel-core</module>
|
||||
<module>continew-starter-excel-fastexcel</module>
|
||||
<module>continew-starter-excel-poi</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,32 +18,26 @@
|
||||
<dependencies>
|
||||
<!-- API 文档模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 文件处理模块 - Excel -->
|
||||
<!-- Excel 文件处理模块 - FastExcel -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<artifactId>continew-starter-file-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Crane4j(基于注解的,用于完成一切 “根据 A 的 key 值拿到 B,再把 B 的属性映射到 A” 这类需求的字段填充框架) -->
|
||||
<dependency>
|
||||
<groupId>cn.crane4j</groupId>
|
||||
<artifactId>crane4j-spring-boot-starter</artifactId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-excel-fastexcel</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -16,13 +16,21 @@
|
||||
|
||||
package top.continew.starter.extension.crud.annotation;
|
||||
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeProperties;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 树结构字段
|
||||
*
|
||||
* @author Charles7c
|
||||
* <p>
|
||||
* 用于复杂树场景,例如:表格
|
||||
* </p>
|
||||
*
|
||||
* @see cn.hutool.core.lang.tree.TreeNodeConfig
|
||||
* @see CrudTreeProperties
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudApi;
|
||||
import top.continew.starter.extension.crud.controller.AbstractBaseController;
|
||||
import top.continew.starter.extension.crud.controller.AbstractCrudController;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
@@ -46,8 +46,8 @@ public class CrudApiAnnotationInterceptor implements MethodInterceptor {
|
||||
// 获取 @CrudApi 注解
|
||||
CrudApi crudApi = AnnotatedElementUtils.findMergedAnnotation(targetMethod, CrudApi.class);
|
||||
// 执行处理
|
||||
AbstractBaseController controller = (AbstractBaseController)invocation.getThis();
|
||||
controller.preHandle(crudApi, invocation.getArguments(), targetMethod, targetClass);
|
||||
AbstractCrudController crudController = (AbstractCrudController)invocation.getThis();
|
||||
crudController.preHandle(crudApi, invocation.getArguments(), targetMethod, targetClass);
|
||||
return invocation.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class CrudProperties {
|
||||
|
||||
/**
|
||||
* 树配置
|
||||
* <p>用于简单树场景,例如:树选择(下拉)</p>
|
||||
*/
|
||||
@NestedConfigurationProperty
|
||||
private CrudTreeProperties tree = new CrudTreeProperties();
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
import top.continew.starter.core.util.ExceptionUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudApi;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
|
||||
@@ -50,16 +51,25 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi
|
||||
return requestMappingInfo;
|
||||
}
|
||||
CrudRequestMapping crudRequestMapping = handlerType.getDeclaredAnnotation(CrudRequestMapping.class);
|
||||
// 过滤 API,如果非本类中定义,且 API 列表中不包含,则忽略
|
||||
Api[] apiArr = crudRequestMapping.api();
|
||||
Api api = ExceptionUtils.exToNull(() -> Api.valueOf(method.getName().toUpperCase()));
|
||||
if (method.getDeclaringClass() != handlerType && !ArrayUtil.contains(apiArr, api)) {
|
||||
CrudApi crudApi = AnnotatedElementUtils.findMergedAnnotation(method, CrudApi.class);
|
||||
// 过滤 API:如果非本类中定义,且 API 列表中不包含,则忽略
|
||||
Api[] apis = crudRequestMapping.api();
|
||||
if (method.getDeclaringClass() != handlerType && !ArrayUtil.contains(apis, ExceptionUtils
|
||||
.exToNull(crudApi::value))) {
|
||||
return null;
|
||||
}
|
||||
// 拼接路径(合并了 @RequestMapping 的部分能力)
|
||||
return this.getMappingForMethodWrapper(method, handlerType, crudRequestMapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求映射信息
|
||||
*
|
||||
* @param method 方法
|
||||
* @param handlerType 处理程序类型
|
||||
* @param crudRequestMapping CRUD 请求映射
|
||||
* @return 请求映射信息
|
||||
*/
|
||||
private RequestMappingInfo getMappingForMethodWrapper(@NonNull Method method,
|
||||
@NonNull Class<?> handlerType,
|
||||
CrudRequestMapping crudRequestMapping) {
|
||||
@@ -79,6 +89,12 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建请求映射信息
|
||||
*
|
||||
* @param element 元素
|
||||
* @return 请求映射信息
|
||||
*/
|
||||
private RequestMappingInfo buildRequestMappingInfo(AnnotatedElement element) {
|
||||
RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, RequestMapping.class);
|
||||
RequestCondition<?> condition = (element instanceof Class<?> clazz
|
||||
|
||||
@@ -17,12 +17,18 @@
|
||||
package top.continew.starter.extension.crud.autoconfigure;
|
||||
|
||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
|
||||
/**
|
||||
* CRUD 树列表配置属性
|
||||
*
|
||||
* <p>
|
||||
* 用于简单树场景,例如:树选择(下拉)
|
||||
* </p>
|
||||
*
|
||||
* @see TreeField
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2.7.2
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -33,23 +34,23 @@ import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.req.IdsReq;
|
||||
import top.continew.starter.extension.crud.model.resp.IdResp;
|
||||
import top.continew.starter.extension.crud.model.resp.BasePageResp;
|
||||
import top.continew.starter.extension.crud.service.BaseService;
|
||||
import top.continew.starter.extension.crud.service.CrudService;
|
||||
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器抽象基类
|
||||
* CRUD 控制器抽象基类
|
||||
*
|
||||
* @param <S> 业务接口
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <Q> 查询条件类型
|
||||
* @param <C> 创建或修改请求参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>, L, D, Q, C> implements CrudApiHandler {
|
||||
public abstract class AbstractCrudController<S extends CrudService<L, D, Q, C>, L, D, Q, C> implements CrudApiHandler {
|
||||
|
||||
@Autowired
|
||||
protected S baseService;
|
||||
@@ -65,7 +66,7 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@Operation(summary = "分页查询列表", description = "分页查询列表")
|
||||
@ResponseBody
|
||||
@GetMapping
|
||||
public BasePageResp<L> page(@Validated Q query, @Validated PageQuery pageQuery) {
|
||||
public BasePageResp<L> page(@Valid Q query, @Valid PageQuery pageQuery) {
|
||||
return baseService.page(query, pageQuery);
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@Operation(summary = "查询列表", description = "查询列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/list")
|
||||
public List<L> list(@Validated Q query, @Validated SortQuery sortQuery) {
|
||||
public List<L> list(@Valid Q query, @Valid SortQuery sortQuery) {
|
||||
return baseService.list(query, sortQuery);
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@Operation(summary = "查询树列表", description = "查询树列表")
|
||||
@ResponseBody
|
||||
@GetMapping("/tree")
|
||||
public List<Tree<Long>> tree(@Validated Q query, @Validated SortQuery sortQuery) {
|
||||
public List<Tree<Long>> tree(@Valid Q query, @Valid SortQuery sortQuery) {
|
||||
return baseService.tree(query, sortQuery, false);
|
||||
}
|
||||
|
||||
@@ -124,7 +125,8 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@Operation(summary = "创建数据", description = "创建数据")
|
||||
@ResponseBody
|
||||
@PostMapping
|
||||
public IdResp<Long> create(@Validated(CrudValidationGroup.Create.class) @RequestBody C req) {
|
||||
@Validated(CrudValidationGroup.Create.class)
|
||||
public IdResp<Long> create(@RequestBody @Valid C req) {
|
||||
return new IdResp<>(baseService.create(req));
|
||||
}
|
||||
|
||||
@@ -139,20 +141,35 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@ResponseBody
|
||||
@PutMapping("/{id}")
|
||||
public void update(@Validated(CrudValidationGroup.Update.class) @RequestBody C req, @PathVariable("id") Long id) {
|
||||
@Validated(CrudValidationGroup.Update.class)
|
||||
public void update(@RequestBody @Valid C req, @PathVariable("id") Long id) {
|
||||
baseService.update(req, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param req 删除请求参数
|
||||
* @param id ID
|
||||
*/
|
||||
@CrudApi(Api.DELETE)
|
||||
@Operation(summary = "删除数据", description = "删除数据")
|
||||
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
|
||||
@ResponseBody
|
||||
@DeleteMapping("/{id}")
|
||||
public void delete(@PathVariable("id") Long id) {
|
||||
baseService.delete(List.of(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param req 删除请求参数
|
||||
*/
|
||||
@CrudApi(Api.BATCH_DELETE)
|
||||
@Operation(summary = "批量删除数据", description = "批量删除数据")
|
||||
@ResponseBody
|
||||
@DeleteMapping
|
||||
public void delete(@Validated @RequestBody IdsReq req) {
|
||||
public void batchDelete(@RequestBody @Valid IdsReq req) {
|
||||
baseService.delete(req.getIds());
|
||||
}
|
||||
|
||||
@@ -167,7 +184,7 @@ public abstract class AbstractBaseController<S extends BaseService<L, D, Q, C>,
|
||||
@ExcludeFromGracefulResponse
|
||||
@Operation(summary = "导出数据", description = "导出数据")
|
||||
@GetMapping("/export")
|
||||
public void export(@Validated Q query, @Validated SortQuery sortQuery, HttpServletResponse response) {
|
||||
public void export(@Valid Q query, @Valid SortQuery sortQuery, HttpServletResponse response) {
|
||||
baseService.export(query, sortQuery, response);
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,9 @@ public enum Api {
|
||||
* 导出
|
||||
*/
|
||||
EXPORT,
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*/
|
||||
BATCH_DELETE,
|
||||
}
|
||||
@@ -21,8 +21,8 @@ import cn.hutool.core.util.ArrayUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.data.core.util.SqlInjectionUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.data.util.SqlInjectionUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -18,24 +18,28 @@ package top.continew.starter.extension.crud.service;
|
||||
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.BasePageResp;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.extension.crud.validation.CrudValidationGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务接口基类
|
||||
* CRUD 业务接口
|
||||
*
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <Q> 查询条件类型
|
||||
* @param <C> 创建或修改请求参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface BaseService<L, D, Q, C> {
|
||||
public interface CrudService<L, D, Q, C> {
|
||||
|
||||
/**
|
||||
* 分页查询列表
|
||||
@@ -44,7 +48,7 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param pageQuery 分页查询条件
|
||||
* @return 分页列表信息
|
||||
*/
|
||||
BasePageResp<L> page(Q query, PageQuery pageQuery);
|
||||
BasePageResp<L> page(@Valid Q query, @Valid PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
@@ -53,7 +57,7 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param sortQuery 排序查询条件
|
||||
* @return 列表信息
|
||||
*/
|
||||
List<L> list(Q query, SortQuery sortQuery);
|
||||
List<L> list(@Valid Q query, @Valid SortQuery sortQuery);
|
||||
|
||||
/**
|
||||
* 查询树列表
|
||||
@@ -67,7 +71,7 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param isSimple 是否为简单树结构(不包含基本树结构之外的扩展字段,简单树(下拉列表)使用全局配置结构,复杂树(表格)使用 @DictField 局部配置)
|
||||
* @return 树列表信息
|
||||
*/
|
||||
List<Tree<Long>> tree(Q query, SortQuery sortQuery, boolean isSimple);
|
||||
List<Tree<Long>> tree(@Valid Q query, @Valid SortQuery sortQuery, boolean isSimple);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
@@ -85,7 +89,7 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @return 字典列表信息
|
||||
* @since 2.1.0
|
||||
*/
|
||||
List<LabelValueResp> listDict(Q query, SortQuery sortQuery);
|
||||
List<LabelValueResp> listDict(@Valid Q query, @Valid SortQuery sortQuery);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
@@ -93,7 +97,8 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param req 创建请求参数
|
||||
* @return 自增 ID
|
||||
*/
|
||||
Long create(C req);
|
||||
@Validated(CrudValidationGroup.Create.class)
|
||||
Long create(@Valid C req);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
@@ -101,14 +106,15 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param req 修改请求参数
|
||||
* @param id ID
|
||||
*/
|
||||
void update(C req, Long id);
|
||||
@Validated(CrudValidationGroup.Update.class)
|
||||
void update(@Valid C req, Long id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids ID 列表
|
||||
*/
|
||||
void delete(List<Long> ids);
|
||||
void delete(@NotEmpty(message = "ID 不能为空") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 导出
|
||||
@@ -117,5 +123,5 @@ public interface BaseService<L, D, Q, C> {
|
||||
* @param sortQuery 排序查询条件
|
||||
* @param response 响应对象
|
||||
*/
|
||||
void export(Q query, SortQuery sortQuery, HttpServletResponse response);
|
||||
void export(@Valid Q query, @Valid SortQuery sortQuery, HttpServletResponse response);
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,13 +18,13 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - MyBatis Flex -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-mf</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.continew.starter.extension.crud.service;
|
||||
|
||||
import cn.crane4j.core.support.OperateTemplate;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -33,10 +32,10 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.data.mf.base.BaseMapper;
|
||||
import top.continew.starter.data.mf.service.impl.ServiceImpl;
|
||||
import top.continew.starter.data.mf.util.QueryWrapperHelper;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.data.base.BaseMapper;
|
||||
import top.continew.starter.data.service.impl.ServiceImpl;
|
||||
import top.continew.starter.data.util.QueryWrapperHelper;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudProperties;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudTreeProperties;
|
||||
@@ -44,7 +43,7 @@ import top.continew.starter.extension.crud.model.entity.BaseIdDO;
|
||||
import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.file.excel.util.ExcelUtils;
|
||||
import top.continew.starter.excel.util.ExcelUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -52,18 +51,18 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 业务实现基类
|
||||
* CRUD 业务实现基类
|
||||
*
|
||||
* @param <M> Mapper 接口
|
||||
* @param <T> 实体类型
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <Q> 查询条件类型
|
||||
* @param <C> 创建或修改请求参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D, Q, C> extends ServiceImpl<M, T> implements BaseService<L, D, Q, C> {
|
||||
public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D, Q, C> extends ServiceImpl<M, T> implements CrudService<L, D, Q, C> {
|
||||
|
||||
protected final Class<L> listClass = this.currentListClass();
|
||||
protected final Class<D> detailClass = this.currentDetailClass();
|
||||
@@ -214,19 +213,6 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
OperateTemplate operateTemplate = SpringUtil.getBean(OperateTemplate.class);
|
||||
operateTemplate.execute(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 QueryWrapper
|
||||
*
|
||||
@@ -239,6 +225,14 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
return QueryWrapperHelper.build(query, queryFields, queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增前置处理
|
||||
*
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
@@ -18,13 +18,13 @@
|
||||
<dependencies>
|
||||
<!-- 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension-crud-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-data-mp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package top.continew.starter.extension.crud.service;
|
||||
|
||||
import cn.crane4j.core.support.OperateTemplate;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
@@ -37,12 +36,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
import top.continew.starter.core.util.ClassUtils;
|
||||
import top.continew.starter.core.util.ReflectUtils;
|
||||
import top.continew.starter.core.validation.CheckUtils;
|
||||
import top.continew.starter.core.validation.ValidationUtils;
|
||||
import top.continew.starter.data.mp.base.BaseMapper;
|
||||
import top.continew.starter.data.mp.service.impl.ServiceImpl;
|
||||
import top.continew.starter.data.mp.util.QueryWrapperHelper;
|
||||
import top.continew.starter.extension.crud.annotation.DictModel;
|
||||
import top.continew.starter.data.mapper.BaseMapper;
|
||||
import top.continew.starter.data.service.impl.ServiceImpl;
|
||||
import top.continew.starter.data.util.QueryWrapperHelper;
|
||||
import top.continew.starter.extension.crud.annotation.DictModel;
|
||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.continew.starter.extension.crud.autoconfigure.CrudProperties;
|
||||
@@ -52,24 +48,26 @@ import top.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
|
||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||
import top.continew.starter.file.excel.util.ExcelUtils;
|
||||
import top.continew.starter.excel.util.ExcelUtils;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 业务实现基类
|
||||
* CRUD 业务实现基类
|
||||
*
|
||||
* @param <M> Mapper 接口
|
||||
* @param <T> 实体类型
|
||||
* @param <L> 列表类型
|
||||
* @param <D> 详情类型
|
||||
* @param <Q> 查询条件
|
||||
* @param <Q> 查询条件类型
|
||||
* @param <C> 创建或修改参数类型
|
||||
* @author Charles7c
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D, Q, C> extends ServiceImpl<M, T> implements BaseService<L, D, Q, C> {
|
||||
public abstract class CrudServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D, Q, C> extends ServiceImpl<M, T> implements CrudService<L, D, Q, C> {
|
||||
|
||||
private Class<L> listClass;
|
||||
private Class<D> detailClass;
|
||||
@@ -305,19 +303,6 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
OperateTemplate operateTemplate = SpringUtil.getBean(OperateTemplate.class);
|
||||
operateTemplate.execute(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 QueryWrapper
|
||||
*
|
||||
@@ -330,6 +315,14 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdD
|
||||
return QueryWrapperHelper.build(query, this.getQueryFields(), queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充数据
|
||||
*
|
||||
* @param obj 待填充信息
|
||||
*/
|
||||
protected void fill(Object obj) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增前置处理
|
||||
*
|
||||
@@ -4,7 +4,7 @@
|
||||
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>top.continew</groupId>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-extension</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user