mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-09 20:57:21 +08:00
style: 使用常量优化部分魔法值
This commit is contained in:
@@ -45,6 +45,11 @@ public class StringConsts implements StrPool {
|
||||
*/
|
||||
public static final String ASTERISK = "*";
|
||||
|
||||
/**
|
||||
* 问号
|
||||
*/
|
||||
public static final String QUESTION_MARK = "?";
|
||||
|
||||
/**
|
||||
* 中文逗号
|
||||
*/
|
||||
|
@@ -25,6 +25,8 @@ import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import top.charles7c.cnadmin.common.constant.StringConsts;
|
||||
|
||||
/**
|
||||
* 异常工具类
|
||||
*
|
||||
@@ -99,7 +101,7 @@ public class ExceptionUtils {
|
||||
* @return /
|
||||
*/
|
||||
public static String exToBlank(ExSupplier<String> exSupplier) {
|
||||
return exToDefault(exSupplier, "");
|
||||
return exToDefault(exSupplier, StringConsts.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import top.charles7c.cnadmin.common.constant.StringConsts;
|
||||
import top.charles7c.cnadmin.common.exception.ServiceException;
|
||||
|
||||
/**
|
||||
@@ -52,8 +53,8 @@ public class CheckUtils extends Validator {
|
||||
* 字段值
|
||||
*/
|
||||
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
|
||||
String message =
|
||||
String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil.replace(entityName, "DO", ""));
|
||||
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue,
|
||||
StrUtil.replace(entityName, "DO", StringConsts.EMPTY));
|
||||
throwIfNull(obj, message, EXCEPTION_TYPE);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user