refactor: 优化字符串模板方法 API 使用

This commit is contained in:
2024-02-18 22:44:06 +08:00
parent 89108ad55a
commit c9867844b6
12 changed files with 16 additions and 16 deletions

View File

@@ -62,7 +62,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);
}

View File

@@ -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);
}