package com.oqpo.api.web.dto.request.ifmng;

import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
import com.oqpo.api.entity.stockmng.BoSaleInfoEntity;
import com.oqpo.api.web.dto.request.pomng.pchReq.SavePchReqlRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

@Getter
@Setter
public class BoSaleStoreInfoRequest {

    @NotBlank
    @ApiModelProperty(value = "오더퀸 브랜드코드")
    private String brandCd;

    @NotBlank
    @ApiModelProperty(value = "오더퀸 매장번호")
    private String storeNo;

    @NotBlank
    @ApiModelProperty(value = "매출일자")
    private String saleDt;

    @ApiModelProperty(value = "판매품목리스트")
    private List<BoSaleStoreInfoRequest.SaleList> saleList;

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

        gridData.forEach(x -> {
            BoSaleInfoEntity entity = new BoSaleInfoEntity();
            entity.setMenuCd(x.getMenuCd());
            entity.setSaleCnt(x.getSaleCnt());
            entities.add(entity);
        });
        return entities;
    }

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

        @NotBlank
        @ApiModelProperty(value = "오더퀸메뉴코드")
        private String menuCd;

        @NotBlank
        @ApiModelProperty(value = "판매수량")
        private int saleCnt;
    }
}
