Commit 0a2f0251 authored by 张辰's avatar 张辰

Merge branch 'v2.3.1' of http://47.100.44.39:10001/tp-backend/tanpu-community into v2.3.1

parents 5e290a4d 69fca593
...@@ -29,5 +29,9 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> { ...@@ -29,5 +29,9 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
Integer countByTopicIdAndCreateTimeAfter(@Param("topicId")String topicId,@Param("minCreateTime")LocalDateTime minCreateTime); Integer countByTopicIdAndCreateTimeAfter(@Param("topicId")String topicId,@Param("minCreateTime")LocalDateTime minCreateTime);
List<ThemeEntity> queryRecentdaysOrHasTopic(@Param("deleteTag")Integer deleteTag,@Param("minCreateTime")LocalDateTime minCreateTime,@Param("notTopicId")String notTopicId);
} }
...@@ -477,10 +477,7 @@ public class ThemeManager { ...@@ -477,10 +477,7 @@ public class ThemeManager {
}); });
firstThemeTime = themeService.queryByThemeIdIgnoreDelete(excludeIds.get(0)).getCreateTime(); firstThemeTime = themeService.queryByThemeIdIgnoreDelete(excludeIds.get(0)).getCreateTime();
} }
} }
Integer pageStart = (req.page.pageNumber - 1) * req.page.pageSize; Integer pageStart = (req.page.pageNumber - 1) * req.page.pageSize;
Integer pageSize = req.page.pageSize; Integer pageSize = req.page.pageSize;
......
...@@ -110,11 +110,11 @@ public class TopicManager { ...@@ -110,11 +110,11 @@ public class TopicManager {
themeService.queryCommentForTopic(topicFollowQos, userId); themeService.queryCommentForTopic(topicFollowQos, userId);
// 排序 // 排序
topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()). List<TopicFollowQo> res = topicFollowQos.stream().filter(o -> o.checkTopicName(keyword)).sorted(Comparator.comparing(TopicFollowQo::getSpecialPermission, Comparator.reverseOrder()).
thenComparing(TopicFollowQo::getLastThemeTime, Comparator.nullsFirst(String::compareTo).reversed())) thenComparing(TopicFollowQo::getLastThemeTime, Comparator.nullsFirst(String::compareTo).reversed()))
.collect(Collectors.toList()); .collect(Collectors.toList());
return topicFollowQos; return res;
} }
/** /**
......
package com.tanpu.community.service; package com.tanpu.community.service;
import com.tanpu.common.api.CommonResp; import com.tanpu.common.api.CommonResp;
import com.tanpu.common.exception.BizException;
import com.tanpu.community.api.beans.resp.CoursePackageSimpleResp; import com.tanpu.community.api.beans.resp.CoursePackageSimpleResp;
import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp; import com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp;
import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp; import com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp;
...@@ -26,6 +25,7 @@ import org.springframework.stereotype.Service; ...@@ -26,6 +25,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
...@@ -65,9 +65,9 @@ public class FeignService { ...@@ -65,9 +65,9 @@ public class FeignService {
public UserInfoResp getUserInfoById(String userId) { public UserInfoResp getUserInfoById(String userId) {
List<UserInfoResp> userList = getUserList(Arrays.asList(userId)); List<UserInfoResp> userList = getUserList(Collections.singletonList(userId));
if (CollectionUtils.isEmpty(userList)) { if (CollectionUtils.isEmpty(userList)) {
throw new BizException("内部接口调用失败"); return null;
} }
return userList.get(0); return userList.get(0);
} }
......
...@@ -27,8 +27,6 @@ import java.util.List; ...@@ -27,8 +27,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USER_INFO;
@Service @Service
public class RankService { public class RankService {
...@@ -97,7 +95,7 @@ public class RankService { ...@@ -97,7 +95,7 @@ public class RankService {
LocalDateTime start = LocalDateTime.now(); LocalDateTime start = LocalDateTime.now();
//7天内所有主题进行热度值排序 //7天内所有主题进行热度值排序
List<ThemeEntity> themeEntities = themeService.queryRecentdays(60); List<ThemeEntity> themeEntities = themeService.queryRecentdaysOrHasTopic(60);
if (CollectionUtils.isEmpty(themeEntities)) { if (CollectionUtils.isEmpty(themeEntities)) {
return; return;
} }
...@@ -119,8 +117,7 @@ public class RankService { ...@@ -119,8 +117,7 @@ public class RankService {
theme.setViewCount(visitCountMap.getOrDefault(themeId, 0)); theme.setViewCount(visitCountMap.getOrDefault(themeId, 0));
//查询用户质量 //查询用户质量
String authorId = theme.getAuthorId(); String authorId = theme.getAuthorId();
UserInfoResp authorInfo = redisCache.getObject(StringUtils.joinWith("_", CACHE_FEIGN_USER_INFO, authorId), UserInfoResp authorInfo = feignService.getUserInfoById(authorId);
60, () -> feignService.getUserInfoById(authorId), UserInfoResp.class);
if (authorInfo == null || authorInfo.getLevelGrade() == null) { if (authorInfo == null || authorInfo.getLevelGrade() == null) {
theme.setUserWeight(0.0); theme.setUserWeight(0.0);
} else { } else {
......
...@@ -62,13 +62,9 @@ public class ThemeService { ...@@ -62,13 +62,9 @@ public class ThemeService {
} }
//n天内发表的所有主题 //n天内发表的所有主题
public List<ThemeEntity> queryRecentdays(Integer days) { public List<ThemeEntity> queryRecentdaysOrHasTopic(Integer days) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode())
.gt(ThemeEntity::getCreateTime, TimeUtils.getDaysBefore(days))
.orderByDesc(ThemeEntity::getId);
return themeMapper.selectList(queryWrapper); return themeMapper.queryRecentdaysOrHasTopic(DeleteTagEnum.NOT_DELETED.getCode(), TimeUtils.getDaysBefore(days), "");
} }
//最新的n条主题 //最新的n条主题
...@@ -366,7 +362,7 @@ public class ThemeService { ...@@ -366,7 +362,7 @@ public class ThemeService {
private String getUserName(String authorId) { private String getUserName(String authorId) {
UserInfoResp userInfoById = feignService.getUserInfoById(authorId); UserInfoResp userInfoById = feignService.getUserInfoById(authorId);
if (StringUtils.isNotBlank(userInfoById.getNickName())){ if (StringUtils.isNotBlank(userInfoById.getNickName())) {
return userInfoById.getNickName(); return userInfoById.getNickName();
} }
return "理财师"; return "理财师";
......
...@@ -54,4 +54,14 @@ ...@@ -54,4 +54,14 @@
where topic_id = #{topicId} where topic_id = #{topicId}
and create_time <![CDATA[>]]> #{minCreateTime} and create_time <![CDATA[>]]> #{minCreateTime}
</select> </select>
<!--auto generated by MybatisCodeHelper on 2022-02-22-->
<select id="queryRecentdaysOrHasTopic" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from theme
where delete_tag=#{deleteTag}
and ( create_time <![CDATA[>]]> #{minCreateTime}
or topic_id <![CDATA[<>]]> #{notTopicId})
</select>
</mapper> </mapper>
...@@ -34,6 +34,6 @@ ...@@ -34,6 +34,6 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from visit_log from visit_log
where visitor_id=#{visitorId} and ref_id=#{refId} where visitor_id=#{visitorId} and ref_id=#{refId}
order by update_time limit 1 order by update_time desc limit 1
</select> </select>
</mapper> </mapper>
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