树形查询子节点优化

This commit is contained in:
cjw 2024-06-20 16:06:52 +08:00
parent 965ef50b86
commit c058749afd
1 changed files with 7 additions and 2 deletions

View File

@ -79,7 +79,8 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
private LambdaQueryWrapper<SysCatalogTextbook> buildQueryWrapper(SysCatalogTextbookBo bo) { private LambdaQueryWrapper<SysCatalogTextbook> buildQueryWrapper(SysCatalogTextbookBo bo) {
Map<String, Object> params = bo.getParams(); Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysCatalogTextbook> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<SysCatalogTextbook> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getParentId() != null, SysCatalogTextbook::getParentId, bo.getParentId()); //lqw.eq(bo.getParentId() != null, SysCatalogTextbook::getParentId, bo.getParentId());
lqw.like(bo.getParentId() != null, SysCatalogTextbook::getAncestors, bo.getParentId());
lqw.le(bo.getType() != null, SysCatalogTextbook::getType, bo.getType()); lqw.le(bo.getType() != null, SysCatalogTextbook::getType, bo.getType());
return lqw; return lqw;
} }
@ -96,7 +97,11 @@ public class SysCatalogTextbookServiceImpl implements ISysCatalogTextbookService
SysCatalogTextbook add = MapstructUtils.convert(bo, SysCatalogTextbook.class); SysCatalogTextbook add = MapstructUtils.convert(bo, SysCatalogTextbook.class);
add.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + add.getParentId()); add.setAncestors(info.getAncestors() + StringUtils.SEPARATOR + add.getParentId());
String[] split = StringUtils.split(add.getAncestors(), StringUtils.SEPARATOR); String[] split = StringUtils.split(add.getAncestors(), StringUtils.SEPARATOR);
add.setType(split.length); if (split.length < 7) {
add.setType(split.length);
} else {
add.setType(7);
}
return baseMapper.insert(add) > 0; return baseMapper.insert(add) > 0;
} }