From 5e3f71065b2a49397a3378d39d060f8ffee6a642 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Fri, 19 Jul 2024 01:40:12 +0800
Subject: [PATCH 1/8] =?UTF-8?q?fix(bugs):=20=E4=BF=AE=E5=A4=8D=E4=BA=86?=
=?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=B7=B2=E7=9F=A5=E7=9A=84BUG?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index c661cac..2c56b54 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
-Gitee / GitHub / CHANGELOG / Maven
+GitHub / Gitee / CHANGELOG / Maven
## 📖 这是个什么项目
@@ -29,12 +29,12 @@
通过我们提供的 ```AirPower宿主仓库``` 项目来完成 **AirPower** 宿主项目的初始化:
AirPowerJavaStarter
-via [Gitee](https://gitee.com/air-power/AirPowerJavaStarter/blob/main/README.md) / [GitHub](https://github.com/HammCn/AirPowerJavaStarter/blob/main/README.md)
+via [GitHub](https://github.com/HammCn/AirPowerJavaStarter/blob/main/README.md) / [Gitee](https://gitee.com/air-power/AirPowerJavaStarter/blob/main/README.md)
## 🛎 问题反馈与建议
如果你有什么疑问或者问题,你也可以加入开发者交流QQ群(```555156313```)
-进行咨询,当然,我们更建议你发起 [Gitee issue](https://gitee.com/air-power/AirPower4J/issues/new) / [Github issue](https://github.com/HammCn/AirPower4J/issues/new)
+进行咨询,当然,我们更建议你发起 [Github issue](https://github.com/HammCn/AirPower4J/issues/new) / [Gitee issue](https://gitee.com/air-power/AirPower4J/issues/new)
## ⏰ Enjoy it
--
Gitee
From 8142aaa310822fefe3e0bf03269955acd9ae6b81 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Sat, 20 Jul 2024 16:17:20 +0800
Subject: [PATCH 2/8] =?UTF-8?q?fix(RootModel):=20=E4=BC=98=E5=8C=96`reflec?=
=?UTF-8?q?tUtil`=E7=9A=84=E5=BC=95=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
.../src/main/java/cn/hamm/airpower/root/RootModel.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java
index 3dde88a..0523004 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootModel.java
@@ -48,9 +48,9 @@ public class RootModel> implements IAction {
* 忽略只读字段
*/
public final void ignoreReadOnlyFields() {
- Utils.getReflectUtil().getFieldList(this.getClass()).stream()
- .filter(field -> Objects.nonNull(Utils.getReflectUtil().getAnnotation(ReadOnly.class, field)))
- .forEach(field -> Utils.getReflectUtil().clearFieldValue(this, field));
+ reflectUtil.getFieldList(this.getClass()).stream()
+ .filter(field -> Objects.nonNull(reflectUtil.getAnnotation(ReadOnly.class, field)))
+ .forEach(field -> reflectUtil.clearFieldValue(this, field));
}
/**
--
Gitee
From 857d4fdf2da1cdc6decdca096626a24e4e77e183 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Sat, 20 Jul 2024 16:59:22 +0800
Subject: [PATCH 3/8] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0API=E6=96=87?=
=?UTF-8?q?=E6=A1=A3=E5=B9=B6=E4=BF=AE=E6=AD=A3=E6=B3=A8=E9=87=8A=E8=AF=AD?=
=?UTF-8?q?=E6=B3=95=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 更新了API文档中的路径和参数说明,提高了文档的准确性和可读性。
- 修正了源代码中的部分注释语法错误,确保代码注释的规范性和可用性。
- 对一些方法和类的描述进行了细化,补充了缺失的文档内容。
- 删除了无关的API文档和过时的注释,清理了代码库。
Signed-off-by: Hamm
---
.../airpower/annotation/ApiController.java | 2 +-
.../hamm/airpower/annotation/Desensitize.java | 2 +-
.../hamm/airpower/config/MessageConstant.java | 2 +-
.../hamm/airpower/config/ServiceConfig.java | 2 +-
.../hamm/airpower/datasource/DataSource.java | 3 +-
.../cache/RequestBodyCacheWrapper.java | 2 +-
.../hamm/airpower/interfaces/IException.java | 42 +++++++++----------
.../cn/hamm/airpower/open/OpenResponse.java | 3 +-
.../cn/hamm/airpower/root/RootService.java | 6 +++
.../cn/hamm/airpower/util/CollectionUtil.java | 2 +-
.../cn/hamm/airpower/util/CookieUtil.java | 4 +-
.../cn/hamm/airpower/util/DateTimeUtil.java | 2 +-
.../java/cn/hamm/airpower/util/HttpUtil.java | 12 +++---
.../cn/hamm/airpower/util/RandomUtil.java | 4 +-
.../java/cn/hamm/airpower/util/RedisUtil.java | 2 +-
.../java/cn/hamm/airpower/util/RsaUtil.java | 1 +
.../java/cn/hamm/airpower/util/TokenUtil.java | 4 +-
17 files changed, 52 insertions(+), 43 deletions(-)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/annotation/ApiController.java b/airpower-core/src/main/java/cn/hamm/airpower/annotation/ApiController.java
index 8a23b4b..3004cd7 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/annotation/ApiController.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/annotation/ApiController.java
@@ -19,7 +19,7 @@ import java.lang.annotation.*;
@RequestMapping
public @interface ApiController {
/**
- * Api的路径
+ * Api
的路径
*/
@AliasFor(annotation = RequestMapping.class, attribute = "path")
String value();
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/annotation/Desensitize.java b/airpower-core/src/main/java/cn/hamm/airpower/annotation/Desensitize.java
index 5dfd7bf..03ed10a 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/annotation/Desensitize.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/annotation/Desensitize.java
@@ -82,7 +82,7 @@ public @interface Desensitize {
ADDRESS(3, 0),
/**
- * IP地址(v4)
+ * IPv4
地址
*/
IP_V4(0, 0),
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/config/MessageConstant.java b/airpower-core/src/main/java/cn/hamm/airpower/config/MessageConstant.java
index 5601f37..5b2ca17 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/config/MessageConstant.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/config/MessageConstant.java
@@ -33,5 +33,5 @@ public class MessageConstant {
public static final String PARAM_INVALID_MAY_BE_NOT_JSON = "请求参数格式不正确,请检查是否接口支持的JSON";
public static final String REQUEST_METHOD_NOT_SUPPORTED = "%s 不被支持,请使用 %s 方法请求";
public static final String MESSAGE_AND_DESCRIPTION = "%s (%s)";
- public static final String ACCESS_DENIED = "你无权访问 " + MESSAGE_AND_DESCRIPTION;
+ public static final String ACCESS_DENIED = "你无权访问 %s (%s)";
}
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/config/ServiceConfig.java b/airpower-core/src/main/java/cn/hamm/airpower/config/ServiceConfig.java
index 674e7cf..2bda807 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/config/ServiceConfig.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/config/ServiceConfig.java
@@ -86,7 +86,7 @@ public class ServiceConfig {
/**
* 导出文件的目录
*
- * @apiNote 请{@code 不要}使用 {@code /} 结尾
+ * @apiNote 请 {@code 不要} 使用 {@code /} 结尾
*/
private String exportFilePath = "";
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/datasource/DataSource.java b/airpower-core/src/main/java/cn/hamm/airpower/datasource/DataSource.java
index cb65aab..5d453c4 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/datasource/DataSource.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/datasource/DataSource.java
@@ -13,7 +13,8 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class DataSource {
/**
- * 数据库名称(租户的key)
+ * 数据库名称
+ * 租户的 {@code key}
*/
private String database;
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/interceptor/cache/RequestBodyCacheWrapper.java b/airpower-core/src/main/java/cn/hamm/airpower/interceptor/cache/RequestBodyCacheWrapper.java
index 54e5637..060e110 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/interceptor/cache/RequestBodyCacheWrapper.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/interceptor/cache/RequestBodyCacheWrapper.java
@@ -55,7 +55,7 @@ public class RequestBodyCacheWrapper extends HttpServletRequestWrapper {
* @param inputStream 输入流
* @return 输入字节数组
*/
- private byte[] inputStreamToBytes(@NotNull InputStream inputStream) throws IOException {
+ private byte @NotNull [] inputStreamToBytes(@NotNull InputStream inputStream) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int read;
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/interfaces/IException.java b/airpower-core/src/main/java/cn/hamm/airpower/interfaces/IException.java
index 5fc629e..13af58d 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/interfaces/IException.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/interfaces/IException.java
@@ -64,7 +64,7 @@ public interface IException {
}
/**
- * 当满足条件时抛出异常
+ * 当 {@code 满足条件} 时抛出异常
*
* @param condition 条件
*/
@@ -73,7 +73,7 @@ public interface IException {
}
/**
- * 当满足条件时抛出异常
+ * 当 {@code 满足条件} 时抛出异常
*
* @param condition 条件
* @param message 返回信息
@@ -85,7 +85,7 @@ public interface IException {
}
/**
- * 当满足条件时抛出异常
+ * 当 {@code 满足条件} 时抛出异常
*
* @param condition 条件
* @param message 返回信息
@@ -98,7 +98,7 @@ public interface IException {
}
/**
- * 当为null时抛出异常
+ * 当为 {@code null} 时抛出异常
*
* @param obj 被验证的数据
*/
@@ -108,7 +108,7 @@ public interface IException {
}
/**
- * 当为null时抛出异常
+ * 当为 {@code null} 时抛出异常
*
* @param obj 被验证的数据
* @param message 返回信息
@@ -119,7 +119,7 @@ public interface IException {
}
/**
- * 当两者相同时抛出异常
+ * 当 {@code 两者相同} 时抛出异常
*
* @param obj1 被验证的数据
* @param obj2 被验证的数据
@@ -129,7 +129,7 @@ public interface IException {
}
/**
- * 当两者相同时抛出异常
+ * 当 {@code 两者相同} 时抛出异常
*
* @param obj1 被验证的数据
* @param obj2 被验证的数据
@@ -140,7 +140,7 @@ public interface IException {
}
/**
- * 当两个字符串相同时抛出异常
+ * 当 {@code 两个字符串相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -150,7 +150,7 @@ public interface IException {
}
/**
- * 当两个字符串相同时抛出异常
+ * 当 {@code 两个字符串相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -161,7 +161,7 @@ public interface IException {
}
/**
- * 当两个字符串忽略大小写相同时抛出异常
+ * 当 {@code 两个字符串忽略大小写相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -171,7 +171,7 @@ public interface IException {
}
/**
- * 当两个字符串忽略大小写相同时抛出异常
+ * 当 {@code 两个字符串忽略大小写相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -182,7 +182,7 @@ public interface IException {
}
/**
- * 当两者不相同时抛出异常
+ * 当 {@code 两者不相同} 时抛出异常
*
* @param obj1 被验证的数据
* @param obj2 被验证的数据
@@ -192,7 +192,7 @@ public interface IException {
}
/**
- * 当两者不相同时抛出异常
+ * 当 {@code 两者不相同} 时抛出异常
*
* @param obj1 被验证的数据
* @param obj2 被验证的数据
@@ -203,7 +203,7 @@ public interface IException {
}
/**
- * 当两个字符串不相同时抛出异常
+ * 当 {@code 两个字符串不相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -213,7 +213,7 @@ public interface IException {
}
/**
- * 当两个字符串不相同时抛出异常
+ * 当 {@code 两个字符串不相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -224,7 +224,7 @@ public interface IException {
}
/**
- * 当两个字符串忽略大小写还不相同时抛出异常
+ * 当 {@code 两个字符串忽略大小写还不相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -234,7 +234,7 @@ public interface IException {
}
/**
- * 当两个字符串忽略大小写还不相同时抛出异常
+ * 当 {@code 两个字符串忽略大小写还不相同} 时抛出异常
*
* @param str1 被验证的数据
* @param str2 被验证的数据
@@ -245,7 +245,7 @@ public interface IException {
}
/**
- * 当为null或空字符串时抛出异常
+ * 当为 {@code null或空字符串} 时抛出异常
*
* @param obj 被验证的数据
*/
@@ -254,7 +254,7 @@ public interface IException {
}
/**
- * 当为null或空字符串时抛出异常
+ * 当为 {@code null或空字符串} 时抛出异常
*
* @param obj 被验证的数据
* @param message 返回信息
@@ -264,7 +264,7 @@ public interface IException {
}
/**
- * 当不为null时抛出异常
+ * 当 {@code 不为null} 时抛出异常
*
* @param obj 被验证的数据
*/
@@ -273,7 +273,7 @@ public interface IException {
}
/**
- * 当不为null时抛出异常
+ * 当 {@code 不为null} 时抛出异常
*
* @param obj 被验证的数据
* @param message 返回信息
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/open/OpenResponse.java b/airpower-core/src/main/java/cn/hamm/airpower/open/OpenResponse.java
index 30ee5d9..f1df5b6 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/open/OpenResponse.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/open/OpenResponse.java
@@ -4,6 +4,7 @@ import cn.hamm.airpower.enums.ServiceError;
import cn.hamm.airpower.exception.ServiceException;
import cn.hamm.airpower.model.Json;
import cn.hamm.airpower.util.Utils;
+import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@@ -20,7 +21,7 @@ public class OpenResponse {
* @param data 数据
* @return 加密后的数据
*/
- public static String encodeResponse(A openApp, Object data) {
+ public static @Nullable String encodeResponse(A openApp, Object data) {
if (Objects.isNull(data)) {
// 数据负载为空 直接返回
return null;
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index dc9f61e..07d142f 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -74,16 +74,22 @@ public class RootService, R extends RootRepository> {
*/
@Autowired
protected R repository;
+
@Autowired
private ReflectUtil reflectUtil;
+
@Autowired
private TaskUtil taskUtil;
+
@Autowired
private RedisUtil redisUtil;
+
@Autowired
private RandomUtil randomUtil;
+
@Autowired
private DateTimeUtil dateTimeUtil;
+
@Autowired
private EntityManager entityManager;
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/CollectionUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/CollectionUtil.java
index 0676844..f0b1841 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/CollectionUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/CollectionUtil.java
@@ -13,7 +13,7 @@ import java.util.*;
@Component
public class CollectionUtil {
/**
- * 获取集合中的非 {@code null} 元素
+ * 获取集合中的 {@code 非null} 元素
*
* @param list 原始集合
* @param fieldClass 数据类型
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/CookieUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/CookieUtil.java
index 00fd1c5..b913449 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/CookieUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/CookieUtil.java
@@ -16,8 +16,8 @@ public class CookieUtil {
/**
* 获取一个 {@code Cookie}
*
- * @param key Key
- * @param value Value
+ * @param key {@code Cookie} 键
+ * @param value {@code Cookie} 值
* @return {@code Cookie}
* @see CookieConfig
*/
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/DateTimeUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/DateTimeUtil.java
index d2290d0..f96bbbc 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/DateTimeUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/DateTimeUtil.java
@@ -37,7 +37,7 @@ public class DateTimeUtil {
* @param formatter 格式化模板
* @return 格式化后的时间
*/
- public final @NotNull String format(long milliSecond, DateTimeFormatter formatter) {
+ public final @NotNull String format(long milliSecond, @NotNull DateTimeFormatter formatter) {
return format(milliSecond, formatter.getValue());
}
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/HttpUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/HttpUtil.java
index 75290d8..0dd68a2 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/HttpUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/HttpUtil.java
@@ -16,7 +16,7 @@ import java.time.Duration;
import java.util.*;
/**
- * HTTP请求工具类
+ * {@code HTTP} 请求工具类
*
* @author Hamm.cn
*/
@@ -29,7 +29,7 @@ public class HttpUtil {
private Map headers = new HashMap<>();
/**
- * Cookie
+ * {@code Cookie}
*/
private Map cookies = new HashMap<>();
@@ -61,8 +61,8 @@ public class HttpUtil {
/**
* 添加 {@code Cookie}
*
- * @param key Key
- * @param value Value
+ * @param key {@code Cookie} 键
+ * @param value {@code Cookie} 值
* @return {@code HttpUtil}
*/
@Contract("_, _ -> this")
@@ -161,8 +161,8 @@ public class HttpUtil {
/**
* 添加 {@code Header}
*
- * @param key Key
- * @param value Value
+ * @param key {@code Header} 键
+ * @param value {@code Header} 值
* @return {@code HttpUtil}
*/
@Contract("_, _ -> this")
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/RandomUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/RandomUtil.java
index 65a6881..b59eeac 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/RandomUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/RandomUtil.java
@@ -50,7 +50,7 @@ public class RandomUtil {
}
/**
- * 获取32位随机字节数组
+ * 获取 {@code 32} 位随机字节数组
*
* @return 随机字节数组
*/
@@ -59,7 +59,7 @@ public class RandomUtil {
}
/**
- * 获取32位随机字符串
+ * 获取 {@code 32} 位随机字符串
*
* @return 随机字符串
*/
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/RedisUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/RedisUtil.java
index 3fbf140..da79bf1 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/RedisUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/RedisUtil.java
@@ -245,7 +245,7 @@ public class RedisUtil {
}
/**
- * 发布到channel的消息
+ * 发布到 {@code channel} 的消息
*
* @param channel 频道
* @param message 消息
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
index c581b09..9b10f16 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/RsaUtil.java
@@ -30,6 +30,7 @@ public class RsaUtil {
* 加密算法 {@code KEY} 长度
*/
private final int CRYPT_KEY_SIZE = 2048;
+
/**
* 加密方式
*/
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/TokenUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/TokenUtil.java
index f49d4de..92ad2ee 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/TokenUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/TokenUtil.java
@@ -104,7 +104,7 @@ public class TokenUtil {
}
/**
- * 设置过期时间(毫秒)
+ * 设置过期时间 {@code 毫秒}
*
* @param millisecond 过期毫秒
* @return {@code TokenUtil}
@@ -188,7 +188,7 @@ public class TokenUtil {
private Map payloads = new HashMap<>();
/**
- * 过期时间(毫秒)
+ * 过期时间 {@code 毫秒}
*/
private long expireTimestamps = 0;
--
Gitee
From 8ccd16761d640257d9d455990a4ea6d3b973e3ad Mon Sep 17 00:00:00 2001
From: Hamm
Date: Sat, 20 Jul 2024 18:36:20 +0800
Subject: [PATCH 4/8] =?UTF-8?q?fix(Service):=20=E7=A7=BB=E9=99=A4=E4=B8=8D?=
=?UTF-8?q?=E5=BF=85=E8=A6=81=E6=B3=A8=E8=A7=A3'SuppressWarning("AlibabaSw?=
=?UTF-8?q?itchStatement")'?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
.../src/main/java/cn/hamm/airpower/root/RootService.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index 07d142f..0d5a99c 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -1100,7 +1100,6 @@ public class RootService, R extends RootRepository> {
* @param isEqual 是否强匹配
* @return 搜索条件
*/
- @SuppressWarnings("AlibabaSwitchStatement")
private @NotNull List getPredicateList(
@NotNull From, ?> root, @NotNull CriteriaBuilder builder, @NotNull Object search, boolean isEqual
) {
--
Gitee
From a6afd1b447d4de4ed6f542dc0429d7a8a901e9c3 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Sat, 20 Jul 2024 18:38:54 +0800
Subject: [PATCH 5/8] =?UTF-8?q?fix(Service):=20=E7=A7=BB=E9=99=A4=E4=B8=8D?=
=?UTF-8?q?=E5=BF=85=E8=A6=81=E6=B3=A8=E8=A7=A3'SuppressWarning("AlibabaSw?=
=?UTF-8?q?itchStatement")'?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
.../src/main/java/cn/hamm/airpower/root/RootService.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index 0d5a99c..5d9631a 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -61,14 +61,17 @@ public class RootService, R extends RootRepository> {
* 导出文件夹前缀
*/
private static final String EXPORT_DIR_PREFIX = "export_";
+
/**
* 导出文件前缀
*/
private static final String EXPORT_FILE_PREFIX = EXPORT_DIR_PREFIX + "file_";
+
/**
* 导出文件后缀
*/
private static final String EXPORT_FILE_CSV = ".csv";
+
/**
* 数据源
*/
--
Gitee
From 47ade47b9b0f0b77c844c342bf2ba09d973a2e41 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Sat, 20 Jul 2024 18:48:23 +0800
Subject: [PATCH 6/8] =?UTF-8?q?fix(Service):=20=E7=A7=BB=E9=99=A4=E4=B8=8D?=
=?UTF-8?q?=E5=BF=85=E8=A6=81=E6=B3=A8=E8=A7=A3'SuppressWarning("AlibabaSw?=
=?UTF-8?q?itchStatement")'?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
.../cn/hamm/airpower/root/RootService.java | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index 5d9631a..677a22e 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -558,7 +558,7 @@ public class RootService, R extends RootRepository> {
/**
* 添加搜索的查询条件
*
- * @param root ROOT
+ * @param root {@code ROOT}
* @param builder 参数构造器
* @param search 原始查询对象
* @return 查询条件列表
@@ -713,7 +713,7 @@ public class RootService, R extends RootRepository> {
/**
* 添加查询条件({@code value}不为{@code null}时)
*
- * @param root ROOT
+ * @param root {@code ROOT}
* @param predicateList 查询条件列表
* @param fieldName 所属的字段名称
* @param expression 表达式
@@ -731,9 +731,9 @@ public class RootService, R extends RootRepository> {
}
/**
- * 尝试获取当前登录用户ID
+ * 尝试获取当前登录用户 {@code ID}
*
- * @return 用户ID
+ * @return 用户 {@code ID}
*/
private long tryToGetCurrentUserId() {
try {
@@ -866,7 +866,7 @@ public class RootService, R extends RootRepository> {
*
* @param id 主键 {@code ID}
* @return 实体
- * @apiNote 查不到返回null,不抛异常
+ * @apiNote 查不到返回 {@code null},不抛异常
*/
private @Nullable E getByIdMaybeNull(long id) {
try {
@@ -1057,7 +1057,7 @@ public class RootService, R extends RootRepository> {
* 创建{@code Sort}
*
* @param sort 排序对象
- * @return Sort Spring的排序对象
+ * @return Sort {@code Spring} 的排序对象
*/
private @NotNull org.springframework.data.domain.Sort createSort(Sort sort) {
sort = Objects.requireNonNullElse(sort, new Sort());
@@ -1097,8 +1097,8 @@ public class RootService, R extends RootRepository> {
/**
* 获取查询条件列表
*
- * @param root root
- * @param builder builder
+ * @param root {@code root}
+ * @param builder {@code builder}
* @param search 搜索实体
* @param isEqual 是否强匹配
* @return 搜索条件
@@ -1146,7 +1146,7 @@ public class RootService, R extends RootRepository> {
/**
* 添加创建时间和更新时间的查询条件
*
- * @param root ROOT
+ * @param root {@code ROOT}
* @param builder 参数构造器
* @param search 原始查询对象
* @param predicateList 查询条件列表
@@ -1175,11 +1175,11 @@ public class RootService, R extends RootRepository> {
}
/**
- * 创建Predicate
+ * 创建 {@code Predicate}
*
- * @param root root
- * @param criteriaQuery query
- * @param builder builder
+ * @param root {@code root}
+ * @param criteriaQuery {@code query}
+ * @param builder {@code builder}
* @param filter 过滤器实体
* @return 查询条件
*/
--
Gitee
From 75473c7fdb770ac7cf7bd0f18dc2d833b0234d04 Mon Sep 17 00:00:00 2001
From: Hamm
Date: Fri, 2 Aug 2024 14:17:29 +0800
Subject: [PATCH 7/8] =?UTF-8?q?feat(reflect):=20=E5=8F=8D=E5=B0=84?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AD=97=E6=AE=B5=E5=88=97=E8=A1=A8=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=E4=BA=86=E7=BC=93=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
.../cn/hamm/airpower/root/RootService.java | 25 +++++++++++--
.../cn/hamm/airpower/util/ReflectUtil.java | 37 ++++++++++++++++++-
2 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
index 677a22e..5d7a951 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/root/RootService.java
@@ -1,5 +1,6 @@
package cn.hamm.airpower.root;
+import cn.hamm.airpower.annotation.Desensitize;
import cn.hamm.airpower.annotation.ExcelColumn;
import cn.hamm.airpower.annotation.Search;
import cn.hamm.airpower.config.Configs;
@@ -905,7 +906,7 @@ public class RootService, R extends RootRepository> {
// 如果数据库是null 且 传入的也是null 签名给空字符串
entity.setRemark(Constant.EMPTY_STRING);
}
- entity = withNull ? entity : getEntityForSave(entity, existEntity);
+ entity = withNull ? entity : getEntityForUpdate(entity, existEntity);
}
if (Objects.isNull(entity.getCreateUserId())) {
entity.setCreateUserId(tryToGetCurrentUserId());
@@ -925,7 +926,7 @@ public class RootService, R extends RootRepository> {
if (Objects.isNull(entity.getUpdateUserId())) {
entity.setUpdateUserId(tryToGetCurrentUserId());
}
- entity = withNull ? entity : getEntityForSave(entity, existEntity);
+ entity = withNull ? entity : getEntityForUpdate(entity, existEntity);
return saveAndFlush(entity);
}
@@ -954,9 +955,27 @@ public class RootService, R extends RootRepository> {
* @return 目标实体
*/
@Contract("_, _ -> param2")
- private @NotNull E getEntityForSave(@NotNull E sourceEntity, @NotNull E existEntity) {
+ private @NotNull E getEntityForUpdate(@NotNull E sourceEntity, @NotNull E existEntity) {
String[] nullProperties = getNullProperties(sourceEntity);
BeanUtils.copyProperties(sourceEntity, existEntity, nullProperties);
+ List fieldList = reflectUtil.getFieldList(getEntityClass());
+ for (Field field : fieldList) {
+ Desensitize desensitize = reflectUtil.getAnnotation(Desensitize.class, field);
+ if (Objects.isNull(desensitize)) {
+ // 非脱敏注解标记属性
+ continue;
+ }
+ // 脱敏字段
+ Object fieldValue = reflectUtil.getFieldValue(existEntity, field);
+ if (Objects.isNull(fieldValue)) {
+ // 值本身是空
+ continue;
+ }
+ if (fieldValue.toString().contains(desensitize.symbol())) {
+ // 如果值包含脱敏字符
+ reflectUtil.setFieldValue(existEntity, field, null);
+ }
+ }
return existEntity;
}
diff --git a/airpower-core/src/main/java/cn/hamm/airpower/util/ReflectUtil.java b/airpower-core/src/main/java/cn/hamm/airpower/util/ReflectUtil.java
index 7318a30..60b7e95 100644
--- a/airpower-core/src/main/java/cn/hamm/airpower/util/ReflectUtil.java
+++ b/airpower-core/src/main/java/cn/hamm/airpower/util/ReflectUtil.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
@@ -244,6 +245,17 @@ public class ReflectUtil {
return isModel(clazz.getSuperclass());
}
+ /**
+ * 缓存字段列表
+ */
+ private final static ConcurrentHashMap, List> FIELD_LIST_MAP = new ConcurrentHashMap<>();
+ /**
+ * 缓存属性列表
+ *
+ * @apiNote 声明属性列表
+ */
+ private final static ConcurrentHashMap DECLARED_FIELD_LIST_MAP = new ConcurrentHashMap<>();
+
/**
* 获取指定类的字段列表
*
@@ -251,11 +263,21 @@ public class ReflectUtil {
* @return 字段数组
*/
public final @NotNull List getFieldList(Class> clazz) {
+ return FIELD_LIST_MAP.computeIfAbsent(clazz, this::getCacheFieldList);
+ }
+
+ /**
+ * 获取指定类的字段列表
+ *
+ * @param clazz 类
+ * @return 字段数组
+ */
+ private @NotNull List getCacheFieldList(Class> clazz) {
List fieldList = new LinkedList<>();
if (Objects.isNull(clazz)) {
return fieldList;
}
- Field[] fields = clazz.getDeclaredFields();
+ Field[] fields = getDeclaredFields(clazz);
// 过滤静态属性 或 过滤transient 关键字修饰的属性
fieldList = Arrays.stream(fields)
.filter(field -> !Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers()))
@@ -269,6 +291,17 @@ public class ReflectUtil {
return fieldList;
}
+ /**
+ * 获取类的所有属性
+ *
+ * @param clazz 类
+ * @return 属性数组
+ */
+ @Contract(pure = true)
+ public final Field @NotNull [] getDeclaredFields(@NotNull Class> clazz) {
+ return DECLARED_FIELD_LIST_MAP.computeIfAbsent(clazz.getName(), key -> clazz.getDeclaredFields());
+ }
+
/**
* 获取类的所有公开属性名称列表
*
@@ -276,7 +309,7 @@ public class ReflectUtil {
* @return 属性名数组
*/
public final @NotNull List getFieldNameList(@NotNull Class> clazz) {
- Field[] fields = clazz.getDeclaredFields();
+ Field[] fields = getDeclaredFields(clazz);
return Arrays.stream(fields)
.map(Field::getName)
.collect(Collectors.toList());
--
Gitee
From 97baf9c5a3b4a4e5b5cad5b812e20dbae90d3e1d Mon Sep 17 00:00:00 2001
From: Hamm
Date: Fri, 2 Aug 2024 14:51:37 +0800
Subject: [PATCH 8/8] =?UTF-8?q?release(v2.2.3):=20=E5=8F=91=E5=B8=83?=
=?UTF-8?q?=E4=BA=86`v2.2.3`=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Hamm
---
airpower-core/pom.xml | 4 ++--
pom.xml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/airpower-core/pom.xml b/airpower-core/pom.xml
index 550c1eb..0d4e53f 100644
--- a/airpower-core/pom.xml
+++ b/airpower-core/pom.xml
@@ -5,10 +5,10 @@
cn.hamm
airpower
- 2.2.2
+ 2.2.3
airpower-core
- 2.2.2
+ 2.2.3
airpower-core
AirPower is a fast backend development tool based on SpringBoot3 and JPA. It's the core of AirPower.
diff --git a/pom.xml b/pom.xml
index 9d0ccf1..4095db5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,11 +4,11 @@
4.0.0
cn.hamm
airpower
- 2.2.2
+ 2.2.3
airpower
AirPower is a fast backend development tool based on SpringBoot3 and JPA.
- 2.2.2
+ 2.2.3
UTF-8
UTF-8
UTF-8
--
Gitee