package incheon.ags.ias.menu.web.dto;

import incheon.ags.ias.menu.vo.MenuVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import java.sql.Timestamp;

@Getter
@Setter
public class MenuRequestDTO {

    @Schema(description = "시스템 유형", example = "SYS01", required = true)
    @NotBlank(message = "시스템 유형은 필수 항목입니다.")
    private String sysCd;

    @Schema(description = "메뉴 ID", example = "MENU001", required = true)
    private String menuCd;

    @Schema(description = "메뉴 명", example = "게시판 설정", required = true)
    @NotBlank(message = "메뉴 이름은 필수 항목입니다.")
    private String menuNm;

    @Schema(description = "상위 메뉴 ID", example = "MENU001")
    private String upMenuCd;

    @Schema(description = "메뉴 순서", example = "3")
    private int menuSortSeq;

    @Schema(description = "관련 이미지 경로", example = "3")
    private String thmbPathNm;

    @Schema(description = "관련 이미지 명", example = "게시판 아이콘")
    private String thmbNm;

    @Schema(description = "URL", example = "/admin/example")
    private String menuUrlAddr;

    @Schema(description = "기타 URL 목록 (콤마 구분)", example = "/admin/example,/admin/detail,/admin/register")
    private String menuEtcUrlAddr;

    @Schema(description = "변경 메뉴 ID", example = "MENU001")
    private String updtMenuCd;

    @Schema(description = "상위 메뉴 명", example = "홈")
    private String upMenuNm;

    @Schema(description = "변경 상위 메뉴 ID", example = "MENU001")
    private String newUpperMenuCd;

    private String frstRegId;
    private Timestamp frstRegDt;
    private String lastMdfcnId;
    private Timestamp lastMdfcnDt;

    public MenuVO toEntity() {
        MenuVO vo = new MenuVO();
        vo.setMenuCd(this.menuCd);
        vo.setMenuNm(this.menuNm);
        vo.setUpMenuCd(this.upMenuCd);
        vo.setNewUpperMenuCd(this.newUpperMenuCd);
        vo.setUpMenuNm(this.upMenuNm);
        vo.setMenuSortSeq(this.menuSortSeq);
        vo.setIconPathNm(this.thmbPathNm);
        vo.setMenuUrlAddr(this.menuUrlAddr);
        vo.setMenuEtcUrlAddr(this.menuEtcUrlAddr);
        vo.setSysCd(this.sysCd);
        vo.setFrstRegId(this.frstRegId);
        vo.setLastMdfcnId(this.lastMdfcnId);
        vo.setLastMdfcnDt(this.lastMdfcnDt);
        vo.setFrstRegDt(this.frstRegDt);
        return vo;
    }
}
