package com.zioinfo.signage.uiws.schedule.dto;

import com.zioinfo.signage.uiws.schedule.model.UiwsAttach;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

import java.util.List;

/**
 * 일정·일지·첨부(모듈 02) DTO. 원본 com.urp.uiws.schedule.dto.* 이식(shape 동일).
 */
public final class ScheduleDtos {

    private ScheduleDtos() {
    }

    public record ScheduleDto(
            Long scheduleId,
            String scheType,
            String title,
            String scheGubunCd,
            String importanceCd,
            String startDt,
            String endDt,
            String ownerId,
            String deptId
    ) {
    }

    public record ScheduleDetailDto(
            Long scheduleId,
            String scheType,
            String title,
            String scheGubunCd,
            String importanceCd,
            String startDt,
            String endDt,
            String ownerId,
            String deptId,
            String content,
            String chargerId,
            String chargerNm,
            List<AttachmentDto> attachments
    ) {
    }

    public record ScheduleSaveDto(
            @NotBlank @Pattern(regexp = "PERSONAL|DEPT") String scheType,
            @NotBlank String title,
            String scheGubunCd,
            String importanceCd,
            @NotNull String startDt,
            @NotNull String endDt,
            String content,
            String deptId,
            String chargerId,
            List<Long> attachmentIds
    ) {
    }

    public record DiaryDto(
            Long diaryId,
            String title,
            String writerNm,
            String diaryDate,
            Long scheduleId
    ) {
    }

    public record DiaryDetailDto(
            Long diaryId,
            String title,
            String writerNm,
            String diaryDate,
            Long scheduleId,
            String content,
            List<AttachmentDto> attachments
    ) {
    }

    public record DiarySaveDto(
            @NotBlank String title,
            String content,
            Long scheduleId,
            String diaryDate,
            List<Long> attachmentIds
    ) {
    }

    public record AttachmentDto(
            Long attachId,
            String refType,
            Long refId,
            String fileNm,
            Long fileSize
    ) {
        public static AttachmentDto from(UiwsAttach a) {
            return new AttachmentDto(a.getAttachId(), a.getRefType(), a.getRefId(), a.getFileNm(), a.getFileSize());
        }
    }

    /** 페이지 래퍼(content/totalElements/page/size/totalPages). */
    public record DiaryPage(List<DiaryDto> content, long totalElements, int page, int size, int totalPages) {
    }

    public record SchedulePage(List<ScheduleDto> content, long totalElements, int page, int size, int totalPages) {
    }
}
