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

import com.oqpo.api.entity.pomng.PchReqDtlPtclEntity;
import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

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

@Getter
@Setter
public class StockMngPassQtyGridRequest {

    @ApiModelProperty(value = "CRUD")
    private String viewCd;

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

    @NotBlank
    @ApiModelProperty(value = "창고아이디")
    private String whsId;

    @NotBlank
    @ApiModelProperty(value = "location")
    private String location;

    @ApiModelProperty(value = "수정 품목리스트")
    private List<StockMngPassQtyGridRequest.PassQtyItemList> gridUpdateData;

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

        gridData.forEach(x -> {
            StckMgntBaseInfoEntity entity = new StckMgntBaseInfoEntity();
            entity.setItemId(x.getItemId());
            entities.add(entity);
        });
        return entities;
    }

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

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

    }
}
