package com.sonic.shark.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * @description: 文件类型枚举类
 * @author: code
 **/
public enum ContentTypeEnum {

    BMP(".bmp", "image/bmp"),
    GIF(".gif", "image/gif"),
    JPEG(".jpeg", "image/jpeg"),
    JPG(".jpg", "image/jpeg"),
    PNG(".png", "image/jpeg"),
    HTML(".html", "text/html"),
    TXT(".txt", "text/plain"),
    VSD(".vsd", "application/vnd.visio"),
    PPTX(".pptx", "application/vnd.ms-powerpoint"),
    PPT(".ppt", "application/vnd.ms-powerpoint"),
    DOCX(".docx", "application/msword"),
    DOC(".doc", "application/msword"),
    XLSX(".xlsx", "application/vnd.ms-excel"),
    XLS(".xls", "application/vnd.ms-excel"),
    CSV(".csv", "text/csv"),
    XML(".xml", "text/xml"),
    PDF(".pdf", "application/pdf"),
    APK(".apk",	"application/vnd.android.package-archive"),
    IPA(".ipa", "application/vnd.iphone"),
    UNKNOWN(".", "application/octet-stream"),

    MP4(".mp4", "video/mp4"),
    GP3(".3gp", "video/3gpp"),
    AVI(".avi", "video/x-msvideo"),
    WMV(".wmv", "video/x-ms-wmv"),
    RM(".rm", "application/vnd.rn-realmedia"),
    SWF(".swf", "application/x-shockwave-flash"),
    MOV(".mov", "video/quicktime"),
    M4V(".m4v", "video/x-m4v"),
    FLV(".flv", "video/x-flv"),
    DIF(".dif", "video/x-dv"),
    DV(".dv", "video/x-dv"),
    M4U(".m4u", "video/vnd.mpegurl"),
    MOVIE(".movie", "video/x-sgi-movie"),
    MPE(".mpe", "video/mpeg"),
    MPEG(".mpeg", "video/mpeg"),
    MPG(".mpg", "video/mpeg"),
    MXU(".mxu", "video/vnd.mpegurl"),
    OGV(".ogv", "video/ogv"),
    QT(".qt", "video/quicktime"),
    WEBM(".webm", "video/webm"),
    MP3(".mp3", "audio/mpeg"),


    ;

    private String suffix;

    private String type;

    ContentTypeEnum(String suffix, String type) {
        this.suffix = suffix;
        this.type = type;
    }

    public String getSuffix() {
        return suffix;
    }

    public String getType() {
        return type;
    }

    public static String getContentType(String suffix) {
        if(StringUtils.isEmpty(suffix)) {
            return null;
        }
        for (ContentTypeEnum contentTypeEnum: ContentTypeEnum.values()) {
            if(StringUtils.equalsIgnoreCase(suffix, contentTypeEnum.suffix)) {
                return contentTypeEnum.type;
            }
        }
        return null;
    }

}
