- 添加评论分页功能
- 在项目的
.env
文件中添加comments_per_page
环境变量,设值为2 - 修改
app config
,将评论分页配置命名为comments_per_page
,其值由环境变量转换为数字 - 导入
pagenet
和comments_per_page
配置到comment router
- 在评论接口中添加分页功能,使用
comments_per_page
作为每页显示评论数 - 修改
comments controller
的index
方法,提供pagination
属性给get_comments
方法 - 更改
get_comments
方法,将options.pagination
解构为limit
和offset
并在SQL查询中使用 - 测试分页功能,发送HTTP请求以检查结果
- 调整每页显示的评论数,修改
.env
文件中的comments_per_page
值,重新编译和运行项目以生效 - 再次测试HTTP请求以确保评论数据按预期分页显示