package com.qmth.teachcloud.common.enums;

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

/**
 * @Description: 同步推送类型
 * @Author: CaoZixuan
 * @Date: 2021-11-01
 */
public enum PushTypeEnum {

    INIT_MARK_DATA("阅卷数据初始化"),

    GRADE_BATCH_PUSH("分析批次推送"),

    GRADE_BATCH_DELETE("分析批次删除"),

    CALCULATE("分析计算"),

    PUBLISH("发布");

    PushTypeEnum(String title) {
        this.title = title;
    }

    private final String title;

    public String getTitle() {
        return title;
    }

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

    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<>();
        for (PushTypeEnum value : PushTypeEnum.values()) {
            EnumResult result = new EnumResult();
            result.setName(value.getTitle());
            result.setOrdinal(value.ordinal());
            result.setCode(value.name());
            list.add(result);
        }
        return list;
    }
}
