|
|
|
@ -4,7 +4,7 @@ import api.PageResult;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.luoo.tag.client.UserClient;
|
|
|
|
|
import com.luoo.tag.config.RequestContext;
|
|
|
|
|
import com.luoo.tag.dao.ColumnTagDao;
|
|
|
|
|
import com.luoo.tag.dao.JournalTagDao;
|
|
|
|
|
import com.luoo.tag.dao.SongTagDao;
|
|
|
|
|
import com.luoo.tag.dao.TagDao;
|
|
|
|
|
import com.luoo.tag.enums.TagLevelEnum;
|
|
|
|
@ -38,7 +38,7 @@ public class TagService {
|
|
|
|
|
private final TagDao tagDao;
|
|
|
|
|
private final IdWorker idWorker;
|
|
|
|
|
private final UserClient userClient;
|
|
|
|
|
private final ColumnTagDao columnTagDao;
|
|
|
|
|
private final JournalTagDao journalTagDao;
|
|
|
|
|
private final SongTagDao songTagDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -65,7 +65,7 @@ public class TagService {
|
|
|
|
|
BeanUtils.copyProperties(tag, tagDTO);
|
|
|
|
|
TagStatistic tagStatistic = tagStatisticMap.get(tag.getId());
|
|
|
|
|
tagDTO.setChildTagCount(tagStatistic.getChildTagCount());
|
|
|
|
|
tagDTO.setColumnRefCount(tagStatistic.getColumnRefCount());
|
|
|
|
|
tagDTO.setJournalRefCount(tagStatistic.getJournalRefCount());
|
|
|
|
|
tagDTO.setSongRefCount(tagStatistic.getSongRefCount());
|
|
|
|
|
Tag parentTag = parentTagMap.get(tagDTO.getParentId());
|
|
|
|
|
if (Objects.nonNull(parentTag)) {
|
|
|
|
@ -151,7 +151,7 @@ public class TagService {
|
|
|
|
|
|
|
|
|
|
TagStatistic tagStatistic = queryTagStatistic(tag.getId());
|
|
|
|
|
tagDTO.setChildTagCount(tagStatistic.getChildTagCount());
|
|
|
|
|
tagDTO.setColumnRefCount(tagStatistic.getColumnRefCount());
|
|
|
|
|
tagDTO.setJournalRefCount(tagStatistic.getJournalRefCount());
|
|
|
|
|
tagDTO.setSongRefCount(tagStatistic.getSongRefCount());
|
|
|
|
|
return tagDTO;
|
|
|
|
|
}
|
|
|
|
@ -184,7 +184,7 @@ public class TagService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TagStatistic referenceStatistic = queryTagStatistic(tagOptional.get().getId());
|
|
|
|
|
AssertUtil.mustEq(referenceStatistic.getColumnRefCount(), 0L,"无法执行删除, 该标签还存在关联的期刊");
|
|
|
|
|
AssertUtil.mustEq(referenceStatistic.getJournalRefCount(), 0L,"无法执行删除, 该标签还存在关联的期刊");
|
|
|
|
|
AssertUtil.mustEq(referenceStatistic.getSongRefCount(), 0L,"无法执行删除, 该标签还存在关联的音乐");
|
|
|
|
|
AssertUtil.mustEq(referenceStatistic.getChildTagCount(), 0L,"无法执行删除, 该标签还存在关联的子标签");
|
|
|
|
|
tagDao.deleteById(id);
|
|
|
|
@ -255,19 +255,19 @@ public class TagService {
|
|
|
|
|
List<TagCountDTO> songTagCountList = songTagDao.countByTagIds(tagIdList);
|
|
|
|
|
Map<String, Long> songTagCountMap = songTagCountList.stream()
|
|
|
|
|
.collect(toMap(TagCountDTO::getTagId, TagCountDTO::getCount));
|
|
|
|
|
List<TagCountDTO> columnTagCountList = columnTagDao.countByTagIds(tagIdList);
|
|
|
|
|
Map<String, Long> columnTagCountMap = columnTagCountList.stream()
|
|
|
|
|
List<TagCountDTO> journalTagCountList = journalTagDao.countByTagIds(tagIdList);
|
|
|
|
|
Map<String, Long> journalTagCountMap = journalTagCountList.stream()
|
|
|
|
|
.collect(toMap(TagCountDTO::getTagId, TagCountDTO::getCount));
|
|
|
|
|
|
|
|
|
|
List<TagStatistic> tagStatisticList = tagIdList.stream().map(tagId -> {
|
|
|
|
|
Long childTagCount = childTagCountMap.getOrDefault(tagId, 0L);
|
|
|
|
|
Long songTagCount = songTagCountMap.getOrDefault(tagId, 0L);
|
|
|
|
|
Long columnTagCount = columnTagCountMap.getOrDefault(tagId, 0L);
|
|
|
|
|
Long journalTagCount = journalTagCountMap.getOrDefault(tagId, 0L);
|
|
|
|
|
return TagStatistic.builder()
|
|
|
|
|
.tagId(tagId)
|
|
|
|
|
.childTagCount(childTagCount)
|
|
|
|
|
.songRefCount(songTagCount)
|
|
|
|
|
.columnRefCount(columnTagCount)
|
|
|
|
|
.journalRefCount(journalTagCount)
|
|
|
|
|
.build();
|
|
|
|
|
}).collect(toList());
|
|
|
|
|
|
|
|
|
|