package com.qmth.teachcloud.mark.enums;

import java.util.LinkedList;
import java.util.List;

public enum DocumentType {
    SYLLABUS("课程教学大纲", 1),
    PROCESS_SCORE("过程考核成绩", 2),
    PAPER("试卷样卷", 3),
    ANSWER("试卷评阅标准", 4),
    PAPER_REPORT("试卷分析报告", 5),
    APPROVE_RECORD("试卷审批记录", 6),
    SCORE("学生期末考试成绩单", 7),
    SCORE_REPORT("学生期末考试成绩分析", 8),
    SHEET("学生答卷原图", 9),
    TRACK("学生答卷轨迹图", 10),
    SIGN("期末考试签到表", 11),
    CHECK_IN("期考考试考场记录单", 12),
    CUSTOM("自定义", 13);

    private String name;

    private int value;

    private static List<DocumentType> options;

    private DocumentType(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public static DocumentType findByValue(int value) {
        for (DocumentType c : DocumentType.values()) {
            if (c.getValue() == value) {
                return c;
            }
        }
        return null;
    }

    /**
     * 类型列表
     *
     * @param containsCustom 是否包含自定义类型
     * @return
     */
    public static List<DocumentType> getOptionList(boolean containsCustom) {
        if (options == null) {
            options = new LinkedList<>();
            for (DocumentType status : DocumentType.values()) {
                if (!containsCustom && status.equals(DocumentType.CUSTOM)) {
                    continue;
                }
                options.add(status);
            }
        }
        return options;
    }
}
