package com.oqpo.api.web.dto.response.stinfo.itemUnit;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.stinfo.ItemUnitEntity;
import com.oqpo.api.entity.stockmng.WhsMgntBaseInfoEntity;
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 StroeWhsListResponse {
    @ApiModelProperty(value = "창고리스트")
    private List<StroeWhsListResponse.WishListClass> whsList;

    public static StroeWhsListResponse toDTO(List<WhsMgntBaseInfoEntity> entities) {
        if (entities == null) return null;
        return StroeWhsListResponse.builder()
                .whsList(entities.stream()
                        .map(m -> WishListClass.builder()
                                .whsId(m.getWhsId())
                                .whsNm(m.getWhsNm())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }

    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class WishListClass {
        @ApiModelProperty(value = "창고아이디")
        private String whsId;

        @ApiModelProperty(value = "창고명")
        private String whsNm;

    }
}
