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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
import com.oqpo.api.entity.stinfo.StoreItemUnitEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.util.List;
import java.util.stream.Collectors;


@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class PchReqRejectTargetResponse {

    @ApiModelProperty(value = "그리드 페이지")
    private Integer gridPage;

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

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

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


    public static PchReqRejectTargetResponse toDTO(List<PchReqDtlPtclEntity> entities) {
        if (entities == null) return null;

        return PchReqRejectTargetResponse.builder()
                .gridPage(0)
                .gridRecords(entities.size())
                .gridTotal(0)
                .gridRows(entities.stream()
                        .map(m -> PchReqInfo.builder()
                                .pchReqUnqNo(m.getPchReqUnqNo())
                                .pchReqDtlNo(m.getPchReqDtlNo())
                                .itemId(m.getItemId())
                                .itemNm(m.getItemNm())
                                .pchReqQty(m.getPchReqQty())
                                .pchReqAmt(m.getPchReqAmt())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }


    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class PchReqInfo {

        @ApiModelProperty(value = "구매요청번호")
        private String pchReqUnqNo;

        @ApiModelProperty(value = "구매요청상세항번")
        private String pchReqDtlNo;

        @ApiModelProperty(value = "품목아이디")
        private String itemId;

        @ApiModelProperty(value = "품목명")
        private String itemNm;

        @ApiModelProperty(value = "구매요청수량")
        private Integer pchReqQty;

        @ApiModelProperty(value = "구매요청금액")
        private Integer pchReqAmt;

    }






}
