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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.oper.MemberEntity;
import com.oqpo.api.web.dto.response.pomng.pchReq.PchReqRejectTargetResponse;
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 LogInBrandListResponse {

    @ApiModelProperty(value = "그리드 리스트")
    private List<LogInBrandListResponse.LoginBrandInfo> gridRows;

    public static LogInBrandListResponse toDTO(List<MemberEntity> entities) {
        if (entities == null) return null;
        return LogInBrandListResponse.builder()
                .gridRows(entities.stream()
                        .map(m -> LogInBrandListResponse.LoginBrandInfo.builder()
                                .brandId(m.getBrandId())
                                .brandNm(m.getBrandNm())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }

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

        @ApiModelProperty(value = "브랜드아이디")
        private String brandId;

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

    }
}
