add destroyAllByExample
This commit is contained in:
@@ -414,6 +414,25 @@ public abstract class BaseSQLProvider {
|
||||
return "DELETE FROM `%s` WHERE `%s` = #{%s}".formatted(tableName, meta.idFieldColumn.columnName, idParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建批量逻辑删除 SQL
|
||||
*
|
||||
* @param meta 实体元数据
|
||||
* @param tableName 表名
|
||||
* @param entity 示例实体
|
||||
* @param paramPrefix 参数前缀(如 "entity."),空字符串表示无前缀
|
||||
* @return SQL
|
||||
*/
|
||||
protected String buildDestroyAllByExampleSQL(EntityMeta meta, String tableName, Object entity, String paramPrefix) {
|
||||
TimiException.required(meta.canDestroy, "not allow destroy for %s".formatted(meta.entityClass));
|
||||
String destroyClause = meta.fieldColumnList.stream()
|
||||
.filter(FieldColumn::isNotId)
|
||||
.filter(fc -> fc.isNotEmpty(entity))
|
||||
.map(fc -> "`%s` = #{%s%s}".formatted(fc.columnName, paramPrefix, fc.fieldName))
|
||||
.collect(Collectors.joining(" AND "));
|
||||
return "DELETE FROM `%s` WHERE %s".formatted(tableName, destroyClause);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体元数据
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user