Commit bde9afa6 by 胡学良

热门问答

parent 92c0430f
...@@ -246,5 +246,14 @@ public class QuestionApi { ...@@ -246,5 +246,14 @@ public class QuestionApi {
return Response.success(questionReplyPageVO); return Response.success(questionReplyPageVO);
} }
@Anonymous
@ApiOperation("热门回答")
@GetMapping("/question/hots")
public Response<PageVO<Question>> getHotsQuestions(@Valid PageForm pageForm) {
IPage<Question> questionPage = questionService.getHotsQuestionsPage(pageForm.getPage(), pageForm.getSize());
PageVO<Question> questionPageVO = new PageVO<>(questionPage);
return Response.success(questionPageVO);
}
} }
...@@ -85,4 +85,12 @@ public interface IQuestionService extends IService<Question> { ...@@ -85,4 +85,12 @@ public interface IQuestionService extends IService<Question> {
*/ */
IPage<Question> getUserParticipatePage(Integer pageNumber, Integer pageSize, String userId); IPage<Question> getUserParticipatePage(Integer pageNumber, Integer pageSize, String userId);
/**
* 获取热门回答列表
* @param pageNumber 页数
* @param pageSize 页面大小
* @return 分页对象
*/
IPage<Question> getHotsQuestionsPage(Integer pageNumber, Integer pageSize);
} }
...@@ -368,4 +368,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i ...@@ -368,4 +368,12 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
} }
return questionPage; return questionPage;
} }
@Override
public IPage<Question> getHotsQuestionsPage(Integer pageNumber, Integer pageSize) {
IPage<Question> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Question> questionQueryWrapper = new QueryWrapper<>();
questionQueryWrapper.orderByDesc("q.view_number");
return questionMapper.selectPageWithTags(page, questionQueryWrapper);
}
} }
...@@ -3,7 +3,7 @@ spring: ...@@ -3,7 +3,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username: root username: root
password: 100Centa30821%mysql password: 197442
swagger: swagger:
enable: true enable: true
......
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