|
|
|
@ -4,6 +4,8 @@ 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.SongTagDao;
|
|
|
|
|
import com.luoo.tag.dao.TagDao;
|
|
|
|
|
import com.luoo.tag.enums.TagLevelEnum;
|
|
|
|
|
import com.luoo.tag.enums.TagStateEnum;
|
|
|
|
@ -37,6 +39,9 @@ public class TagService {
|
|
|
|
|
private final TagDao tagDao;
|
|
|
|
|
private final IdWorker idWorker;
|
|
|
|
|
private final UserClient userClient;
|
|
|
|
|
private final ColumnTagDao columnTagDao;
|
|
|
|
|
private final SongTagDao songTagDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 标签信息分页查询
|
|
|
|
@ -245,32 +250,32 @@ public class TagService {
|
|
|
|
|
* @return 引用统计集合
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, TagStatistic> queryTagStatistic(List<String> tagIdList){
|
|
|
|
|
Map<String, TagStatistic> tagStatisticMap = tagIdList.stream()
|
|
|
|
|
.collect(toMap(Function.identity(), TagStatistic::new));
|
|
|
|
|
List<TagStatistic> childTagStatisticList = queryChildTagStatistic(tagIdList);
|
|
|
|
|
childTagStatisticList.forEach(childTagStatistic -> {
|
|
|
|
|
tagStatisticMap.get(childTagStatistic.getTagId()).setChildTagCount(childTagStatistic.getChildTagCount());
|
|
|
|
|
});
|
|
|
|
|
// todo 关联音乐或期刊
|
|
|
|
|
return tagStatisticMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<TagStatistic> queryChildTagStatistic(List<String> tagIdList){
|
|
|
|
|
if(CollectionUtils.isEmpty(tagIdList)){
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
}
|
|
|
|
|
List<TagStatistic> childTagStatisticList = tagDao.countByParentIds(tagIdList);
|
|
|
|
|
Map<String, TagStatistic> childTagStatisticMap = childTagStatisticList.stream()
|
|
|
|
|
.collect(toMap(TagStatistic::getTagId, Function.identity()));
|
|
|
|
|
return tagIdList.stream().map(tagId -> {
|
|
|
|
|
TagStatistic tagStatistic = childTagStatisticMap.get(tagId);
|
|
|
|
|
if(Objects.isNull(tagStatistic)){
|
|
|
|
|
tagStatistic = new TagStatistic();
|
|
|
|
|
tagStatistic.setTagId(tagId);
|
|
|
|
|
tagStatistic.setChildTagCount(0L);
|
|
|
|
|
}
|
|
|
|
|
return tagStatistic;
|
|
|
|
|
List<TagCountDTO> childTagCountList = tagDao.countByParentIds(tagIdList);
|
|
|
|
|
Map<String, Long> childTagCountMap = childTagCountList.stream()
|
|
|
|
|
.collect(toMap(TagCountDTO::getTagId, TagCountDTO::getCount));
|
|
|
|
|
List<TagCountDTO> songTagCountList = songTagDao.countByTagIds(tagIdList);
|
|
|
|
|
Map<String, Long> songTagCountMap = songTagCountList.stream()
|
|
|
|
|
.collect(toMap(TagCountDTO::getTagId, TagCountDTO::getCount));
|
|
|
|
|
List<TagCountDTO> columnTagCountList = songTagDao.countByTagIds(tagIdList);
|
|
|
|
|
Map<String, Long> columnTagCountMap = columnTagCountList.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);
|
|
|
|
|
return TagStatistic.builder()
|
|
|
|
|
.tagId(tagId)
|
|
|
|
|
.childTagCount(childTagCount)
|
|
|
|
|
.songRefCount(songTagCount)
|
|
|
|
|
.columnRefCount(columnTagCount)
|
|
|
|
|
.build();
|
|
|
|
|
}).collect(toList());
|
|
|
|
|
|
|
|
|
|
return tagStatisticList.stream().collect(toMap(TagStatistic::getTagId, Function.identity()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|