package com.qmth.distributed.print.business.enums;

import com.qmth.teachcloud.common.enums.EnumResult;

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

/**
 * 试卷备份方式
 * @Date: 2021/3/23.
 */
public enum BackupMethodEnum {

    PLACE("按考点"),
    ROOM("按考场");

    BackupMethodEnum(String desc) {
        this.desc = desc;
    }

    private String desc;

    public String getDesc() {
        return desc;
    }

    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<EnumResult>();
        for (BackupMethodEnum value : BackupMethodEnum.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;
    }

    public static String convertToName(String desc) {
        for (BackupMethodEnum e : BackupMethodEnum.values()) {
            if (Objects.equals(desc, e.getDesc())) {
                return e.name();
            }
        }
        return null;
    }

    public static BackupMethodEnum convertToEnum(String desc) {
        for (BackupMethodEnum e : BackupMethodEnum.values()) {
            if (Objects.equals(desc, e.getDesc())) {
                return e;
            }
        }
        return null;
    }

}
