package org.qinan.safetyeval.client.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 通用分页响应体
 * <p>
 * 与 GBS PageResponse 格式保持一致，当 GBS 依赖可用时可平滑切换。
 * </p>
 *
 * @author safety-eval
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PageResponse<T> extends SingleResponse<List<T>> {

    @ApiModelProperty(value = "总条数")
    private Long total;

    public static <T> PageResponse<T> of(List<T> list, Long total) {
        PageResponse<T> response = new PageResponse<>();
        response.setSuccess(true);
        response.setCode("0");
        response.setData(list);
        response.setTotal(total);
        return response;
    }
}
