1
This commit is contained in:
parent
95415e84d2
commit
33de2cbc7b
@ -48,12 +48,10 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
|||||||
if (!StringUtils.isEmpty(category.getCatgName())) {
|
if (!StringUtils.isEmpty(category.getCatgName())) {
|
||||||
lambdaQueryWrapper.like(BusiCategory::getCatgName, category.getCatgName());
|
lambdaQueryWrapper.like(BusiCategory::getCatgName, category.getCatgName());
|
||||||
}
|
}
|
||||||
lambdaQueryWrapper.orderByAsc(BusiCategory::getSort);
|
lambdaQueryWrapper.orderByDesc(BusiCategory::getSort);
|
||||||
List<BusiCategory> list = list(lambdaQueryWrapper);
|
List<BusiCategory> list = list(lambdaQueryWrapper);
|
||||||
List<BusiCategoryVO> rtnList = buildCategoryTree(list);
|
List<BusiCategoryVO> rtnList = buildCategoryTree(list);
|
||||||
return rtnList.stream().sorted(Comparator.comparing(BusiCategoryVO::getSort,
|
return rtnList;
|
||||||
Comparator.nullsLast(Comparator.reverseOrder())))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,12 +150,10 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成树结构
|
* 生成树结构(修改版)
|
||||||
*
|
*
|
||||||
* @param list 网站栏目列表
|
* @param list 网站栏目列表
|
||||||
* @return java.util.List<com.ruoyi.busi.vo.BusiCategoryVO>
|
* @return java.util.List<com.ruoyi.busi.vo.BusiCategoryVO>
|
||||||
* @author PQZ
|
|
||||||
* @date 14:11 2025/6/23
|
|
||||||
**/
|
**/
|
||||||
private List<BusiCategoryVO> buildCategoryTree(List<BusiCategory> list) {
|
private List<BusiCategoryVO> buildCategoryTree(List<BusiCategory> list) {
|
||||||
// Map存放id到VO的映射
|
// Map存放id到VO的映射
|
||||||
@ -183,9 +179,36 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
|||||||
parent.getChildren().add(node);
|
parent.getChildren().add(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 对所有层级节点进行排序
|
||||||
|
sortTreeNodes(roots);
|
||||||
|
|
||||||
return roots;
|
return roots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归对树节点进行排序
|
||||||
|
*
|
||||||
|
* @param nodes 节点列表
|
||||||
|
*/
|
||||||
|
private void sortTreeNodes(List<BusiCategoryVO> nodes) {
|
||||||
|
if (nodes == null || nodes.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对当前层级节点排序
|
||||||
|
nodes.sort(Comparator.comparing(BusiCategoryVO::getSort,
|
||||||
|
Comparator.nullsLast(Comparator.reverseOrder())));
|
||||||
|
|
||||||
|
// 递归对子节点排序
|
||||||
|
for (BusiCategoryVO node : nodes) {
|
||||||
|
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
|
||||||
|
sortTreeNodes(node.getChildren());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id 查询的栏目ID
|
* @param id 查询的栏目ID
|
||||||
* @return java.util.List<java.lang.String>
|
* @return java.util.List<java.lang.String>
|
||||||
@ -229,10 +252,11 @@ public class BusiCategoryServiceImpl extends ServiceImpl<BusiCategoryMapper, Bus
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 给所有子级设置最父级ID并且反回map格式
|
* 给所有子级设置最父级ID并且反回map格式
|
||||||
* @author vinjor-M
|
*
|
||||||
* @date 11:23 2025/7/19
|
|
||||||
* @param busiCategoryVOList 栏目树
|
* @param busiCategoryVOList 栏目树
|
||||||
* @return java.util.List<com.ruoyi.busi.vo.BusiCategoryVO>
|
* @return java.util.List<com.ruoyi.busi.vo.BusiCategoryVO>
|
||||||
|
* @author vinjor-M
|
||||||
|
* @date 11:23 2025/7/19
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> dealFirstIdRtnMap(List<BusiCategoryVO> busiCategoryVOList) {
|
public Map<String, String> dealFirstIdRtnMap(List<BusiCategoryVO> busiCategoryVOList) {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
select id, tenant_id from dl_busi_keyword
|
select id, tenant_id from dl_busi_keyword
|
||||||
</sql>
|
</sql>
|
||||||
<delete id="deleteByIdAndTenantId">
|
<delete id="deleteByIdAndTenantId">
|
||||||
DELETE dl_busi_keyword WHERE id =#{id} AND tenant_id=#{tenantId}
|
DELETE FROM dl_busi_keyword WHERE id =#{id} AND tenant_id=#{tenantId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="queryListPage" parameterType="BusiKeyword" resultMap="BusiKeywordResult">
|
<select id="queryListPage" parameterType="BusiKeyword" resultMap="BusiKeywordResult">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user