package com.smppw.modaq.domain.dto;

import cn.hutool.core.io.FileUtil;
import lombok.Getter;
import lombok.Setter;

import java.io.File;

@Getter
public class EmailZipFileDTO {
    private final String emailTitle;
    private final String filename;
    private final String filepath;
    private final long fileSize;
    @Setter
    private Integer emailType;

    private final String extName;

    public EmailZipFileDTO(String emailTitle, String filepath, Integer emailType) {
        File file = FileUtil.file(filepath);
        this.emailTitle = emailTitle;
        this.filepath = filepath;
        this.emailType = emailType;
        this.fileSize = FileUtil.size(file);
        this.filename = FileUtil.getName(file);
        this.extName = FileUtil.extName(file);
    }

//    public EmailZipFileDTO(String emailTitle, String filepath, String filename, int fileSize, Integer emailType) {
//        this.emailTitle = emailTitle;
//        this.filepath = filepath;
//        this.emailType = emailType;
//        this.filename = filename;
//        this.fileSize = fileSize;
//        this.extName = FileUtil.extName(filepath);
//    }

    public EmailZipFileDTO(String emailTitle, EmailContentInfoDTO emailDto) {
        this.emailTitle = emailTitle;
        this.filepath = emailDto.getFilePath();
        this.emailType = emailDto.getEmailType();
        this.filename = emailDto.getFileName();
        this.fileSize = emailDto.getFileSize();
        this.extName = FileUtil.extName(filepath);
    }

    public EmailZipFileDTO(String emailTitle, UploadReportParams.ReportInfo uploadReportInfo) {
        this.emailTitle = emailTitle;
        this.filepath = uploadReportInfo.getReportPath();
        this.emailType = uploadReportInfo.getReportType();
        this.filename = uploadReportInfo.getReportName();
        this.fileSize = FileUtil.size(FileUtil.file(this.filepath));
        this.extName = FileUtil.extName(filepath);
    }

    @Override
    public String toString() {
        return "EmailZipFileDTO{" +
                "emailTitle='" + emailTitle + '\'' +
                ", filename='" + filename + '\'' +
                ", filepath='" + filepath + '\'' +
                ", emailType=" + emailType +
                ", fileSize=" + fileSize +
                '}';
    }
}
