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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
import com.oqpo.api.entity.oper.UserMngEntity;
import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
import com.oqpo.api.entity.stinfo.BrandEntity;
import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
import com.oqpo.api.web.dto.response.pomng.pchOrd.SpplyPchOdrInfoResponse;
import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqInitInfoResponse;
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 StockMngPassqtyListResponse {

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

    @ApiModelProperty(value = "품목 출고 가능수량 정보")
    private List<StockMngPassqtyListResponse.ItemPassQtyInfo> passList;

    public static StockMngPassqtyListResponse toDTO(List<StckMgntBaseInfoEntity>  dtlEntityList) {
        if (dtlEntityList == null) return null;
        return StockMngPassqtyListResponse.builder()
                .viewCd("R")
                .passList(dtlEntityList.stream()
                        .map(m -> StockMngPassqtyListResponse.ItemPassQtyInfo.builder()
                                .itemId(m.getItemId() == null ? "" : m.getItemId())
                                .whsPassQty(m.getWhsPassQty() == null ? 0 : m.getWhsPassQty())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }

    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class ItemPassQtyInfo {
        @ApiModelProperty(value = "품목아이디")
        private String itemId;

        @ApiModelProperty(value = "출고가능수량")
        private Integer whsPassQty;
    }

}
