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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.oper.AuthEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class AuthInfoResponse {

    @ApiModelProperty(value = "권한코드")
    private String authNo;

    @ApiModelProperty(value = "권한명")
    private String authNm;

    @ApiModelProperty(value = "권한타입코드")
    private String authTpCd;

    @ApiModelProperty(value = "권한타임명")
    private String authTpNm;

    @ApiModelProperty(value = "상위메뉴번호")
    private Integer topMenuNo;

    @ApiModelProperty(value = "상위메뉴명")
    private String topMenuNm;

    @ApiModelProperty(value = "사용여부")
    private String useYn;

    public static AuthInfoResponse toDTO(AuthEntity entity) {
        if (entity == null) return null;
        return AuthInfoResponse.builder()
                .authNo(entity.getAuthNo())
                .authNm(entity.getAuthNm())
                .authTpCd(entity.getAuthTpCd())
                .authTpNm(entity.getAuthTpNm())
                .topMenuNo(entity.getTopMenuNo())
                .topMenuNm(entity.getTopMenuNm())
                .useYn(entity.getUseYn())
                .build();
    }
}
