feat(文章): 添加根据状态分页查询文章功能

实现文章列表的分页查询功能,包括:
- 在ArticleRepository添加分页查询方法
- 在IArticleService和ArticleService添加分页接口和实现
- 新增PageDto用于分页参数校验
- 在ArticleController添加分页接口
This commit is contained in:
qingfeng1121
2025-11-14 15:30:39 +08:00
parent 47c357695b
commit eb1f70d431
14 changed files with 5649 additions and 15226 deletions

View File

@@ -0,0 +1,42 @@
package com.qf.myafterprojecy.pojo.dto;
import javax.ws.rs.DefaultValue;
public class PageDto {
private Integer status;
@DefaultValue("0")
private Integer page;
@DefaultValue("10")
private Integer size;
// 数据验证
public void validate() {
if ( status > 0 && status <= 2) {
throw new IllegalArgumentException("Status must be 0 or 2");
}
if (page < 0) {
throw new IllegalArgumentException("Page number must be non-negative");
}
if (size <= 0 || size > 100) {
throw new IllegalArgumentException("Page size must be between 1 and 100");
}
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
this.size = size;
}
}