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