package com.oqpo.api.web.dto.response.oper.pop;

import com.fasterxml.jackson.annotation.JsonInclude;

import com.oqpo.api.entity.oper.PopEntity;
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 LoginPopInfoResponse {

    @ApiModelProperty(value = "팝업 리스트")
    private List<PopInfo> popList;

    //public static LoginPopInfoResponse toDTO(List<PopEntity> popList) {
     public static LoginPopInfoResponse toDTO(List<PopEntity> popList) {
        return LoginPopInfoResponse.builder()
                .popList(popList.stream()
                        .map(m -> PopInfo.builder()
                                .popNo(m.getPopNo())
                                .viewTargetCd(m.getViewTargetCd())
                                .menuId(m.getMenu() == null ? "" : m.getMenu().getMenuId() == null ? "" : m.getMenu().getMenuId() )
                                .popNm(m.getPopNm())
                                .popWidth(m.getPopWidth())
                                .popHeight(m.getPopHeight())
                                .build())
                        .collect(Collectors.toList()))
                .build();
    }



    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class PopInfo {
        @ApiModelProperty(value = "팝업번호")
        private String popNo ;

        @ApiModelProperty(value = "팝업오픈구분")
        private String viewTargetCd;

        @ApiModelProperty(value = "메뉴ID")
        private String menuId;

        @ApiModelProperty(value = "팝업명")
        private String popNm;

        @ApiModelProperty(value = "팝업width")
        private Integer popWidth;

        @ApiModelProperty(value = "팝업Height")
        private Integer popHeight;
    }
}
