Browse Source
- 在 Algorithm 枚举中添加 getAlgorithmIds 方法用于获取算法ID集合 - 在 ModelSelectQuery 查询类中继承 PageParam 实现分页参数功能 - 修改 ModelController 和 ModelService 接口返回 PagedResponse 分页结果 - 实现 ModelServiceImpl 中的分页查询逻辑,支持正常分页和不分页两种模式 - 新增 PagedResponse 通用分页响应类,包含总数、页码、大小和记录等字段pull/57/head
6 changed files with 77 additions and 7 deletions
@ -0,0 +1,40 @@ |
|||
package cn.iocoder.yudao.framework.common.pojo; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.List; |
|||
|
|||
@Schema(description = "分页结果") |
|||
@Data |
|||
@Builder |
|||
public class PagedResponse<T> { |
|||
|
|||
@Schema(description = "总条数") |
|||
private long total; |
|||
|
|||
@Schema(description = "当前页码,从 1 开始") |
|||
private int current; |
|||
|
|||
@Schema(description = "分页大小") |
|||
private int size; |
|||
|
|||
@Schema(description = "当前页数据") |
|||
private List<T> records; |
|||
|
|||
@Schema(description = "总页数") |
|||
private int pages; |
|||
|
|||
public static <T> PagedResponse<T> of(long total, int current, int size, List<T> records) { |
|||
int pages = size <= 0 ? 0 : (int) ((total + size - 1) / size); |
|||
return PagedResponse.<T>builder() |
|||
.total(total) |
|||
.current(current) |
|||
.size(size) |
|||
.pages(pages) |
|||
.records(records == null ? Collections.emptyList() : records) |
|||
.build(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue