package com.oqpo.api.web.dto.request.pomng.pchOrd;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
import com.oqpo.api.entity.pomng.PchReqBaseInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class SavePchSteamlineOrdRequest {
    @NotBlank
    @ApiModelProperty(value = "CRUD")
    private String viewCd;

    @NotBlank
    @ApiModelProperty(value = "브랜드아이디")
    private String brandId;

    @ApiModelProperty(value = "등록 구매요청리스트")
    private List<SaveSteamlinePoItemList> gridInsertData;


    public List<PchReqBaseInfoEntity> toCodeEntities(List<SaveSteamlinePoItemList> gridData) {
        List<PchReqBaseInfoEntity> entities = new ArrayList<>();
        if (gridData == null || gridData.size() == 0)
            return entities;

        gridData.forEach(x -> {
            PchReqBaseInfoEntity entity = new PchReqBaseInfoEntity();
            entity.setPchReqUnqNo(x.getPchReqUnqNo());
            entities.add(entity);
        });
        return entities;
    }

    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class SaveSteamlinePoItemList {
        @ApiModelProperty(value = "구매요청고유번호") private String pchReqUnqNo;
    }
}
