package com.qmth.teachcloud.exchange.common.enums;

import java.util.Objects;

/**
 * @Description: 上传文件类型
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/15
 */
public enum UploadFileEnum {
    /**
     * 客户端
     */
    PAPER("paper","private"),
    /**
     * 系统相关
     */
    UPLOAD("upload","private"),
    /**
     * 导入导出
     */
    FILE("file","public"),

    PDF("pdf","private"),

    HTML("html","private");

    private String title;
    private String fssType;

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

    public String getTitle() {
        return title;
    }

    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.getTitle())) {
                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.getTitle())) {
                return e.getFssType();
            }
        }
        return null;
    }
}
