package com.qmth.themis.business.enums;

import java.util.Objects;

/**
 * @Description: 上传文件类型
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/15
 */
public enum UploadFileEnum {
    /**
     * 客户端
     */
    client(0),
    /**
     * 学生底照
     */
    base_photo(1),
    /**
     * 系统相关
     */
    upload(2),
    /**
     * 导入导出&试卷
     */
    file(3),
    /**
     * 前端资源
     */
    frontend(4),

    /**
     * 移动端
     */
    app(5);

    private int id;

    private UploadFileEnum(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    /**
     * 状态转换 toName
     *
     * @param value
     * @return
     */
    public static String convertToName(int value) {
        for (UploadFileEnum e : UploadFileEnum.values()) {
            if (value == e.getId()) {
                return e.name();
            }
        }
        return null;
    }

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