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

讨论区置顶

parent 0a2f0251
package com.tanpu.community.dao.mapper.community; package com.tanpu.community.dao.mapper.community;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
...@@ -8,6 +9,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -8,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
...@@ -24,14 +26,23 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> { ...@@ -24,14 +26,23 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper); List<TimesCountEntity> selectCountByThemeIds(@Param(Constants.WRAPPER) LambdaQueryWrapper wrapper);
ThemeEntity queryOneByTopicIdOrderByUpdateTimeDesc(@Param("topicId")String topicId); ThemeEntity queryOneByTopicIdOrderByUpdateTimeDesc(@Param("topicId") String topicId);
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); List<ThemeEntity> queryRecentdaysOrHasTopic(@Param("deleteTag") Integer deleteTag, @Param("minCreateTime") LocalDateTime minCreateTime, @Param("notTopicId") String notTopicId);
/**
* 关注人+关注话题下的帖子,带分页
*
* @param followUsers
* @param followTopics
* @return
*/
List<ThemeEntity> queryFollowList(@Param("authorIdCollection") Collection<String> followUsers, @Param("topicIdCollection") Collection<String> followTopics,
@Param("pageStart") Integer pageStart, @Param("pageSize") Integer pageSize);
} }
...@@ -532,12 +532,21 @@ public class ThemeManager { ...@@ -532,12 +532,21 @@ public class ThemeManager {
if (StringUtils.isEmpty(req.getTopicId())) { if (StringUtils.isEmpty(req.getTopicId())) {
throw new BizException("TopicId为空"); throw new BizException("TopicId为空");
} }
// 话题下的置顶
List<ThemeEntity> topThemes = themeService.queryTopByTopic(req.getTopicId());
excludeIds.addAll(topThemes.stream().map(ThemeEntity::getThemeId).collect(Collectors.toList()));
List<String> rankThemeIds = rankService.getRankThemeListByTopic(req.getTopicId(), excludeIds); List<String> rankThemeIds = rankService.getRankThemeListByTopic(req.getTopicId(), excludeIds);
rankThemeIds = BizUtils.subList(rankThemeIds, pageStart, pageSize); rankThemeIds = BizUtils.subList(rankThemeIds, pageStart, pageSize);
themes = themeService.queryByThemeIds(rankThemeIds); themes = themeService.queryByThemeIds(rankThemeIds);
themes = RankUtils.sortThemeEntityByIds(themes, rankThemeIds); themes = RankUtils.sortThemeEntityByIds(themes, rankThemeIds);
// 置顶
if (pageStart==0){
topThemes.addAll(themes);
themes=topThemes;
}
} else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) { } else if (ThemeListTypeEnum.TOPIC_LATEST.getCode().equals(req.getType())) {
//根据话题查询最新 //根据话题查询最新
......
...@@ -14,6 +14,7 @@ import com.tanpu.community.api.beans.req.comment.CreateCommentReq; ...@@ -14,6 +14,7 @@ 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.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.StatusEnum;
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;
import com.tanpu.community.dao.entity.community.TimesCountEntity; import com.tanpu.community.dao.entity.community.TimesCountEntity;
...@@ -220,15 +221,8 @@ public class ThemeService { ...@@ -220,15 +221,8 @@ public class ThemeService {
if (CollectionUtils.isEmpty(userIds)) { if (CollectionUtils.isEmpty(userIds)) {
return Collections.emptyList(); return Collections.emptyList();
} }
// 权限控制,添加主题为空的情况 userPermitTopics.remove("");
userPermitTopics.add(""); return themeMapper.queryFollowList(userIds,userPermitTopics,pageStart,pageSize);
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.in(ThemeEntity::getAuthorId, userIds)
.in(ThemeEntity::getTopicId, userPermitTopics)
.last("limit " + pageStart + ", " + pageSize)
.orderByDesc(ThemeEntity::getCreateTime)
.eq(ThemeEntity::getDeleteTag, DeleteTagEnum.NOT_DELETED.getCode());
return themeMapper.selectList(queryWrapper);
} }
...@@ -367,4 +361,13 @@ public class ThemeService { ...@@ -367,4 +361,13 @@ public class ThemeService {
} }
return "理财师"; return "理财师";
} }
public List<ThemeEntity> queryTopByTopic(String topicId) {
LambdaQueryWrapper<ThemeEntity> queryWrapper = new LambdaQueryWrapper<ThemeEntity>()
.eq(ThemeEntity::getTopicId, topicId)
.eq(ThemeEntity::getDeleteTag, StatusEnum.FALSE.getCode())
.eq(ThemeEntity::getIsTop,StatusEnum.TRUE.getCode())
.orderByDesc(ThemeEntity::getSetTopTime);
return themeMapper.selectList(queryWrapper);
}
} }
...@@ -64,4 +64,21 @@ ...@@ -64,4 +64,21 @@
and ( create_time <![CDATA[>]]> #{minCreateTime} and ( create_time <![CDATA[>]]> #{minCreateTime}
or topic_id <![CDATA[<>]]> #{notTopicId}) or topic_id <![CDATA[<>]]> #{notTopicId})
</select> </select>
<!--auto generated by MybatisCodeHelper on 2022-02-23-->
<select id="queryFollowList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from theme
where delete_tag=0 and ((author_id in
<foreach item="item" index="index" collection="authorIdCollection"
open="(" separator="," close=")">
#{item}
</foreach>
and topic_id="") or topic_id in
<foreach item="item" index="index" collection="topicIdCollection"
open="(" separator="," close=")">
#{item}) limit #{pageStart}, #{pageSize}
</foreach>
</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