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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.stinfo.BrandEntity;
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) //null 값 전송
public class BsnsBrandListResponse {
    @ApiModelProperty(value = "조회리스트")
    private List<BrandInfo> brandList;

    public static BsnsBrandListResponse toDTO(List<BrandEntity> entities) {
        if (entities == null) return null;
        return BsnsBrandListResponse.builder()
                .brandList(entities.stream()
                        .map(m -> BrandInfo.builder()
                                .brandId(m.getBrandId())
                                .brandNm(m.getBrandNm())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }

    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class BrandInfo {
        @ApiModelProperty(value = "브랜드아이디")
        private String brandId;

        @ApiModelProperty(value = "브랜드명")
        private String brandNm;
    }
}
