|
|
|
@ -1,17 +1,16 @@
|
|
|
|
|
package cn.iocoder.yudao.module.system.service.taglibrary; |
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.tasktag.TaskTagMapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
import cn.iocoder.yudao.module.system.controller.admin.taglibrary.vo.*; |
|
|
|
|
import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; |
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult; |
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; |
|
|
|
@ -20,6 +19,7 @@ import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
@ -142,6 +142,30 @@ public class TagLibraryServiceImpl implements TagLibraryService {
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<TagLibraryDO> listSetParentId(List<TagLibraryDO> tagLibraryDOS) { |
|
|
|
|
List<TagLibraryDO> tagLibraryDOSAll = tagLibraryMapper.selectList(); |
|
|
|
|
Map<Integer, TagLibraryDO> integerTagLibraryDOMap = CollectionUtils.convertMap(tagLibraryDOSAll, TagLibraryDO::getId); |
|
|
|
|
|
|
|
|
|
for (TagLibraryDO tagLibraryDO : tagLibraryDOS) { |
|
|
|
|
TagLibraryDO topTag = findTopTag(integerTagLibraryDOMap, tagLibraryDO); |
|
|
|
|
if (topTag != null) { |
|
|
|
|
tagLibraryDO.setTagCode(topTag.getTagCode()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return tagLibraryDOS; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public TagLibraryDO findTopTag(Map<Integer, TagLibraryDO> integerTagLibraryDOMap,TagLibraryDO tagLibraryDOBot) { |
|
|
|
|
if(tagLibraryDOBot.getParentId() == 0) |
|
|
|
|
return tagLibraryDOBot; |
|
|
|
|
TagLibraryDO tagLibraryDO = integerTagLibraryDOMap.get(tagLibraryDOBot.getParentId()); |
|
|
|
|
|
|
|
|
|
return findTopTag(integerTagLibraryDOMap,tagLibraryDO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 递归构建树
|
|
|
|
|
private List<TagLibraryDO> buildTree(List<TagLibraryDO> tags, Integer parentId) { |
|
|
|
|
List<TagLibraryDO> tree = new ArrayList<>(); |
|
|
|
|