增加标签路径集合接口

This commit is contained in:
2023-04-20 11:50:39 +08:00
parent a866bb5d28
commit a9ca68af08
4 changed files with 37 additions and 3 deletions
@@ -10,4 +10,6 @@ public class TreeLabelConstants {
public static final Integer UNDELETE = 0;
public static final String ROOT_TAG_PARENT_ID = "0";
public static final String ROOT_LABEL_ID = "RTYUHYT";
}
@@ -43,8 +43,19 @@ public class TreeLabelManagerController {
TreeLabelEntity treeLabelEntity = Convert.convert(TreeLabelEntity.class, treeLabelVo);
iTreeLabelService.saveOrUpdateTag(treeLabelEntity);
return Result.success();
}
/**
* 新增或编辑标签
*
* @param id
* @return
*/
@ApiOperation("获取当前标签的路径List")
@GetMapping("/labelList/{id}")
public ResponseMessage add(@PathVariable String id) {
List<String> labelList = iTreeLabelService.getLabelList(id);
return Result.success(labelList);
}
/**
@@ -43,4 +43,11 @@ public interface ITreeLabelService extends IService<TreeLabelEntity> {
*/
boolean deleteById(String id);
/**
* 获取当前标签的路径
*
* @param id
* @return
*/
List<String> getLabelList(String id);
}
@@ -130,8 +130,8 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
if (currentNum != maxNum) {
LambdaQueryWrapper<TreeLabelEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.gt(TreeLabelEntity::getOrderNum, currentNum)
.le(TreeLabelEntity::getOrderNum, maxNum)
.eq(TreeLabelEntity::getParentId, parentId);
.le(TreeLabelEntity::getOrderNum, maxNum)
.eq(TreeLabelEntity::getParentId, parentId);
List<TreeLabelEntity> labelList = treeLabelDao.selectList(wrapper);
for (TreeLabelEntity entity : labelList) {
entity.setOrderNum(entity.getOrderNum() - 1);
@@ -148,6 +148,20 @@ public class ITreeLabelServiceImpl extends ServiceImpl<TreeLabelDao, TreeLabelEn
return i != 0;
}
@Override
public List<String> getLabelList(String id) {
List<String> labelList = new ArrayList<>();
TreeLabelEntity treeLabelEntity = getById(id);
while (!TreeLabelConstants.ROOT_TAG_PARENT_ID.equals(treeLabelEntity.getParentId())) {
labelList.add(treeLabelEntity.getLabel());
treeLabelEntity = getById(treeLabelEntity.getParentId());
}
TreeLabelEntity root = getById(TreeLabelConstants.ROOT_LABEL_ID);
labelList.add(root.getLabel());
Collections.reverse(labelList);
return labelList;
}
private List<TreeLabelVo> createTree(String rootParentId, List<TreeLabelVo> treeLabelVos) {
List<TreeLabelVo> tree = new ArrayList<>();
for (TreeLabelVo label : treeLabelVos) {