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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.oper.NticeEntity;
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)
public class AfflBrandSearchResponse {

    @ApiModelProperty(value = "브랜드리스트")
    private List<SearchBrand> searchList;


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


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

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