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

import incheon.ags.ias.authrtAplyMng.vo.AuthrtAplyMngVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@Getter
@Setter
@ToString
public class AuthrtAplyMngRequestDTO {

    @Schema(description = "역할 ID", example = "ROLE_ADMIN", required = true)
    @NotBlank(message = "역할 ID는 필수 항목입니다.")
    private String roleCd;

    @Schema(description = "시스템 코드", example = "AGS", required = true)
    private String sysCd;

    @Schema(description = "사용자 ID", example = "admin", required = true)
    @NotBlank(message = "사용자 ID는 필수 항목입니다.")
    private String userId;

    @Schema(description = "현재 접속한 사용자 ID", example = "admin")
    private String nowUserId;

    @Schema(description = "첨부파일 ID", example = "01K7ZFMTW3EWQX89YSF62VQZX9")
    private String atchFileId;

    @Schema(description = "승인할 신청 번호 목록", example = "[1, 2, 3]")
    private List<Long> aplySnList;

    @Schema(description = "승인할 시스템 코드 목록", example = "[AGS, CMS, RES]")
    private List<String> sysCdList;

    @Schema(description = "승인할 신청 역할 목록", example = "[ROLE_SUPER_ADMIN, ROLE_WORK_USER99]")
    private List<String> roleCdList;

    @Schema(description = "전체 개수")
    private int totalCount;

    @Schema(description = "신청 상태 코드", example = "APRV")
    private String aplyStcd;

    @Schema(description = "신청자 사용자 ID", example = "user01")
    private String aplcnUserId;

    @Schema(description = "신청 시작일", example = "2025-01-01")
    private String aplyBgngYmd;

    @Schema(description = "신청 종료일", example = "2025-12-31")
    private String aplyEndYmd;

    @Schema(description = "검토 의견 내용", example = "승인합니다")
    private String rvwOpnnCn;

    /**
     * DTO를 VO로 변환
     * MenuRequestDTO.toEntity() 패턴을 따름
     */
    public AuthrtAplyMngVO toEntity() {
        AuthrtAplyMngVO vo = new AuthrtAplyMngVO();
        vo.setRoleCd(this.roleCd);
        vo.setSysCd(this.sysCd);
        vo.setUserId(this.userId);
        vo.setNowUserId(this.nowUserId);
        vo.setAtchFileId(this.atchFileId);
        vo.setTotalCount(this.totalCount);
        vo.setAplyStcd(this.aplyStcd);
        vo.setAplcnUserId(this.aplcnUserId);
        vo.setAplyBgngYmd(this.aplyBgngYmd);
        vo.setAplyEndYmd(this.aplyEndYmd);
        vo.setRvwOpnnCn(this.rvwOpnnCn);
        return vo;
    }
}
