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

import com.fasterxml.jackson.annotation.JsonInclude;
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.stockmng.StckMgntBaseInfoEntity;
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 PchOrdWhsQtyResponse {

    @ApiModelProperty(value = "출고가능수량 리스트") private List<WhsPassOtyInfo> whsPassList;


    public static PchOrdWhsQtyResponse toDTO( List<StckMgntBaseInfoEntity> passQtyList ) {
        if (passQtyList == null) return null;
        return PchOrdWhsQtyResponse.builder()
                .whsPassList(passQtyList.stream()
                        .map(m -> WhsPassOtyInfo.builder()
                                .itemId(m.getItemId())
                                .whsPassQty(m.getWhsPassQty())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }


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

        @ApiModelProperty(value = "품목아이디")
        private String itemId;
        @ApiModelProperty(value = "출고가능수량")
        private Integer whsPassQty;

    }
}
