package com.kamco.cd.kamcoback.mapsheet.dto;

import com.kamco.cd.kamcoback.common.utils.FIleChecker;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

public class FileDto {

  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  public static class SrchFoldersDto {
    @Schema(description = "디렉토리경로(ROOT:/app/original-images)", example = "")
    @NotNull
    private String dirPath;
  }

  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  public static class SrchFilesDto {
    @Schema(description = "디렉토리경로", example = "D:\\kamco\\2022\\캠코_2021_2022_34602060_D1")
    @NotNull
    private String dirPath;

    @Schema(description = "전체(*), cpg,dbf,geojson등", example = "*")
    @NotNull
    private String extension;

    @Schema(description = "파일명(name), 최종수정일(date)", example = "name")
    @NotNull
    private String sortType;

    @Schema(description = "파일시작위치", example = "1")
    @NotNull
    private Integer startPos;

    @Schema(description = "파일종료위치", example = "100")
    @NotNull
    private Integer endPos;
  }

  @Getter
  @Setter
  @NoArgsConstructor
  @AllArgsConstructor
  public static class SrchFilesDepthDto extends SrchFilesDto {
    @Schema(description = "최대폴더Depth", example = "5")
    @NotNull
    private Integer maxDepth;
  }

  @Schema(name = "FolderDto", description = "폴더 정보")
  @Getter
  public static class FolderDto {
    private final String folderNm;
    private final String parentFolderNm;
    private final String parentPath;
    private final String fullPath;
    private final int depth;
    private final long childCnt;
    private final String lastModified;
    private final Boolean isValid;

    public FolderDto(
        String folderNm,
        String parentFolderNm,
        String parentPath,
        String fullPath,
        int depth,
        long childCnt,
        String lastModified,
        Boolean isValid) {
      this.folderNm = folderNm;
      this.parentFolderNm = parentFolderNm;
      this.parentPath = parentPath;
      this.fullPath = fullPath;
      this.depth = depth;
      this.childCnt = childCnt;
      this.lastModified = lastModified;
      this.isValid = isValid;
    }
  }

  @Schema(name = "FoldersDto", description = "폴더목록 정보")
  @Getter
  public static class FoldersDto {
    private final String dirPath;
    private final int folderTotCnt;
    private final int folderErrTotCnt;
    private final List<FolderDto> folders;

    public FoldersDto(
        String dirPath, int folderTotCnt, int folderErrTotCnt, List<FolderDto> folders) {

      this.dirPath = dirPath;
      this.folderTotCnt = folderTotCnt;
      this.folderErrTotCnt = folderErrTotCnt;
      this.folders = folders;
    }
  }

  @Schema(name = "File Basic", description = "파일 기본 정보")
  @Getter
  public static class Basic {

    private final String fileNm;
    private final String parentFolderNm;
    private final String parentPath;
    private final String fullPath;
    private final String extension;
    private final long fileSize;
    private final String lastModified;

    public Basic(
        String fileNm,
        String parentFolderNm,
        String parentPath,
        String fullPath,
        String extension,
        long fileSize,
        String lastModified) {
      this.fileNm = fileNm;
      this.parentFolderNm = parentFolderNm;
      this.parentPath = parentPath;
      this.fullPath = fullPath;
      this.extension = extension;
      this.fileSize = fileSize;
      this.lastModified = lastModified;
    }
  }

  @Schema(name = "FilesDto", description = "파일 목록 정보")
  @Getter
  public static class FilesDto {
    private final String dirPath;
    private final int fileTotCnt;
    private final long fileTotSize;
    private final List<FIleChecker.Basic> files;

    public FilesDto(
        String dirPath, int fileTotCnt, long fileTotSize, List<FIleChecker.Basic> files) {

      this.dirPath = dirPath;
      this.fileTotCnt = fileTotCnt;
      this.fileTotSize = fileTotSize;
      this.files = files;
    }
  }
}
