mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-10 20:57:18 +08:00
refactor: 优化字符串模板方法 API 使用
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user