|
|
|
@ -222,6 +222,8 @@ public class CoreBaseService<T> {
|
|
|
|
|
*/
|
|
|
|
|
public boolean deleteByCondition(T condition) {
|
|
|
|
|
|
|
|
|
|
if (condition == null) { return false; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 忽略的字段, 考虑到正则的关键字
|
|
|
|
|
*/
|
|
|
|
@ -240,18 +242,26 @@ public class CoreBaseService<T> {
|
|
|
|
|
log.debug("生成的正则:{}", regex);
|
|
|
|
|
|
|
|
|
|
// 构建LambdaQuery
|
|
|
|
|
LambdaQuery<T> tLambdaQuery = sqlManager.lambdaQuery(getCurrentEntityClassz());
|
|
|
|
|
Class<T> currentEntityClass = getCurrentEntityClassz();
|
|
|
|
|
LambdaQuery<T> tLambdaQuery = sqlManager.lambdaQuery(currentEntityClass);
|
|
|
|
|
|
|
|
|
|
// 实体类属性转Map
|
|
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(condition);
|
|
|
|
|
|
|
|
|
|
// 是否继承TailBean类, 再次获取TailBean里面的Map值
|
|
|
|
|
if (condition instanceof TailBean) {
|
|
|
|
|
Map<String, Object> tails = ReflectUtil.invoke(condition, "getTails");
|
|
|
|
|
stringObjectMap.putAll(tails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 移除空值或者忽略字段
|
|
|
|
|
for (String k : stringObjectMap.keySet()) {
|
|
|
|
|
Object obj = stringObjectMap.get(k);
|
|
|
|
|
/**
|
|
|
|
|
* 根据类型判断是否为空
|
|
|
|
|
* 根据类型判断是否为空, 移除非String类型的值,在忽略列表中的值
|
|
|
|
|
* 查看支持哪些类型 {@link cn.hutool.core.util.ObjectUtil#isEmpty}
|
|
|
|
|
*/
|
|
|
|
|
if (ObjectUtil.isEmpty(stringObjectMap.get(k)) || ReUtil.isMatch(regex, k)) {
|
|
|
|
|
if (!(obj instanceof String) || ObjectUtil.isEmpty(obj) || ReUtil.isMatch(regex, k)) {
|
|
|
|
|
stringObjectMap.remove(k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|