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

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 文件存储设置
 */
public enum StoreTypeEnum {
    COURSE("按课程存储"),
    ROOM("按考场存储"),

    CLASS("按班级存储");

    private String desc;

    private StoreTypeEnum(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

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

    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<EnumResult>();
        for (StoreTypeEnum value : StoreTypeEnum.values()) {
            EnumResult result = new EnumResult();
            result.setName(value.name());
            result.setOrdinal(value.ordinal());
            result.setCode(null);
            result.setDesc(value.getDesc());
            list.add(result);
        }
        return list;
    }

}
