Commit 16b2a3e9 by 段启岩

新增热搜话题接口

parent 67e537bc
......@@ -205,4 +205,15 @@ public class TopicApi {
}
}
@Anonymous
@ApiOperation("热搜话题")
@GetMapping("/topic/hotSearch")
public Response<?> hotSearchTopics(@Valid PageForm pageForm, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return Response.fieldError(bindingResult.getFieldError());
}
PageDTO<TopicDTO> topicDTOPage = topicService.getHotSearchTopics(pageForm.getPage(), pageForm.getSize());
return Response.success(topicDTOPage);
}
}
......@@ -2,6 +2,8 @@ package cn.meteor.beyondclouds.modules.topic.mapper;
import cn.meteor.beyondclouds.modules.topic.entity.Topic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Component;
import java.util.List;
......@@ -23,4 +25,11 @@ public interface TopicMapper extends BaseMapper<Topic> {
* @return
*/
List<Topic> searchTopics(String keywords);
/**
* 热搜话题
* @param topicPage
* @return
*/
IPage<Topic> selectHotSearchPage(Page<Topic> topicPage);
}
......@@ -5,4 +5,12 @@
<select id="searchTopics" resultType="cn.meteor.beyondclouds.modules.topic.entity.Topic">
select * from topic where topic_name like CONCAT('%',#{keywords},'%')
</select>
<select id="selectHotSearchPage" resultType="cn.meteor.beyondclouds.modules.topic.entity.Topic">
SELECT t.*
FROM topic t, search_degree sd
WHERE t.topic_id = sd.item_id
AND sd.item_type = 'TOPIC'
ORDER BY sd.degree DESC;
</select>
</mapper>
......@@ -153,4 +153,13 @@ public interface ITopicService extends IService<Topic> {
* @return
*/
List<Topic> queryAndCreateByTopicNames(List<String> topicNames, String userId);
/**
* 获取热搜话题
* @return
* @param pageNumber
* @param pageSize
*/
PageDTO<TopicDTO> getHotSearchTopics(Integer pageNumber, Integer pageSize);
}
......@@ -546,6 +546,11 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
return topics;
}
@Override
public PageDTO<TopicDTO> getHotSearchTopics(Integer pageNumber, Integer pageSize) {
IPage<Topic> topicPage = topicMapper.selectHotSearchPage(new Page<Topic>(pageNumber, pageSize));
return toPageDTO(topicPage);
}
}
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