概念标签不存在则创建的逻辑

This commit is contained in:
sunflower2014 2025-06-19 19:06:36 +08:00
parent 6863147014
commit 6898af28c0
2 changed files with 22 additions and 17 deletions

View File

@ -178,7 +178,7 @@ public class NewsInfoService {
}
private Long saveConceptLabel(String conceptLabel) {
String[] conceptTags = conceptLabel.split("-");
final String[] conceptTags = conceptLabel.split("-");
Tag levelOneTag = new Tag();
levelOneTag.setParentId(6L);
levelOneTag.setLevel(1);
@ -190,6 +190,7 @@ public class NewsInfoService {
levelTwoTag.setLevel(2);
levelTwoTag.setParentName(conceptTags[0]);
levelTwoTag.setName(conceptTags[1]);
tagMapper.saveTag(levelTwoTag);
return levelTwoTag.getId();
}
return levelOneTag.getId();

View File

@ -300,6 +300,7 @@ public class NewsService {
for (NewsTagRel rel : tagRelList) {
Long tagId = rel.getTagId();
Tag tag = tagMap.get(tagId);
if (tag != null) {
Long parentId = tag.getParentId();
NewsDetailTagItem tagItem = new NewsDetailTagItem();
tagItem.setId(tagId);
@ -313,6 +314,7 @@ public class NewsService {
arr.add(tagItem);
}
}
}
newsDetailTag.setFieldArr(arr);
}
@ -323,6 +325,7 @@ public class NewsService {
for (NewsIndustryRel rel: industryRelList) {
Long industryId = rel.getIndustryId();
Industry industry = industryMap.get(industryId);
if (industry != null) {
NewsDetailIndustry newsDetailIndustry = new NewsDetailIndustry();
newsDetailIndustry.setId(industryId);
newsDetailIndustry.setPrimaryName(industry.getPrimaryName());
@ -330,6 +333,7 @@ public class NewsService {
newsIndustryList.add(newsDetailIndustry);
}
}
}
return ResultObject.success(newsDetailVO);
}