Skip to content

Commit c9c7c34

Browse files
committed
refactor: 优化部分错误提示信息和代码注释
1 parent a6fb65f commit c9c7c34

File tree

8 files changed

+26
-25
lines changed
  • continew-starter-core/src/main/java/top/continew/starter/core/validation
  • continew-starter-data
  • continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/model/query
  • continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/continew/starter/messaging/mail/core
  • continew-starter-storage/continew-starter-storage-oss/src/main/java/top/continew/starter/storage/strategy

8 files changed

+26
-25
lines changed

continew-starter-core/src/main/java/top/continew/starter/core/validation/Validator.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected Validator() {
4444
* 如果为空,抛出异常
4545
*
4646
* @param obj 被检测的对象
47-
* @param message 错误信息
47+
* @param message 提示信息
4848
* @param exceptionType 异常类型
4949
*/
5050
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
@@ -55,7 +55,7 @@ protected static void throwIfNull(Object obj, String message, Class<? extends Ru
5555
* 如果不为空,抛出异常
5656
*
5757
* @param obj 被检测的对象
58-
* @param message 错误信息
58+
* @param message 提示信息
5959
* @param exceptionType 异常类型
6060
*/
6161
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
@@ -66,7 +66,7 @@ protected static void throwIfNotNull(Object obj, String message, Class<? extends
6666
* 如果为空,抛出异常
6767
*
6868
* @param obj 被检测的对象
69-
* @param message 错误信息
69+
* @param message 提示信息
7070
* @param exceptionType 异常类型
7171
*/
7272
protected static void throwIfEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
@@ -77,7 +77,7 @@ protected static void throwIfEmpty(Object obj, String message, Class<? extends R
7777
* 如果不为空,抛出异常
7878
*
7979
* @param obj 被检测的对象
80-
* @param message 错误信息
80+
* @param message 提示信息
8181
* @param exceptionType 异常类型
8282
*/
8383
protected static void throwIfNotEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
@@ -88,7 +88,7 @@ protected static void throwIfNotEmpty(Object obj, String message, Class<? extend
8888
* 如果为空,抛出异常
8989
*
9090
* @param str 被检测的字符串
91-
* @param message 错误信息
91+
* @param message 提示信息
9292
* @param exceptionType 异常类型
9393
*/
9494
protected static void throwIfBlank(CharSequence str,
@@ -101,7 +101,7 @@ protected static void throwIfBlank(CharSequence str,
101101
* 如果不为空,抛出异常
102102
*
103103
* @param str 被检测的字符串
104-
* @param message 错误信息
104+
* @param message 提示信息
105105
* @param exceptionType 异常类型
106106
*/
107107
protected static void throwIfNotBlank(CharSequence str,
@@ -115,7 +115,7 @@ protected static void throwIfNotBlank(CharSequence str,
115115
*
116116
* @param obj1 要比较的对象1
117117
* @param obj2 要比较的对象2
118-
* @param message 错误信息
118+
* @param message 提示信息
119119
* @param exceptionType 异常类型
120120
*/
121121
protected static void throwIfEqual(Object obj1,
@@ -130,7 +130,7 @@ protected static void throwIfEqual(Object obj1,
130130
*
131131
* @param obj1 要比较的对象1
132132
* @param obj2 要比较的对象2
133-
* @param message 错误信息
133+
* @param message 提示信息
134134
* @param exceptionType 异常类型
135135
*/
136136
protected static void throwIfNotEqual(Object obj1,
@@ -145,7 +145,7 @@ protected static void throwIfNotEqual(Object obj1,
145145
*
146146
* @param str1 要比较的字符串1
147147
* @param str2 要比较的字符串2
148-
* @param message 错误信息
148+
* @param message 提示信息
149149
* @param exceptionType 异常类型
150150
*/
151151
protected static void throwIfEqualIgnoreCase(CharSequence str1,
@@ -160,7 +160,7 @@ protected static void throwIfEqualIgnoreCase(CharSequence str1,
160160
*
161161
* @param str1 要比较的字符串1
162162
* @param str2 要比较的字符串2
163-
* @param message 错误信息
163+
* @param message 提示信息
164164
* @param exceptionType 异常类型
165165
*/
166166
protected static void throwIfNotEqualIgnoreCase(CharSequence str1,
@@ -174,7 +174,7 @@ protected static void throwIfNotEqualIgnoreCase(CharSequence str1,
174174
* 如果条件成立,抛出异常
175175
*
176176
* @param condition 条件
177-
* @param message 错误信息
177+
* @param message 提示信息
178178
* @param exceptionType 异常类型
179179
*/
180180
protected static void throwIf(boolean condition, String message, Class<? extends RuntimeException> exceptionType) {

continew-starter-data/continew-starter-data-core/src/main/java/top/continew/starter/data/core/util/SqlInjectionUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private SqlInjectionUtils() {
6767
* 检查参数是否存在 SQL 注入
6868
*
6969
* @param value 检查参数
70-
* @return true:非法;false:合法
70+
* @return true:存在;false:不存在
7171
*/
7272
public static boolean check(String value) {
7373
return check(value, null);
@@ -78,7 +78,7 @@ public static boolean check(String value) {
7878
*
7979
* @param value 检查参数
8080
* @param customKeyword 自定义关键字
81-
* @return true:非法;false:合法
81+
* @return true:存在;false:不存在
8282
*/
8383
public static boolean check(String value, String customKeyword) {
8484
if (CharSequenceUtil.isBlank(value)) {
@@ -114,7 +114,7 @@ public static boolean check(String value, String customKeyword) {
114114
*
115115
* @param value 检查参数
116116
* @param keywords 关键字列表
117-
* @return true:非法;false:合法
117+
* @return true:存在;false:不存在
118118
*/
119119
private static boolean checkKeyword(String value, String[] keywords) {
120120
for (String keyword : keywords) {

continew-starter-data/continew-starter-data-mf/src/main/java/top/continew/starter/data/mf/util/QueryWrapperHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static <Q> QueryWrapper build(Q query, Sort sort) {
9292
if (sort != null && sort.isSorted()) {
9393
for (Sort.Order order : sort) {
9494
String field = CharSequenceUtil.toUnderlineCase(order.getProperty());
95-
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含非法字符");
95+
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含无效字符");
9696
queryWrapper.orderBy(field, order.isAscending());
9797
}
9898
}

continew-starter-data/continew-starter-data-mp/src/main/java/top/continew/starter/data/mp/util/QueryWrapperHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static <Q, R> QueryWrapper<R> build(Q query, Sort sort) {
104104
if (sort != null && sort.isSorted()) {
105105
for (Sort.Order order : sort) {
106106
String field = CharSequenceUtil.toUnderlineCase(order.getProperty());
107-
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含非法字符");
107+
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含无效字符");
108108
queryWrapper.orderBy(true, order.isAscending(), field);
109109
}
110110
}

continew-starter-extension/continew-starter-extension-crud/continew-starter-extension-crud-core/src/main/java/top/continew/starter/extension/crud/model/query/SortQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Sort getSort() {
5656
if (ArrayUtil.isEmpty(sort)) {
5757
return Sort.unsorted();
5858
}
59-
ValidationUtils.throwIf(sort.length < 2, "排序条件非法");
59+
ValidationUtils.throwIf(sort.length < 2, "排序条件无效");
6060
List<Sort.Order> orders = new ArrayList<>(sort.length);
6161
if (CharSequenceUtil.contains(sort[0], StringConstants.COMMA)) {
6262
// e.g "sort=createTime,desc&sort=name,asc"
@@ -83,7 +83,7 @@ public void setSort(String[] sort) {
8383
* @return 排序条件
8484
*/
8585
private Sort.Order getOrder(String field, String direction) {
86-
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含非法字符");
86+
ValidationUtils.throwIf(SqlInjectionUtils.check(field), "排序字段包含无效字符");
8787
return new Sort.Order(Sort.Direction.valueOf(direction.toUpperCase()), field);
8888
}
8989
}

continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/continew/starter/messaging/mail/core/MailConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public Properties toJavaMailProperties() {
174174
javaMailProperties.put("mail.smtp.auth", true);
175175
javaMailProperties.put("mail.smtp.ssl.enable", this.isSslEnabled());
176176
if (this.isSslEnabled()) {
177-
ValidationUtils.throwIfNull(this.getSslPort(), "邮件配置错误:SSL端口不能为空");
177+
ValidationUtils.throwIfNull(this.getSslPort(), "邮件配置不正确:SSL端口不能为空");
178178
javaMailProperties.put("mail.smtp.socketFactory.port", this.sslPort);
179179
javaMailProperties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
180180
}

continew-starter-messaging/continew-starter-messaging-mail/src/main/java/top/continew/starter/messaging/mail/core/MailConfigurer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ public interface MailConfigurer {
4242
*/
4343
default void apply(MailConfig mailConfig, JavaMailSenderImpl sender) {
4444
String protocolLowerCase = mailConfig.getProtocol().toLowerCase();
45-
ValidationUtils.throwIfNotEqual(MailConfig.DEFAULT_PROTOCOL, protocolLowerCase, "邮件配置错误:不支持的邮件发送协议: %s"
45+
ValidationUtils.throwIfNotEqual(MailConfig.DEFAULT_PROTOCOL, protocolLowerCase, "邮件配置不正确:不支持的邮件发送协议: %s"
4646
.formatted(mailConfig.getProtocol()));
4747
sender.setProtocol(mailConfig.getProtocol());
4848

49-
ValidationUtils.throwIfBlank(mailConfig.getHost(), "邮件配置错误:服务器地址不能为空");
49+
ValidationUtils.throwIfBlank(mailConfig.getHost(), "邮件配置不正确:服务器地址不能为空");
5050
sender.setHost(mailConfig.getHost());
5151

52-
ValidationUtils.throwIfNull(mailConfig.getPort(), "邮件配置错误:服务器端口不能为空");
52+
ValidationUtils.throwIfNull(mailConfig.getPort(), "邮件配置不正确:服务器端口不能为空");
5353
sender.setPort(mailConfig.getPort());
5454

55-
ValidationUtils.throwIfBlank(mailConfig.getUsername(), "邮件配置错误:用户名不能为空");
55+
ValidationUtils.throwIfBlank(mailConfig.getUsername(), "邮件配置不正确:用户名不能为空");
5656
sender.setUsername(mailConfig.getUsername());
5757

58-
ValidationUtils.throwIfBlank(mailConfig.getPassword(), "邮件配置错误:密码不能为空");
58+
ValidationUtils.throwIfBlank(mailConfig.getPassword(), "邮件配置不正确:密码不能为空");
5959
sender.setPassword(mailConfig.getPassword());
6060

6161
if (mailConfig.getDefaultEncoding() != null) {

continew-starter-storage/continew-starter-storage-oss/src/main/java/top/continew/starter/storage/strategy/OssStorageStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ private boolean isPrivate(String bucketName) {
374374
} catch (Exception e) {
375375
// 如果 getBucketAcl 失败,可能是权限或连接问题
376376
log.error("获取桶 ACL 失败: {}", e.getMessage());
377-
return true; // 出现错误时,默认认为桶是私有的
377+
// 出现错误时,默认认为桶是私有的
378+
return true;
378379
}
379380
}
380381

0 commit comments

Comments
 (0)