mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-11-12 06:57:10 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1207983ce1 | |||
| ab7e987672 | |||
| 9ed2dac00c | |||
| 9bd4583223 | |||
| 3f2a306cad | |||
| 31ca1fda52 | |||
| 56a22c4bce | |||
| 4ffc5dc1d4 | |||
| d42585cb4d | |||
| c9867844b6 | |||
| 89108ad55a | |||
| 557ea13757 | |||
| 2e5788f007 | |||
| 90eaab8dbd |
40
CHANGELOG.md
40
CHANGELOG.md
@@ -1,3 +1,29 @@
|
||||
## [v1.4.1](https://github.com/Charles7c/continew-starter/compare/v1.4.0...v1.4.1) (2024-02-21)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
- 【data/core】新增 continew-starter-data-core 模块 ([4ffc5dc](https://github.com/Charles7c/continew-starter/commit/4ffc5dc1d4cdbb572070312eef172a197e216318))
|
||||
- 【data/core】新增获取数据库类型带默认类型方法 ([31ca1fd](https://github.com/Charles7c/continew-starter/commit/31ca1fda528629906958d8422897ac8ae179daab))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
- 【security/crypto】调整部分 StrUtil => CharSequenceUtil ([2e5788f](https://github.com/Charles7c/continew-starter/commit/2e5788f007f61f0ec531aa69834229d128311398))
|
||||
- 【data/mybatis-plus】移除 ` 符号的使用,保持数据库无关性 ([557ea13](https://github.com/Charles7c/continew-starter/commit/557ea1375728695c027004e64e2fa8d2d66215e6))
|
||||
- 【core】完善自定义异常类构造方法 ([d42585c](https://github.com/Charles7c/continew-starter/commit/d42585cb4d6660724db004893f57a6c67b4690e1))
|
||||
- 【cache/redisson】完善 Redisson 工具类 ([9ed2dac](https://github.com/Charles7c/continew-starter/commit/9ed2dac00c58621cbc133e3e072c100306cf170a))
|
||||
- 优化字符串模板方法 API 使用 ([c986784](https://github.com/Charles7c/continew-starter/commit/c9867844b650a69f6b3b3ea4f9af67807091eb1b))
|
||||
|
||||
### 🐛 问题修复
|
||||
|
||||
- 【data/mybatis-plus】修复 Query In、Not In 查询数据类型转换错误 ([9bd4583](https://github.com/Charles7c/continew-starter/commit/9bd458322339f3197f1925347ff16f53fe0f3856))
|
||||
|
||||
### 💥 破坏性变更
|
||||
|
||||
- 【log/core】continew-starter-log-common => continew-starter-log-core ([56a22c4](https://github.com/Charles7c/continew-starter/commit/56a22c4bce2445fb135d1fce7b6155fd5b48051e))
|
||||
- 【data/mybatis-plus】调整 Query 相关类到 data-core ([3f2a306](https://github.com/Charles7c/continew-starter/commit/3f2a306cad1d15436ae36c1b2eb54f28b50e84b9))
|
||||
- 【extension/crud】调整 IService 到 data-core ([ab7e987](https://github.com/Charles7c/continew-starter/commit/ab7e987672202f3e80c0e4f64ea0c576ff7cc89f))
|
||||
- 更新 Gitee 项目链接 ([89108ad](https://github.com/Charles7c/continew-starter/commit/89108ad55addeaf47f224f4ed90ecb42244dbfd8))
|
||||
|
||||
## [v1.4.0](https://github.com/Charles7c/continew-starter/compare/v1.3.0...v1.4.0) (2024-02-14)
|
||||
|
||||
### ✨ 新特性
|
||||
@@ -22,7 +48,7 @@
|
||||
### 🐛 问题修复
|
||||
|
||||
- 【extension/crud】修复删除后置处理方法访问修饰符使用错误 ([24f9975](https://github.com/Charles7c/continew-starter/commit/24f99754d041e113f07eb43570d6a49c4ff24008))
|
||||
- 【message/mail】修复发送邮件收件人不为空判断错误 ([Gitee PR#12](https://gitee.com/Charles7c/continew-starter/pulls/12))
|
||||
- 【message/mail】修复发送邮件收件人不为空判断错误 ([Gitee PR#12](https://gitee.com/continew/continew-starter/pulls/12))
|
||||
- 【auth/satoken】修复 SaInterceptor Bean 获取方式错误 ([1ba1596](https://github.com/Charles7c/continew-starter/commit/1ba1596f4e4b31d82e174e981711e45a1df67ee7))
|
||||
|
||||
### 📦 依赖升级
|
||||
@@ -46,19 +72,19 @@
|
||||
### ✨ 新特性
|
||||
|
||||
* 【data/mybatis-plus】新增 QueryIgnore 忽略查询解析注解 ([91651b0](https://github.com/Charles7c/continew-starter/commit/91651b0b59cf642cd59aca068d8bca4554dc9895))
|
||||
* 【security/password】新增安全模块-密码编码器自动配置 ([47a4d57](https://github.com/Charles7c/continew-starter/commit/47a4d57dee3739de12ccbe9e15e25aef5b9ae558)) ([Gitee PR#9](https://gitee.com/Charles7c/continew-starter/pulls/9))
|
||||
* 【security/password】新增安全模块-密码编码器自动配置 ([47a4d57](https://github.com/Charles7c/continew-starter/commit/47a4d57dee3739de12ccbe9e15e25aef5b9ae558)) ([Gitee PR#9](https://gitee.com/continew/continew-starter/pulls/9))
|
||||
* 【web】新增链路跟踪自动配置 ([8fc19ab](https://github.com/Charles7c/continew-starter/commit/8fc19ab9b87b1a1b6d290ee9a40d0157de267324))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
- 【extension/crud】排序字段增加是否存在校验 ([Gitee PR#7](https://gitee.com/Charles7c/continew-starter/pulls/7))
|
||||
- 【extension/crud】排序字段增加是否存在校验 ([Gitee PR#7](https://gitee.com/continew/continew-starter/pulls/7))
|
||||
- 【data/mybatis-plus】优化数据权限处理器代码结构 ([aecefa1](https://github.com/Charles7c/continew-starter/commit/aecefa15ecbb9660f2ffa2f3bef3ad9eeb810916))
|
||||
- 【auth/satoken】支持更灵活的动态化路由拦截鉴权 ([31f29db](https://github.com/Charles7c/continew-starter/commit/31f29db19dede2cbf6988946b0dd8c8f153d1bd9))
|
||||
- 【auth/satoken】优化 SaToken 持久层配置 ([e6f8ac8](https://github.com/Charles7c/continew-starter/commit/e6f8ac8afa1b6c487343dc88d8ac7fdfde40e58b))
|
||||
- 【captcha/behavior】优化行为验证码缓存配置 ([8598e6d](https://github.com/Charles7c/continew-starter/commit/8598e6d109c1ca6be3e973ceb41c6dd7bd93c333))
|
||||
- 【storage/local】优化存储模块依赖 ([dcb6568](https://github.com/Charles7c/continew-starter/commit/dcb6568916cd549f1c403ece1c4f4d29ecc320b9))
|
||||
- 移除 Lombok 私有构造注解使用 ([11d0798](https://github.com/Charles7c/continew-starter/commit/11d0798f92a5fe4eda6300a7e6065f2d3afef0df))
|
||||
- 移除 Lombok 依赖,再度精简依赖 ([0eb6afa](https://github.com/Charles7c/continew-starter/commit/0eb6afabb6ccaa9d421981280c896e381f68b9a6)) ([Gitee PR#9](https://gitee.com/Charles7c/continew-starter/pulls/9))
|
||||
- 移除 Lombok 依赖,再度精简依赖 ([0eb6afa](https://github.com/Charles7c/continew-starter/commit/0eb6afabb6ccaa9d421981280c896e381f68b9a6)) ([Gitee PR#9](https://gitee.com/continew/continew-starter/pulls/9))
|
||||
- 新增 Qodana、Sonar 扫描 ([ab1e999](https://github.com/Charles7c/continew-starter/commit/ab1e999094d9349a24eff51382a940f0ec682801)) ([1a8c589](https://github.com/Charles7c/continew-starter/commit/1a8c589083f80eddd2fe7e4c99751c699dd4d357))
|
||||
- 优化大量代码,解决 [Sonar](https://sonarcloud.io/organizations/charles7c/projects)、[Codacy](https://app.codacy.com/gh/Charles7c/continew-admin/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)、[Qodana](https://qodana.cloud/organizations/pQDPD/teams/p5jqd/) 扫描问题,点击各链接查看对应实时质量分析报告(Codacy 已达到 A)
|
||||
|
||||
@@ -89,7 +115,7 @@
|
||||
|
||||
- 新增部分 Maven 插件版本锁定 ([be14bca](https://github.com/Charles7c/continew-starter/commit/be14bca2ca6ba5a808f7feebaafcf9356d338643))
|
||||
- 移除部分无用 Maven 配置 ([6d9e8b4](https://github.com/Charles7c/continew-starter/commit/6d9e8b43ebe8d891ab459a2c2f21e06936abdc1d))
|
||||
- 全局统一 Hutool 版本,精简各模块 Hutool 依赖 ([Gitee PR#6](https://gitee.com/Charles7c/continew-starter/pulls/6))
|
||||
- 全局统一 Hutool 版本,精简各模块 Hutool 依赖 ([Gitee PR#6](https://gitee.com/continew/continew-starter/pulls/6))
|
||||
- 调整部分类的所在包 ([b4b40b4](https://github.com/Charles7c/continew-starter/commit/b4b40b4cb929824e44bc7ad8737cbe73b283b34d))
|
||||
|
||||
### 🐛 问题修复
|
||||
@@ -112,7 +138,7 @@
|
||||
### 💎 功能优化
|
||||
|
||||
- 【log/httptrace-pro】优化日志过滤器,仅在需要记录请求体、响应体时进行过滤 ([d68d88d](https://github.com/Charles7c/continew-starter/commit/d68d88db218d5008140c3056827dd6ac608a8b62))
|
||||
- 【log/httptrace-pro】优化 @Log 注解信息获取优先级逻辑 ([Gitee PR#5](https://gitee.com/Charles7c/continew-starter/pulls/5))
|
||||
- 【log/httptrace-pro】优化 @Log 注解信息获取优先级逻辑 ([Gitee PR#5](https://gitee.com/continew/continew-starter/pulls/5))
|
||||
- 【extension/crud】优化 BaseServiceImpl 中获取各泛型参数类型的方式 ([6fc0b51](https://github.com/Charles7c/continew-starter/commit/6fc0b51a574434db9d21d1f254b3fce344c9f2f6))
|
||||
- 【extension/crud】减少查询列表时可能的无用转换 ([0565372](https://github.com/Charles7c/continew-starter/commit/0565372e9aa8010a1c4625be4cf85d557a7eed7b))
|
||||
- 使用常量优化部分配置属性名 ([2025068](https://github.com/Charles7c/continew-starter/commit/20250681da7682de159b6259e80193b204e55047))
|
||||
@@ -131,7 +157,7 @@
|
||||
* 【storage/local】新增 continew-starter-storage-local 本地存储模块 ([cd6826a](https://github.com/Charles7c/continew-starter/commit/cd6826a0abe0666f9fe867e92bf70abb47e5ff2e))
|
||||
* 【cache/redisson】RedisUtils 新增限流方法 ([9cf3ae8](https://github.com/Charles7c/continew-starter/commit/9cf3ae87a1a20db9ee8b2b7272e8328b5fc5c20c))
|
||||
* 【data/mybatis-plus】新增数据权限默认解决方案 ([621a5e3](https://github.com/Charles7c/continew-starter/commit/621a5e3b22db9b81d31c65b39ad387a8531e09af))
|
||||
* 【captcha/behavior】新增 continew-starter-captcha-behavior 行为验证码模块 ([Gitee PR#1](https://gitee.com/Charles7c/continew-starter/pulls/1))
|
||||
* 【captcha/behavior】新增 continew-starter-captcha-behavior 行为验证码模块 ([Gitee PR#1](https://gitee.com/continew/continew-starter/pulls/1))
|
||||
* 【core】新增 PATH_PATTERN 字符串常量 ([76e282c](https://github.com/Charles7c/continew-starter/commit/76e282c7965fdfa39854fe77397687bbc40d0f7f))
|
||||
|
||||
### 💎 功能优化
|
||||
|
||||
14
README.md
14
README.md
@@ -7,7 +7,7 @@
|
||||
<img src="https://img.shields.io/maven-central/v/top.charles7c.continew/continew-starter.svg?label=Maven%20Central&logo=sonatype&logoColor=FFF" alt="Release" />
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://img.shields.io/badge/RELEASE-v1.4.0-%23ff3f59.svg" alt="Release" />
|
||||
<img src="https://img.shields.io/badge/RELEASE-v1.4.1-%23ff3f59.svg" alt="Release" />
|
||||
</a>
|
||||
<a href="https://app.codacy.com/gh/Charles7c/continew-starter/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade" target="_blank">
|
||||
<img src="https://app.codacy.com/project/badge/Grade/90ed633957a9410aa8745f0654827c01" alt="Codacy Badge" />
|
||||
@@ -27,11 +27,11 @@
|
||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://img.shields.io/github/forks/Charles7c/continew-starter?style=social" alt="GitHub forks" />
|
||||
</a>
|
||||
<a href="https://gitee.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://gitee.com/Charles7c/continew-starter/badge/star.svg?theme=white" alt="Gitee stars" />
|
||||
<a href="https://gitee.com/continew/continew-starter" target="_blank">
|
||||
<img src="https://gitee.com/continew/continew-starter/badge/star.svg?theme=white" alt="Gitee stars" />
|
||||
</a>
|
||||
<a href="https://gitee.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://gitee.com/Charles7c/continew-starter/badge/fork.svg?theme=white" alt="Gitee forks" />
|
||||
<a href="https://gitee.com/continew/continew-starter" target="_blank">
|
||||
<img src="https://gitee.com/continew/continew-starter/badge/fork.svg?theme=white" alt="Gitee forks" />
|
||||
</a>
|
||||
|
||||
## 简介
|
||||
@@ -66,7 +66,7 @@ ContiNew Starter 就是将脚手架项目中的通用基础配置进行了封装
|
||||
| 开源平台 | 源码地址 |
|
||||
| :------------ | :-------------------------------------------- |
|
||||
| GitHub | https://github.com/Charles7c/continew-starter |
|
||||
| Gitee(码云) | https://gitee.com/Charles7c/continew-starter |
|
||||
| Gitee(码云) | https://gitee.com/continew/continew-starter |
|
||||
|
||||
## 像数1,2,3一样容易
|
||||
|
||||
@@ -201,6 +201,7 @@ continew-starter.web:
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ---------------------------------- | ----------------------------------------- | -------- |
|
||||
| continew-starter-log-core | 日志核心模块 | |
|
||||
| continew-starter-log-httptrace-pro | Spring Boot Actuator HttpTrace 重置增强版 | |
|
||||
|
||||
### 存储模块
|
||||
@@ -234,6 +235,7 @@ continew-starter.web:
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ---------------------------------- | --------------------- | ------------------------------------------------------------ |
|
||||
| continew-starter-data-core | 数据访问核心模块 | |
|
||||
| continew-starter-data-mybatis-plus | MyBatis Plus 自动配置 | <a href="https://baomidou.com/" target="_blank">MyBatis Plus</a>:3.5.5<br /><a href="https://www.kancloud.cn/tracy5546/dynamic-datasource/2264611" target="_blank">dynamic-datasource-spring-boot-starter</a>:4.3.0<br /><a href="https://github.com/p6spy/p6spy" target="_blank">P6Spy</a>:3.9.1 |
|
||||
|
||||
### 认证模块
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SpringDocAutoConfiguration implements WebMvcConfigurer {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OpenAPI openApi(ProjectProperties projectProperties, SpringDocExtensionProperties properties) {
|
||||
Info info = new Info().title(String.format("%s %s", projectProperties.getName(), "API 文档"))
|
||||
Info info = new Info().title("%s %s".formatted(projectProperties.getName(), "API 文档"))
|
||||
.version(projectProperties.getVersion())
|
||||
.description(projectProperties.getDescription());
|
||||
ProjectProperties.Contact contact = projectProperties.getContact();
|
||||
|
||||
@@ -140,7 +140,7 @@ public class SaTokenDaoRedisImpl implements SaTokenDao {
|
||||
|
||||
@Override
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) {
|
||||
Collection<String> keys = RedisUtils.keys(String.format("%s*%s*", prefix, keyword));
|
||||
Collection<String> keys = RedisUtils.keys("%s*%s*".formatted(prefix, keyword));
|
||||
List<String> list = new ArrayList<>(keys);
|
||||
return SaFoxUtil.searchList(list, start, size, sortType);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package top.charles7c.continew.starter.cache.redisson.util;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import org.redisson.api.*;
|
||||
import org.redisson.config.Config;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -44,7 +43,7 @@ public class RedisUtils {
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
*/
|
||||
public static <T> void set(final String key, final T value) {
|
||||
public static <T> void set(String key, T value) {
|
||||
CLIENT.getBucket(key).set(value);
|
||||
}
|
||||
|
||||
@@ -55,7 +54,7 @@ public class RedisUtils {
|
||||
* @param value 值
|
||||
* @param duration 过期时间
|
||||
*/
|
||||
public static <T> void set(final String key, final T value, final Duration duration) {
|
||||
public static <T> void set(String key, T value, Duration duration) {
|
||||
RBatch batch = CLIENT.createBatch();
|
||||
RBucketAsync<T> bucket = batch.getBucket(key);
|
||||
bucket.setAsync(value);
|
||||
@@ -69,7 +68,7 @@ public class RedisUtils {
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public static <T> T get(final String key) {
|
||||
public static <T> T get(String key) {
|
||||
RBucket<T> bucket = CLIENT.getBucket(key);
|
||||
return bucket.get();
|
||||
}
|
||||
@@ -80,10 +79,19 @@ public class RedisUtils {
|
||||
* @param key 键
|
||||
* @return true:设置成功;false:设置失败
|
||||
*/
|
||||
public static boolean delete(final String key) {
|
||||
public static boolean delete(String key) {
|
||||
return CLIENT.getBucket(key).delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
*
|
||||
* @param pattern 键模式
|
||||
*/
|
||||
public static void deleteByPattern(String pattern) {
|
||||
CLIENT.getKeys().deleteByPattern(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存过期时间
|
||||
*
|
||||
@@ -91,7 +99,7 @@ public class RedisUtils {
|
||||
* @param timeout 过期时间(单位:秒)
|
||||
* @return true:设置成功;false:设置失败
|
||||
*/
|
||||
public static boolean expire(final String key, final long timeout) {
|
||||
public static boolean expire(String key, long timeout) {
|
||||
return expire(key, Duration.ofSeconds(timeout));
|
||||
}
|
||||
|
||||
@@ -102,7 +110,7 @@ public class RedisUtils {
|
||||
* @param duration 过期时间
|
||||
* @return true:设置成功;false:设置失败
|
||||
*/
|
||||
public static boolean expire(final String key, final Duration duration) {
|
||||
public static boolean expire(String key, Duration duration) {
|
||||
return CLIENT.getBucket(key).expire(duration);
|
||||
}
|
||||
|
||||
@@ -112,7 +120,7 @@ public class RedisUtils {
|
||||
* @param key 键
|
||||
* @return 缓存剩余过期时间(单位:毫秒)
|
||||
*/
|
||||
public static long getTimeToLive(final String key) {
|
||||
public static long getTimeToLive(String key) {
|
||||
return CLIENT.getBucket(key).remainTimeToLive();
|
||||
}
|
||||
|
||||
@@ -124,18 +132,18 @@ public class RedisUtils {
|
||||
*/
|
||||
public static boolean hasKey(String key) {
|
||||
RKeys keys = CLIENT.getKeys();
|
||||
return keys.countExists(getNameMapper().map(key)) > 0;
|
||||
return keys.countExists(key) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询缓存列表
|
||||
*
|
||||
* @param keyPattern 键表达式
|
||||
* @param pattern 键模式
|
||||
* @return 缓存列表
|
||||
*/
|
||||
public static Collection<String> keys(final String keyPattern) {
|
||||
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(getNameMapper().map(keyPattern));
|
||||
return stream.map(key -> getNameMapper().unmap(key)).toList();
|
||||
public static Collection<String> keys(String pattern) {
|
||||
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
|
||||
return stream.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,21 +170,4 @@ public class RedisUtils {
|
||||
public static String formatKey(String... subKeys) {
|
||||
return String.join(StringConstants.COLON, subKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Redisson 配置,获取名称映射器
|
||||
*
|
||||
* @return 名称映射器
|
||||
*/
|
||||
private static NameMapper getNameMapper() {
|
||||
Config config = CLIENT.getConfig();
|
||||
if (config.isClusterConfig()) {
|
||||
return config.useClusterServers().getNameMapper();
|
||||
}
|
||||
if (config.isSentinelConfig()) {
|
||||
return config.useSentinelServers().getNameMapper();
|
||||
}
|
||||
return config.useSingleServer().getNameMapper();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class SpringCacheAutoConfiguration implements CachingConfigurer {
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
paramMap.put(String.valueOf(i), params[i]);
|
||||
}
|
||||
return String.format("%s:%s", key, DigestUtil.sha256Hex(JSONUtil.toJsonStr(paramMap)));
|
||||
return "%s:%s".formatted(key, DigestUtil.sha256Hex(JSONUtil.toJsonStr(paramMap)));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -52,11 +52,5 @@
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-http</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Hutool 数据库模块(在 JDBC 基础上封装的数据库操作工具类,通过包装,使用 ActiveRecord 思想操作数据库) -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-db</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 自定义验证异常-错误请求
|
||||
*
|
||||
@@ -24,10 +26,21 @@ package top.charles7c.continew.starter.core.exception;
|
||||
*/
|
||||
public class BadRequestException extends BaseException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BadRequestException() {
|
||||
}
|
||||
|
||||
public BadRequestException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BadRequestException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BadRequestException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 自定义异常基类
|
||||
*
|
||||
@@ -24,10 +26,21 @@ package top.charles7c.continew.starter.core.exception;
|
||||
*/
|
||||
public class BaseException extends RuntimeException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BaseException() {
|
||||
}
|
||||
|
||||
public BaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BaseException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BaseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package top.charles7c.continew.starter.core.exception;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
@@ -24,10 +26,21 @@ package top.charles7c.continew.starter.core.exception;
|
||||
*/
|
||||
public class BusinessException extends BaseException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public BusinessException() {
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BusinessException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BusinessException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CheckUtils extends Validator {
|
||||
* @param fieldValue 字段值
|
||||
*/
|
||||
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, CharSequenceUtil
|
||||
String message = "%s 为 [%s] 的 %s 记录已不存在".formatted(fieldName, fieldValue, CharSequenceUtil
|
||||
.replace(entityName, "DO", StringConstants.EMPTY));
|
||||
throwIfNull(obj, message, EXCEPTION_TYPE);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class CheckUtils extends Validator {
|
||||
* @param fieldValue 字段值
|
||||
*/
|
||||
public static void throwIfExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
||||
String message = String.format("%s 为 [%s] 的 %s 记录已存在", fieldName, fieldValue, entityName);
|
||||
String message = "%s 为 [%s] 的 %s 记录已存在".formatted(fieldName, fieldValue, entityName);
|
||||
throwIfNotNull(obj, message, EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
|
||||
22
continew-starter-data/continew-starter-data-core/pom.xml
Normal file
22
continew-starter-data/continew-starter-data-core/pom.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-data</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
<description>ContiNew Starter 数据访问模块 - 核心模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- Hutool 数据库模块(在 JDBC 基础上封装的数据库操作工具类,通过包装,使用 ActiveRecord 思想操作数据库) -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-db</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -14,7 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.data.mybatis.plus.query;
|
||||
package top.charles7c.continew.starter.data.core.annotation;
|
||||
|
||||
import top.charles7c.continew.starter.data.core.enums.QueryType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.data.mybatis.plus.query;
|
||||
package top.charles7c.continew.starter.data.core.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.charles7c.continew.starter.data.core.enums;
|
||||
|
||||
import top.charles7c.continew.starter.data.core.function.ISqlFunction;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据库类型枚举
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public enum DatabaseType implements ISqlFunction {
|
||||
|
||||
/**
|
||||
* MySQL
|
||||
*/
|
||||
MYSQL("MySQL") {
|
||||
@Override
|
||||
public String findInSet(Serializable value, String set) {
|
||||
return "find_in_set('%s', %s) <> 0".formatted(value, set);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* PostgreSQL
|
||||
*/
|
||||
POSTGRE_SQL("PostgreSQL") {
|
||||
@Override
|
||||
public String findInSet(Serializable value, String set) {
|
||||
return "(select position(',%s,' in ','||%s||',')) <> 0".formatted(value, set);
|
||||
}
|
||||
},;
|
||||
|
||||
private final String database;
|
||||
|
||||
DatabaseType(String database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型
|
||||
*
|
||||
* @param database 数据库
|
||||
*/
|
||||
public static DatabaseType get(String database) {
|
||||
for (DatabaseType databaseType : DatabaseType.values()) {
|
||||
if (databaseType.database.equalsIgnoreCase(database)) {
|
||||
return databaseType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return database;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.data.mybatis.plus.query;
|
||||
package top.charles7c.continew.starter.data.core.enums;
|
||||
|
||||
/**
|
||||
* 查询类型枚举
|
||||
@@ -25,72 +25,72 @@ package top.charles7c.continew.starter.data.mybatis.plus.query;
|
||||
public enum QueryType {
|
||||
|
||||
/**
|
||||
* 等于 =,例如:WHERE `age` = 18
|
||||
* 等于 =,例如:WHERE age = 18
|
||||
*/
|
||||
EQ,
|
||||
|
||||
/**
|
||||
* 不等于 !=,例如:WHERE `age` != 18
|
||||
* 不等于 !=,例如:WHERE age != 18
|
||||
*/
|
||||
NE,
|
||||
|
||||
/**
|
||||
* 大于 >,例如:WHERE `age` > 18
|
||||
* 大于 >,例如:WHERE age > 18
|
||||
*/
|
||||
GT,
|
||||
|
||||
/**
|
||||
* 大于等于 >= ,例如:WHERE `age` >= 18
|
||||
* 大于等于 >= ,例如:WHERE age >= 18
|
||||
*/
|
||||
GE,
|
||||
|
||||
/**
|
||||
* 小于 <,例如:WHERE `age` < 18
|
||||
* 小于 <,例如:WHERE age < 18
|
||||
*/
|
||||
LT,
|
||||
|
||||
/**
|
||||
* 小于等于 <=,例如:WHERE `age` <= 18
|
||||
* 小于等于 <=,例如:WHERE age <= 18
|
||||
*/
|
||||
LE,
|
||||
|
||||
/**
|
||||
* 范围查询,例如:WHERE `age` BETWEEN 10 AND 18
|
||||
* 范围查询,例如:WHERE age BETWEEN 10 AND 18
|
||||
*/
|
||||
BETWEEN,
|
||||
|
||||
/**
|
||||
* LIKE '%值%',例如:WHERE `nickname` LIKE '%s%'
|
||||
* LIKE '%值%',例如:WHERE nickname LIKE '%s%'
|
||||
*/
|
||||
LIKE,
|
||||
|
||||
/**
|
||||
* LIKE '%值',例如:WHERE `nickname` LIKE '%s'
|
||||
* LIKE '%值',例如:WHERE nickname LIKE '%s'
|
||||
*/
|
||||
LIKE_LEFT,
|
||||
|
||||
/**
|
||||
* LIKE '值%',例如:WHERE `nickname` LIKE 's%'
|
||||
* LIKE '值%',例如:WHERE nickname LIKE 's%'
|
||||
*/
|
||||
LIKE_RIGHT,
|
||||
|
||||
/**
|
||||
* 包含查询,例如:WHERE `age` IN (10, 20, 30)
|
||||
* 包含查询,例如:WHERE age IN (10, 20, 30)
|
||||
*/
|
||||
IN,
|
||||
|
||||
/**
|
||||
* 不包含查询,例如:WHERE `age` NOT IN (20, 30)
|
||||
* 不包含查询,例如:WHERE age NOT IN (20, 30)
|
||||
*/
|
||||
NOT_IN,
|
||||
|
||||
/**
|
||||
* 空查询,例如:WHERE `email` IS NULL
|
||||
* 空查询,例如:WHERE email IS NULL
|
||||
*/
|
||||
IS_NULL,
|
||||
|
||||
/**
|
||||
* 非空查询,例如:WHERE `email` IS NOT NULL
|
||||
* 非空查询,例如:WHERE email IS NOT NULL
|
||||
*/
|
||||
IS_NOT_NULL,;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.charles7c.continew.starter.data.core.function;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* SQL 函数接口
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public interface ISqlFunction {
|
||||
|
||||
/**
|
||||
* find_in_set 函数
|
||||
*
|
||||
* @param value 值
|
||||
* @param set 集合
|
||||
* @return 函数实现
|
||||
*/
|
||||
String findInSet(Serializable value, String set);
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.extension.crud.service;
|
||||
package top.charles7c.continew.starter.data.core.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.core.util.db;
|
||||
package top.charles7c.continew.starter.data.core.util;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
@@ -22,8 +22,12 @@ import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import cn.hutool.db.meta.Column;
|
||||
import cn.hutool.db.meta.MetaUtil;
|
||||
import top.charles7c.continew.starter.core.exception.BusinessException;
|
||||
import top.charles7c.continew.starter.data.core.enums.DatabaseType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -40,6 +44,36 @@ public class MetaUtils {
|
||||
private MetaUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型(如果获取不到数据库类型,则返回默认数据库类型)
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @param defaultValue 默认数据库类型
|
||||
* @return 数据库类型
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public static DatabaseType getDatabaseTypeOrDefault(DataSource dataSource, DatabaseType defaultValue) {
|
||||
DatabaseType databaseType = getDatabaseType(dataSource);
|
||||
return null == databaseType ? defaultValue : databaseType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型
|
||||
*
|
||||
* @param dataSource 数据源
|
||||
* @return 数据库类型
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public static DatabaseType getDatabaseType(DataSource dataSource) {
|
||||
try (Connection conn = dataSource.getConnection()) {
|
||||
DatabaseMetaData metaData = conn.getMetaData();
|
||||
String databaseProductName = metaData.getDatabaseProductName();
|
||||
return DatabaseType.get(databaseProductName);
|
||||
} catch (SQLException e) {
|
||||
throw new BusinessException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有表信息
|
||||
*
|
||||
@@ -62,7 +96,7 @@ public class MetaUtils {
|
||||
List<Entity> tableEntityList;
|
||||
Db db = Db.use(dataSource);
|
||||
if (CharSequenceUtil.isNotBlank(tableName)) {
|
||||
tableEntityList = db.query(String.format("%s WHERE NAME = ?", querySql), tableName);
|
||||
tableEntityList = db.query("%s WHERE NAME = ?".formatted(querySql), tableName);
|
||||
} else {
|
||||
tableEntityList = db.query(querySql);
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.core.util.db;
|
||||
package top.charles7c.continew.starter.data.core.util;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
@@ -31,6 +31,12 @@
|
||||
<artifactId>p6spy</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- CosId(通用、灵活、高性能的分布式 ID 生成器) -->
|
||||
<dependency>
|
||||
<groupId>me.ahoo.cosid</groupId>
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
case DEPT -> expression = this.buildDeptExpression(dataPermission, currentUser, expression);
|
||||
case SELF -> expression = this.buildSelfExpression(dataPermission, currentUser, expression);
|
||||
case CUSTOM -> expression = this.buildCustomExpression(dataPermission, role, expression);
|
||||
default -> throw new IllegalArgumentException(String.format("暂不支持 [%s] 数据权限", dataScope));
|
||||
default -> throw new IllegalArgumentException("暂不支持 [%s] 数据权限".formatted(dataScope));
|
||||
}
|
||||
}
|
||||
return null != where ? new AndExpression(where, new Parenthesis(expression)) : expression;
|
||||
@@ -112,8 +112,8 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
* 构建本部门及以下数据权限表达式
|
||||
*
|
||||
* <p>
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.`dept_id` in (select `id` from `sys_dept` where `id` =
|
||||
* xxx or find_in_set(xxx, `ancestors`));
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.dept_id in (select id from sys_dept where id =
|
||||
* xxx or find_in_set(xxx, ancestors));
|
||||
* </p>
|
||||
*
|
||||
* @param dataPermission 数据权限
|
||||
@@ -147,7 +147,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
* 构建本部门数据权限表达式
|
||||
*
|
||||
* <p>
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.`dept_id` = xxx;
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.dept_id = xxx;
|
||||
* </p>
|
||||
*
|
||||
* @param dataPermission 数据权限
|
||||
@@ -168,7 +168,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
* 构建仅本人数据权限表达式
|
||||
*
|
||||
* <p>
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.`create_user` = xxx;
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.create_user = xxx;
|
||||
* </p>
|
||||
*
|
||||
* @param dataPermission 数据权限
|
||||
@@ -190,8 +190,8 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
* 构建自定义数据权限表达式
|
||||
*
|
||||
* <p>
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.`dept_id` in (select `dept_id` from `sys_role_dept`
|
||||
* where `role_id` = xxx);
|
||||
* 处理完后的 SQL 示例:<br /> select t1.* from table as t1 where t1.dept_id in (select dept_id from sys_role_dept
|
||||
* where role_id = xxx);
|
||||
* </p>
|
||||
*
|
||||
* @param dataPermission 数据权限
|
||||
@@ -227,7 +227,7 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler {
|
||||
*/
|
||||
private Column buildColumn(String tableAlias, String columnName) {
|
||||
if (StringUtils.isNotEmpty(tableAlias)) {
|
||||
return new Column(String.format("%s.%s", tableAlias, columnName));
|
||||
return new Column("%s.%s".formatted(tableAlias, columnName));
|
||||
}
|
||||
return new Column(columnName);
|
||||
}
|
||||
|
||||
@@ -26,9 +26,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import top.charles7c.continew.starter.core.exception.BadRequestException;
|
||||
import top.charles7c.continew.starter.core.util.ReflectUtils;
|
||||
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
|
||||
import top.charles7c.continew.starter.data.core.annotation.Query;
|
||||
import top.charles7c.continew.starter.data.core.annotation.QueryIgnore;
|
||||
import top.charles7c.continew.starter.data.core.enums.QueryType;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@@ -174,15 +178,15 @@ public class QueryWrapperHelper {
|
||||
case LIKE_RIGHT -> consumers.add(q -> q.likeRight(columnName, fieldValue));
|
||||
case IN -> {
|
||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", columnName);
|
||||
consumers.add(q -> q.in(columnName, (List<Object>)fieldValue));
|
||||
consumers.add(q -> q.in(columnName, (Collection<Object>)fieldValue));
|
||||
}
|
||||
case NOT_IN -> {
|
||||
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", columnName);
|
||||
consumers.add(q -> q.notIn(columnName, (List<Object>)fieldValue));
|
||||
consumers.add(q -> q.notIn(columnName, (Collection<Object>)fieldValue));
|
||||
}
|
||||
case IS_NULL -> consumers.add(q -> q.isNull(columnName));
|
||||
case IS_NOT_NULL -> consumers.add(q -> q.isNotNull(columnName));
|
||||
default -> throw new IllegalArgumentException(String.format("暂不支持 [%s] 查询类型", queryType));
|
||||
default -> throw new IllegalArgumentException("暂不支持 [%s] 查询类型".formatted(queryType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<description>ContiNew Starter 数据访问模块</description>
|
||||
|
||||
<modules>
|
||||
<module>continew-starter-data-core</module>
|
||||
<module>continew-starter-data-mybatis-plus</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- 项目版本号 -->
|
||||
<revision>1.4.0</revision>
|
||||
<revision>1.4.1</revision>
|
||||
<sa-token.version>1.37.0</sa-token.version>
|
||||
<just-auth.version>1.16.6</just-auth.version>
|
||||
<mybatis-plus.version>3.5.5</mybatis-plus.version>
|
||||
@@ -321,6 +321,13 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据访问模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-data-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 缓存模块 - JetCache -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
@@ -391,10 +398,10 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 日志模块 - 公共模块 -->
|
||||
<!-- 日志模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-log-common</artifactId>
|
||||
<artifactId>continew-starter-log-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -186,6 +186,6 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
|
||||
String path = crudRequestMapping.value();
|
||||
String permissionPrefix = String.join(StringConstants.COLON, CharSequenceUtil
|
||||
.splitTrim(path, StringConstants.SLASH));
|
||||
StpUtil.checkPermission(String.format("%s:%s", permissionPrefix, api.name().toLowerCase()));
|
||||
StpUtil.checkPermission("%s:%s".formatted(permissionPrefix, api.name().toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import top.charles7c.continew.starter.data.mybatis.plus.query.QueryWrapperHelper
|
||||
import top.charles7c.continew.starter.extension.crud.annotation.TreeField;
|
||||
import top.charles7c.continew.starter.extension.crud.model.entity.BaseDO;
|
||||
import top.charles7c.continew.starter.extension.crud.model.req.BaseReq;
|
||||
import top.charles7c.continew.starter.extension.crud.service.IService;
|
||||
import top.charles7c.continew.starter.data.core.service.IService;
|
||||
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
|
||||
import top.charles7c.continew.starter.extension.crud.model.query.SortQuery;
|
||||
import top.charles7c.continew.starter.extension.crud.model.resp.PageResp;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ExcelUtils {
|
||||
Class<T> clazz,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
String exportFileName = URLUtil.encode(String.format("%s_%s.xlsx", fileName, DateUtil
|
||||
String exportFileName = URLUtil.encode("%s_%s.xlsx".formatted(fileName, DateUtil
|
||||
.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");
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-log-common</artifactId>
|
||||
<description>ContiNew Starter 日志模块 - 公共模块</description>
|
||||
<artifactId>continew-starter-log-core</artifactId>
|
||||
<description>ContiNew Starter 日志模块 - 核心模块</description>
|
||||
</project>
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.annotation;
|
||||
package top.charles7c.continew.starter.log.core.annotation;
|
||||
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.dao;
|
||||
package top.charles7c.continew.starter.log.core.dao;
|
||||
|
||||
import top.charles7c.continew.starter.log.common.model.LogRecord;
|
||||
import top.charles7c.continew.starter.log.core.model.LogRecord;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.dao.impl;
|
||||
package top.charles7c.continew.starter.log.core.dao.impl;
|
||||
|
||||
import top.charles7c.continew.starter.log.common.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.common.model.LogRecord;
|
||||
import top.charles7c.continew.starter.log.core.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.core.model.LogRecord;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.enums;
|
||||
package top.charles7c.continew.starter.log.core.enums;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
package top.charles7c.continew.starter.log.core.model;
|
||||
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
package top.charles7c.continew.starter.log.core.model;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import top.charles7c.continew.starter.core.util.IpUtils;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
import top.charles7c.continew.starter.web.util.ServletUtils;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
package top.charles7c.continew.starter.log.core.model;
|
||||
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
package top.charles7c.continew.starter.log.core.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.charles7c.continew.starter.log.common.model;
|
||||
package top.charles7c.continew.starter.log.core.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
<artifactId>transmittable-thread-local</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 日志模块 - 公共模块 -->
|
||||
<!-- 日志模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-log-common</artifactId>
|
||||
<artifactId>continew-starter-log-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -26,8 +26,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import top.charles7c.continew.starter.log.common.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.common.dao.impl.LogDaoDefaultImpl;
|
||||
import top.charles7c.continew.starter.log.core.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.core.dao.impl.LogDaoDefaultImpl;
|
||||
import top.charles7c.continew.starter.log.httptracepro.handler.LogFilter;
|
||||
import top.charles7c.continew.starter.log.httptracepro.handler.LogInterceptor;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package top.charles7c.continew.starter.log.httptracepro.autoconfigure;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
import top.charles7c.continew.starter.log.httptracepro.autoconfigure.LogProperties;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -30,11 +30,11 @@ import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import top.charles7c.continew.starter.log.common.annotation.Log;
|
||||
import top.charles7c.continew.starter.log.common.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.common.enums.Include;
|
||||
import top.charles7c.continew.starter.log.common.model.LogRecord;
|
||||
import top.charles7c.continew.starter.log.common.model.LogResponse;
|
||||
import top.charles7c.continew.starter.log.core.annotation.Log;
|
||||
import top.charles7c.continew.starter.log.core.dao.LogDao;
|
||||
import top.charles7c.continew.starter.log.core.enums.Include;
|
||||
import top.charles7c.continew.starter.log.core.model.LogRecord;
|
||||
import top.charles7c.continew.starter.log.core.model.LogResponse;
|
||||
import top.charles7c.continew.starter.log.httptracepro.autoconfigure.LogProperties;
|
||||
|
||||
import java.time.Clock;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.log.common.model.RecordableHttpRequest;
|
||||
import top.charles7c.continew.starter.log.core.model.RecordableHttpRequest;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
@@ -23,7 +23,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.log.common.model.RecordableHttpResponse;
|
||||
import top.charles7c.continew.starter.log.core.model.RecordableHttpResponse;
|
||||
import top.charles7c.continew.starter.web.util.ServletUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<description>ContiNew Starter 日志模块</description>
|
||||
|
||||
<modules>
|
||||
<module>continew-starter-log-common</module>
|
||||
<module>continew-starter-log-core</module>
|
||||
<module>continew-starter-log-httptrace-pro</module>
|
||||
</modules>
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package top.charles7c.continew.starter.security.crypto.encryptor;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
||||
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
@@ -37,7 +37,7 @@ public abstract class AbstractSymmetricCryptoEncryptor implements IEncryptor {
|
||||
|
||||
@Override
|
||||
public String encrypt(String plaintext, String password, String publicKey) throws Exception {
|
||||
if (StrUtil.isBlank(plaintext)) {
|
||||
if (CharSequenceUtil.isBlank(plaintext)) {
|
||||
return plaintext;
|
||||
}
|
||||
return this.getCrypto(password).encryptHex(plaintext);
|
||||
@@ -45,7 +45,7 @@ public abstract class AbstractSymmetricCryptoEncryptor implements IEncryptor {
|
||||
|
||||
@Override
|
||||
public String decrypt(String ciphertext, String password, String privateKey) throws Exception {
|
||||
if (StrUtil.isBlank(ciphertext)) {
|
||||
if (CharSequenceUtil.isBlank(ciphertext)) {
|
||||
return ciphertext;
|
||||
}
|
||||
return this.getCrypto(password).decryptStr(ciphertext);
|
||||
|
||||
@@ -58,11 +58,11 @@ public class LocalStorageAutoConfiguration implements WebMvcConfigurer {
|
||||
String pathPattern = mapping.getPathPattern();
|
||||
String location = mapping.getLocation();
|
||||
if (CharSequenceUtil.isBlank(location)) {
|
||||
throw new IllegalArgumentException(String.format("Path pattern [%s] location is null.", pathPattern));
|
||||
throw new IllegalArgumentException("Path pattern [%s] location is null.".formatted(pathPattern));
|
||||
}
|
||||
registry.addResourceHandler(CharSequenceUtil.appendIfMissing(pathPattern, StringConstants.PATH_PATTERN))
|
||||
.addResourceLocations(!location.startsWith("file:")
|
||||
? String.format("file:%s", this.format(location))
|
||||
? "file:%s".formatted(this.format(location))
|
||||
: this.format(location))
|
||||
.setCachePeriod(0);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class GlobalExceptionHandler {
|
||||
public R<Void> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e, HttpServletRequest request) {
|
||||
log.warn("请求地址 [{}],上传文件失败,文件大小超过限制。", request.getRequestURI(), e);
|
||||
String sizeLimit = CharSequenceUtil.subBetween(e.getMessage(), "The maximum size ", " for");
|
||||
String errorMsg = String.format("请上传小于 %sMB 的文件", NumberUtil.parseLong(sizeLimit) / 1024 / 1024);
|
||||
String errorMsg = "请上传小于 %sMB 的文件".formatted(NumberUtil.parseLong(sizeLimit) / 1024 / 1024);
|
||||
return R.fail(HttpStatus.BAD_REQUEST.value(), errorMsg);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ public class FileUploadUtils {
|
||||
|
||||
String fileName;
|
||||
if (isKeepOriginalFilename) {
|
||||
fileName = String.format("%s-%s.%s", FileNameUtil.getPrefix(originalFilename), DateUtil.format(LocalDateTime
|
||||
fileName = "%s-%s.%s".formatted(FileNameUtil.getPrefix(originalFilename), DateUtil.format(LocalDateTime
|
||||
.now(), DatePattern.PURE_DATETIME_MS_PATTERN), extensionName);
|
||||
} else {
|
||||
fileName = String.format("%s.%s", IdUtil.fastSimpleUUID(), extensionName);
|
||||
fileName = "%s.%s".formatted(IdUtil.fastSimpleUUID(), extensionName);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user