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 {
    USER_PUSH("用户推送"),

    EXAM_PUSH("考试、考生、题卡数据推送"),

    STRUCTURE_GROUP_PUSH("试卷结构、分组、评卷员绑定关系数据推送"),

    PAPER_ANSWER_FILE_PUSH("试卷、标答文件推送"),

    OBJECTIVE_ANSWER_PUSH("客观题答案推送"),

    SCORE_PUSH("成绩推送"),

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

    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.name());
            result.setOrdinal(value.ordinal());
            result.setCode(null);
            result.setDesc(value.getTitle());
            list.add(result);
        }
        return list;
    }
}
