Commit db65dc1e authored by 刘基明's avatar 刘基明

话题排序

parent 0252f076
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -163,7 +164,8 @@ public class RankService { ...@@ -163,7 +164,8 @@ public class RankService {
// 统计话题下的所有主题数据 // 统计话题下的所有主题数据
List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList()); List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList());
Map<String, Integer> topicViewMap = visitLogService.getCountMapByTargetIds(topicIds, PageEnum.COMM_VISIT_TOPIC_DETAIL.getId()); Map<String, Integer> topicViewMap = visitLogService.getCountMapByTargetIds(topicIds,
Arrays.asList(PageEnum.COMM_VISIT_TOPIC_DETAIL_HOT.getId(),PageEnum.COMM_VISIT_TOPIC_DETAIL_NEW.getId(),PageEnum.COMM_VISIT_TOPIC_DETAIL.getId()));
for (TopicRankQo topic : topicRankQos) { for (TopicRankQo topic : topicRankQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId()); List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
if (CollectionUtils.isEmpty(themeIds)) { if (CollectionUtils.isEmpty(themeIds)) {
......
...@@ -12,6 +12,7 @@ import com.tanpu.community.api.beans.qo.ThemeQo; ...@@ -12,6 +12,7 @@ import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicFollowQo; import com.tanpu.community.api.beans.qo.TopicFollowQo;
import com.tanpu.community.api.beans.req.comment.CreateCommentReq; import com.tanpu.community.api.beans.req.comment.CreateCommentReq;
import com.tanpu.community.api.beans.req.theme.ThemeContentReq; import com.tanpu.community.api.beans.req.theme.ThemeContentReq;
import com.tanpu.community.api.beans.vo.feign.fatools.UserInfoResp;
import com.tanpu.community.api.enums.DeleteTagEnum; import com.tanpu.community.api.enums.DeleteTagEnum;
import com.tanpu.community.api.enums.ThemeTypeEnum; import com.tanpu.community.api.enums.ThemeTypeEnum;
import com.tanpu.community.dao.entity.community.ThemeEntity; import com.tanpu.community.dao.entity.community.ThemeEntity;
...@@ -49,6 +50,8 @@ public class ThemeService { ...@@ -49,6 +50,8 @@ public class ThemeService {
private RedisHelper redisHelper; private RedisHelper redisHelper;
@Resource @Resource
private VisitLogMapper visitLogMapper; private VisitLogMapper visitLogMapper;
@Resource
private FeignService feignService;
@Transactional @Transactional
public void insertTheme(ThemeEntity themeEntity) { public void insertTheme(ThemeEntity themeEntity) {
...@@ -337,6 +340,7 @@ public class ThemeService { ...@@ -337,6 +340,7 @@ public class ThemeService {
ThemeEntity themeEntity = themeMapper.queryOneByTopicIdOrderByUpdateTimeDesc(topicId); ThemeEntity themeEntity = themeMapper.queryOneByTopicIdOrderByUpdateTimeDesc(topicId);
if (themeEntity != null) { if (themeEntity != null) {
ThemeQo themeQo = ConvertUtil.themeEntityToQo(themeEntity); ThemeQo themeQo = ConvertUtil.themeEntityToQo(themeEntity);
topic.setLastTheme(getUserName(themeQo.getAuthorId()) + ":" + themeQo.content.get(0).getValue()); topic.setLastTheme(getUserName(themeQo.getAuthorId()) + ":" + themeQo.content.get(0).getValue());
topic.setLastThemeTime(TimeUtils.formatTopicListTime(themeEntity.getUpdateTime())); topic.setLastThemeTime(TimeUtils.formatTopicListTime(themeEntity.getUpdateTime()));
...@@ -357,7 +361,10 @@ public class ThemeService { ...@@ -357,7 +361,10 @@ public class ThemeService {
} }
private String getUserName(String authorId) { private String getUserName(String authorId) {
UserInfoResp userInfoById = feignService.getUserInfoById(authorId);
return "理财师Jack"; if (StringUtils.isNotBlank(userInfoById.getNickName())){
return userInfoById.getNickName();
}
return "理财师";
} }
} }
...@@ -139,6 +139,20 @@ public class VisitLogService { ...@@ -139,6 +139,20 @@ public class VisitLogService {
.collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes)); .collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes));
} }
//统计行为集合的浏览量
public Map<String, Integer> getCountMapByTargetIds(List<String> refIds, List<String> refTypes) {
if (CollectionUtils.isEmpty(refIds)) {
return new HashMap<>();
}
LambdaQueryWrapper<VisitLogEntity> wrapper = (new LambdaQueryWrapper<VisitLogEntity>()
.in(VisitLogEntity::getRefId, refIds))
.eq(VisitLogEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED)
.in(VisitLogEntity::getRefType, refTypes)
.groupBy(VisitLogEntity::getRefId);
return visitLogMapper.selectCountByThemeIds(wrapper).stream()
.collect(Collectors.toMap(TimesCountEntity::getId, TimesCountEntity::getTimes));
}
// 查询讨论区最近浏览 // 查询讨论区最近浏览
public Integer queryLastTopicVisit(String theme) { public Integer queryLastTopicVisit(String theme) {
return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>() return visitLogMapper.selectCount(new LambdaQueryWrapper<VisitLogEntity>()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment