package com.qmth.paper.library.common.enums;

import java.util.Objects;

/**
 * @Description: 上传文件类型
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/15
 */
public enum UploadFileEnum {
    FILE("file", "local"),

    DOWNLOAD("download", "local"),
    CUT("cut", "local"),

    IMAGE("image", "local"),

    PDF("pdf", "local");



    private String prefix;
    private String fssType;

    UploadFileEnum(String prefix, String fssType) {
        this.prefix = prefix;
        this.fssType = fssType;
    }

    public String getPrefix() {
        return prefix;
    }

    public String getFssType() {
        return fssType;
    }


    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToName(String title) {
        for (UploadFileEnum e : UploadFileEnum.values()) {
            if (Objects.equals(title, e.getPrefix())) {
                return e.name();
            }
        }
        return null;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToFssType(String title) {
        for (UploadFileEnum e : UploadFileEnum.values()) {
            if (Objects.equals(title.toLowerCase(), e.getPrefix())) {
                return e.getFssType();
            }
        }
        return null;
    }
}
