...
|
...
|
@@ -8,6 +8,7 @@ import com.yohobuy.platform.common.util.DateUtil; |
|
|
import com.yohobuy.platform.common.util.StringUtil;
|
|
|
import com.yohobuy.platform.dal.grass.*;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassArticle;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassArticleTopic;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassLabel;
|
|
|
import com.yohobuy.platform.dal.grass.model.GrassTopic;
|
|
|
import com.yohobuy.platform.grass.service.ITopicService;
|
...
|
...
|
@@ -43,6 +44,9 @@ public class TopicServiceImpl implements ITopicService { |
|
|
@Autowired
|
|
|
private IGrassTopicGroupDAO topicGroupDAO;
|
|
|
|
|
|
@Autowired
|
|
|
private IGrassArticleTopicDao articleTopicDao;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req) {
|
...
|
...
|
@@ -119,15 +123,17 @@ public class TopicServiceImpl implements ITopicService { |
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<TopicRespBo> result = new ArrayList<>();
|
|
|
List<Integer> topicId = sourceList.stream().map(GrassTopic::getId).distinct().collect(Collectors.toList());
|
|
|
List<Integer> topicIds = sourceList.stream().map(GrassTopic::getId).distinct().collect(Collectors.toList());
|
|
|
//查询文章表 统计话题下的文章数(不考虑文章状态)
|
|
|
|
|
|
|
|
|
List<GrassArticleTopic> topicList = articleTopicDao.countBytopicIds(topicIds);
|
|
|
Map<Integer,Integer> topicMap = topicList.stream().collect(Collectors.toMap(GrassArticleTopic::getTopicId, obj -> obj.getNum()));
|
|
|
|
|
|
for(GrassTopic grassTopic : sourceList){
|
|
|
TopicRespBo bo = new TopicRespBo();
|
|
|
BeanUtils.copyProperties(grassTopic,bo);
|
|
|
bo.setUpdateTimeStr(grassTopic.getUpdateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
//相关的文章
|
|
|
bo.setArticleAmount(topicMap.get(bo.getId()) == null ? 0 : topicMap.get(bo.getId()));
|
|
|
result.add(bo);
|
|
|
}
|
|
|
return result;
|
...
|
...
|
|