|
@@ -14,7 +14,6 @@ import java.util.stream.Collectors;
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.chelvc.framework.common.util.ObjectUtils;
|
|
|
import com.chelvc.framework.common.util.StringUtils;
|
|
|
import com.chelvc.framework.common.util.TreeUtils;
|
|
@@ -29,7 +28,7 @@ import lombok.NonNull;
|
|
|
* @date 2024/4/28
|
|
|
*/
|
|
|
public class DefaultTreeService<M extends BaseMapper<T>, T extends TreeEntity<? extends Serializable, T>>
|
|
|
- extends ServiceImpl<M, T> implements TreeService<T> {
|
|
|
+ extends DefaultEnhanceService<M, T> implements TreeService<T> {
|
|
|
/**
|
|
|
* 序号替换SQL
|
|
|
*/
|
|
@@ -154,13 +153,9 @@ public class DefaultTreeService<M extends BaseMapper<T>, T extends TreeEntity<?
|
|
|
Set<String> sequences = nodes.stream().map(TreeEntity::getSequence).filter(StringUtils::notEmpty)
|
|
|
.collect(Collectors.toSet());
|
|
|
if (ObjectUtils.notEmpty(sequences)) {
|
|
|
- List<T> children = this.treeQuery().and(query -> {
|
|
|
- // 重置查询实体对象,否则使用实体对象父类或接口函数查询会出现异常
|
|
|
- query.setEntityClass(getEntityClass());
|
|
|
-
|
|
|
- // 设置多个Like或查询条件
|
|
|
- sequences.forEach(sequence -> query.or().likeRight(TreeEntity::getSequence, sequence));
|
|
|
- }).list();
|
|
|
+ List<T> children = this.treeQuery().and(query -> sequences.forEach(
|
|
|
+ sequence -> query.or().likeRight(TreeEntity::getSequence, sequence)
|
|
|
+ )).list();
|
|
|
nodes.addAll(children);
|
|
|
}
|
|
|
return nodes;
|