package com.oqpo.api.web.dto.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.List;

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class GridResponse {
    @ApiModelProperty(value = "그리드 페이지")
    private Integer gridPage;

    @ApiModelProperty(value = "그리드 전체 페이지 수")
    private Integer gridTotal;

    @ApiModelProperty(value = "그리드 전체 목록 수")
    private Integer gridRecords;

    @ApiModelProperty(value = "그리드 리스트")
    private List<Object> gridRows;

    public static GridResponse toDTO(int gridPage, int gridTotal, int gridRecords, List<Object> gridRows) {
        if (gridRows == null) return null;
        return GridResponse.builder()
                .gridPage(gridPage)
                .gridTotal(gridTotal)
                .gridRecords(gridRecords)
                .gridRows(gridRows)
                .build();
    }
}
