package com.smppw.modaq.domain.dto;

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

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

    private final String extName;

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

    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);
    }

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