package com.reading.platform.dto.response;

import com.reading.platform.entity.Lesson;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * 分页响应（通用）
 */
@Data
@Schema(description = "分页响应")
public class CommonPageResponse<T> {

    @Schema(description = "数据列表")
    private List<T> items;

    @Schema(description = "总数", example = "100")
    private Long total;

    @Schema(description = "当前页码", example = "1")
    private Integer page;

    @Schema(description = "每页大小", example = "10")
    private Integer pageSize;

    public static <T> CommonPageResponse<T> of(List<T> items, Long total, Integer page, Integer pageSize) {
        CommonPageResponse<T> response = new CommonPageResponse<>();
        response.setItems(items);
        response.setTotal(total);
        response.setPage(page);
        response.setPageSize(pageSize);
        return response;
    }
}
