package com.erp.report.export.dto;

/**
 * 导出格式枚举
 */
public enum ExportFormat {
    CSV("csv", "text/csv; charset=UTF-8", ".csv"),
    XLSX("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx"),
    PDF("pdf", "application/pdf", ".pdf");

    private final String code;
    private final String contentType;
    private final String extension;

    ExportFormat(String code, String contentType, String extension) {
        this.code = code;
        this.contentType = contentType;
        this.extension = extension;
    }

    public String getCode() {
        return code;
    }

    public String getContentType() {
        return contentType;
    }

    public String getExtension() {
        return extension;
    }

    public static ExportFormat fromCode(String code) {
        for (ExportFormat format : values()) {
            if (format.code.equalsIgnoreCase(code)) {
                return format;
            }
        }
        return CSV;
    }
}
