|
@@ -8,6 +8,7 @@ import com.yohobuy.platform.common.util.DateUtil; |
|
@@ -8,6 +8,7 @@ import com.yohobuy.platform.common.util.DateUtil; |
8
|
import com.yohobuy.platform.common.util.StringUtil;
|
8
|
import com.yohobuy.platform.common.util.StringUtil;
|
9
|
import com.yohobuy.platform.dal.grass.*;
|
9
|
import com.yohobuy.platform.dal.grass.*;
|
10
|
import com.yohobuy.platform.dal.grass.model.GrassArticle;
|
10
|
import com.yohobuy.platform.dal.grass.model.GrassArticle;
|
|
|
11
|
+import com.yohobuy.platform.dal.grass.model.GrassArticleTopic;
|
11
|
import com.yohobuy.platform.dal.grass.model.GrassLabel;
|
12
|
import com.yohobuy.platform.dal.grass.model.GrassLabel;
|
12
|
import com.yohobuy.platform.dal.grass.model.GrassTopic;
|
13
|
import com.yohobuy.platform.dal.grass.model.GrassTopic;
|
13
|
import com.yohobuy.platform.grass.service.ITopicService;
|
14
|
import com.yohobuy.platform.grass.service.ITopicService;
|
|
@@ -43,6 +44,9 @@ public class TopicServiceImpl implements ITopicService { |
|
@@ -43,6 +44,9 @@ public class TopicServiceImpl implements ITopicService { |
43
|
@Autowired
|
44
|
@Autowired
|
44
|
private IGrassTopicGroupDAO topicGroupDAO;
|
45
|
private IGrassTopicGroupDAO topicGroupDAO;
|
45
|
|
46
|
|
|
|
47
|
+ @Autowired
|
|
|
48
|
+ private IGrassArticleTopicDao articleTopicDao;
|
|
|
49
|
+
|
46
|
|
50
|
|
47
|
@Override
|
51
|
@Override
|
48
|
public PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req) {
|
52
|
public PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req) {
|
|
@@ -119,15 +123,17 @@ public class TopicServiceImpl implements ITopicService { |
|
@@ -119,15 +123,17 @@ public class TopicServiceImpl implements ITopicService { |
119
|
return new ArrayList<>();
|
123
|
return new ArrayList<>();
|
120
|
}
|
124
|
}
|
121
|
List<TopicRespBo> result = new ArrayList<>();
|
125
|
List<TopicRespBo> result = new ArrayList<>();
|
122
|
- List<Integer> topicId = sourceList.stream().map(GrassTopic::getId).distinct().collect(Collectors.toList());
|
126
|
+ List<Integer> topicIds = sourceList.stream().map(GrassTopic::getId).distinct().collect(Collectors.toList());
|
123
|
//查询文章表 统计话题下的文章数(不考虑文章状态)
|
127
|
//查询文章表 统计话题下的文章数(不考虑文章状态)
|
124
|
-
|
|
|
125
|
-
|
128
|
+ List<GrassArticleTopic> topicList = articleTopicDao.countBytopicIds(topicIds);
|
|
|
129
|
+ Map<Integer,Integer> topicMap = topicList.stream().collect(Collectors.toMap(GrassArticleTopic::getTopicId, obj -> obj.getNum()));
|
126
|
|
130
|
|
127
|
for(GrassTopic grassTopic : sourceList){
|
131
|
for(GrassTopic grassTopic : sourceList){
|
128
|
TopicRespBo bo = new TopicRespBo();
|
132
|
TopicRespBo bo = new TopicRespBo();
|
129
|
BeanUtils.copyProperties(grassTopic,bo);
|
133
|
BeanUtils.copyProperties(grassTopic,bo);
|
130
|
bo.setUpdateTimeStr(grassTopic.getUpdateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
|
134
|
bo.setUpdateTimeStr(grassTopic.getUpdateTime() == null ? "" : DateUtil.int2DateStr(grassTopic.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
135
|
+ //相关的文章
|
|
|
136
|
+ bo.setArticleAmount(topicMap.get(bo.getId()) == null ? 0 : topicMap.get(bo.getId()));
|
131
|
result.add(bo);
|
137
|
result.add(bo);
|
132
|
}
|
138
|
}
|
133
|
return result;
|
139
|
return result;
|