package com.heyu.api.data.constants;


import java.util.Arrays;
import java.util.List;

public enum MimeTypeEnums {
    // 1. 文本类型 (text/*)
    text_plain(".txt", "text/plain", "纯文本文件"),
    text_html(".html", "text/html", "HTML文件"),
    text_css(".css", "text/css", "CSS样式表"),
    text_javascript(".js", "text/javascript", "JavaScript文件"),
    text_csv(".csv", "text/csv", "逗号分隔值文件"),
    // 2. 图片类型 (image/*)
    image_jpeg(".jpeg", "image/jpeg", "JPEG格式图片"),
    image_jpg(".jpg", "image/jpeg", "JPEG格式图片"),
    image_png(".png", "image/png", "PNG格式图片"),
    image_gif(".gif", "image/gif", "GIF格式图片"),
    image_webp(".webp", "image/webp", "WebP格式图片"),
    image_svg_xml(".svg", "image/svg+xml", "SVG矢量图"),
    image_bmp(".bmp", "image/bmp", "BMP格式图片"),
    // 3. 音频类型 (audio/*)
    audio_mid(".mid", "audio/midi", "MIDI音频文件"),
    audio_midi(".midi", "audio/midi", "MIDI音频文件"),
    audio_mpeg(".mp3", "audio/mpeg", "MP3音频文件"),
    audio_ogg(".ogg", "audio/ogg", "OGG音频文件"),
    audio_oga(".oga", "audio/ogg", "OGG音频文件"),
    audio_wav(".wav", "audio/wav", "WAV音频文件"),
    audio_weba(".weba", "audio/webm", "WebM音频文件"),
    // 4. 视频类型 (video/*)
    video_mp4(".mp4", "video/mp4", "MP4视频文件"),
    video_mpeg(".mpeg", "video/mpeg", "MPEG视频文件"),
    video_mpg(".mpg", "video/mpeg", "MPEG视频文件"),
    video_ogv(".ogv", "video/ogg", "OGG视频文件"),
    video_webm(".webm", "video/webm", "WebM视频文件"),
    video_x_msvideo(".avi", "video/x-msvideo", "AVI视频文件"),

    // 5. 应用类型 (application/*)
    application_json(".json", "application/json", "JSON数据"),
    application_xml(".xml", "application/xml", "XML数据"),
    application_pdf(".pdf", "application/pdf", "PDF文件"),
    application_zip(".zip", "application/zip", "ZIP压缩文件"),
    application_x_www_form_urlencoded(".xxxxxx", "application/x-www-form-urlencoded", "URL编码的表单数据"),
    application_octet_stream(".application/octet-stream", "application/octet-stream", "二进制数据流（通常用于下载文件）"),
    application_vnd_ms_excel(".xls", "application/vnd.ms-excel", "Excel文件"),
    application_xlsx(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel文件"),
    application_ppt(".ppt", "application/vnd.ms-powerpoint", "PowerPoint文件"),
    application_doc(".doc", "application/msword", "Word文档"),
    application_document(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word文档"),
    // 6. 压缩文件类型
    application_gzip(".gz", "application/gzip", "GZIP压缩文件"),
    application_rar(".rar", "application/x-rar-compressed", "RAR压缩文件"),
    application_7z(".php", "application/x-7z-compressed", "7-Zip压缩文件"),
    application_php(".7z", "application/x-httpd-php", "PHP文件"),
    ;


    public final static List<String> videoSuffixList  = Arrays.asList("mp4","mpeg","mpg","ogv","webm","avi");

    private String suffix;

    private String contentType;

    private String remark;

    MimeTypeEnums(String suffix, String contentType, String remark) {
        this.suffix = suffix;
        this.contentType = contentType;
        this.remark = remark;
    }

    public static String getContentType(String suffix) {
        for(MimeTypeEnums mimeTypeEnums: MimeTypeEnums.values()) {
            if(mimeTypeEnums.suffix.equals(suffix)) {
                return mimeTypeEnums.contentType;
            }
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(getContentType(".mpeg"));
    }




    public static boolean suportVideo(String videoSuffix) {
        return videoSuffix.contains(videoSuffix.toLowerCase());
    }
}
