package jnpf.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author yanglei
 * @version V1.0
 * @date 2023/7/20 2:03
 */
public class CourseEnums {

    @Getter
    @AllArgsConstructor
    public enum CourseGroundingType {
        UNDER(0, "未上架"),
        UP(1, "已上架"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum EnabledMarkType {
        INVALID(0, "无效"),
        VALID(1, "有效"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum IsRightAnswer {
        NO(0, "否"),
        YES(1, "是"),
        ;
        private final Integer code;
        private final String desc;
    }


    @Getter
    @AllArgsConstructor
    //考试状态
    public enum ExamStatus {
        //待考试
        WAIT(0),
        //待批阅
        WAIT_CHECK(1),
        //已逾期
        OVERDUE(2),
        //合格
        PASS(3),
        //不合格
        NO_PASS(4),
        //优秀
        VERY_PASS(5),
        ;
        private final Integer code;

        public static ExamStatus fromCode(Integer code) {
            for (ExamStatus examStatus : ExamStatus.values()) {
                if (examStatus.getCode().equals(code)) {
                    return examStatus;
                }
            }
            return null; // 或者您可以选择抛出异常，根据实际需求而定
        }

    }

    //场景类型
    @Getter
    public enum ExamMapType {
        //统考
        ALL(1),
        //岗位
        POSITION(2),
        ;
        private final int code;

        ExamMapType(int code) {
            this.code = code;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum QuestionType {
        SINGLE(1, "单选题"),
        MULTI(2, "多选题"),
        JUDGE(3, "判断题"),
        FILL(4, "填空题"),
        INPUT(5, "问答题"),
        COMBINE(6, "组合题"),
        ONE_OR_MULTI(7, "不定项选择题"),
        ;
        private final Integer code;
        private final String desc;

        public static QuestionType getByDesc(String desc) {
            QuestionType[] values = QuestionType.values();
            for (QuestionType value : values) {
                if (value.getDesc().equals(desc)) {
                    return value;
                }
            }
            return null;
        }

        public static QuestionType fromCode(Integer code) {
            for (QuestionType questionType : QuestionType.values()) {
                if (questionType.getCode().equals(code)) {
                    return questionType;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum QuestionDifficulty {
        EASY(1, "易"),
        MIDDLE(2, "中"),
        MAX(3, "难"),
        ;
        private final Integer code;
        private final String desc;

        public static QuestionDifficulty getByDesc(String desc) {
            QuestionDifficulty[] values = QuestionDifficulty.values();
            for (QuestionDifficulty value : values) {
                if (value.getDesc().equals(desc)) {
                    return value;
                }
            }
            return null;
        }
        public static QuestionDifficulty fromCode(Integer code) {
            for (QuestionDifficulty questionType : QuestionDifficulty.values()) {
                if (questionType.getCode().equals(code)) {
                    return questionType;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum CertExpireType {
        MONTH(1, "按月"),
        DAY(2, "按天"),
        NEVER(0, "永久"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum CertStatus {
        DOWN(0, "已下架"),
        UP(1, "上架中"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum CertUserStatus {
        USING(0, "生效中"),
        UN_USE(1, "已失效"),
        REVOKED(2, "已吊销"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum LearningType {
        COURSE(1, "课程"),
        EXAM(2, "考试"),
        IDENTIFY(3, "鉴定"),
        ;
        private final Integer code;
        private final String desc;

        public static LearningType getByCode(Integer code) {
            LearningType[] values = LearningType.values();
            for (LearningType value : values) {
                if (value.getCode().equals(code)) {
                    return value;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum LearningStatus {
        ING(0, "学习部分"),
        FINISH(1, "已学完"),
        NO_START(2, "未开始"),
        NO_PASS(3, "未通过"),
        ;
        private final Integer code;
        private final String desc;

    }

    @Getter
    @AllArgsConstructor
    public enum PaperType {
        FIX(1, "固定"),
        RANDOM(2, "随机"),
        ;
        private final Integer code;
        private final String desc;

        public static PaperType fromCode(Integer code) {
            for (PaperType paperType : PaperType.values()) {
                if (paperType.getCode().equals(code)) {
                    return paperType;
                }
            }
            return null; // 或者您可以选择抛出异常，根据实际需求而定
        }

    }

    @Getter
    @AllArgsConstructor
    public enum IdentifyStatus {
        UNDO(0, "待鉴定"),
        PASS(1, "已通过"),
        FAIL(2, "未通过"),
        ;
        private final Integer code;
        private final String desc;

    }

    @Getter
    @AllArgsConstructor
    public enum IdentifyType {
        YES_NO(1, "是/否"),
        OTHER(2, "熟悉/一般/了解"),
        ;
        private final Integer code;
        private final String desc;

    }

    @Getter
    @AllArgsConstructor
    public enum IdentifyOption {
        YES(1, "是"),
        NO(2, "否"),
        GOOD_AT(11, "熟悉"),
        COMMON(12, "一般"),
        KNOW(13, "了解"),
        ;
        private final Integer code;
        private final String desc;

    }

    @Getter
    @AllArgsConstructor
    public enum StudyType {
        POSITION(1, "岗位学习"),
        BASE(2, "知识库"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum StudyStatus {
        ING(0, "学习中"),
        FINISH(1, "已学习"),
        NO_START(2, "未学习"),
        ;
        private final Integer code;
        private final String desc;

    }

    @Getter
    @AllArgsConstructor
    public enum FollowStatus {
        //关注状态,0.取消关注,1.相互关注.2关注
        FALSE(0, "取消关注"),
        C_T_C_TRUE(1, "相互关注"),
        TRUE(2, "关注"),
        ;
        private final Integer code;
        private final String desc;
    }

    @Getter
    @AllArgsConstructor
    public enum CourseFormat {
        VIDEO(1, "视频"),
        AUDIO(2, "音频"),
        GRAPHIC(3, "图文"),
        GLOBAL_CURRICULUM(4, "全局课程"),
        JOB_COURSES(5, "岗位课程"),
        TOTAL_NUMBER_OF_COURSES(6, "课程总数"),
        NUMBER_OF_COMMON_FORMAT_COURSES(7, "通用格式课程数");
        private final Integer code;
        private final String desc;

    }

    /**
     * 试卷类型,1岗位学习试卷,2常规试卷
     */
    @Getter
    @AllArgsConstructor
    public enum PaperStudyType {
        POSITION(0, "岗位学习试卷"),
        BASE(1, "常规试卷"),
        ;
        private final Integer code;
        private final String desc;

        public static PaperStudyType fromCode(Integer code) {
            for (PaperStudyType paperStudyType : PaperStudyType.values()) {
                if (paperStudyType.getCode().equals(code)) {
                    return paperStudyType;
                }
            }
            return null; // 或者您可以选择抛出异常，根据实际需求而定
        }
    }

    @Getter
    @AllArgsConstructor
    public enum ExamType {
        POSITION(0, "岗位学习考试"),
        BASE(1, "自定义考试"),
        ;
        private final Integer code;
        private final String desc;

        // 通过代码获取对应的枚举值
        public static ExamType fromCode(Integer code) {
            for (ExamType examType : ExamType.values()) {
                if (examType.getCode().equals(code)) {
                    return examType;
                }
            }
            return null; // 或者您可以选择抛出异常，根据实际需求而定
        }
    }


    /**
     * 试卷状态（0启用，1禁用）
     */
    @Getter
    @AllArgsConstructor
    public enum PaperStatus {
        ENABLED(0, "启用"),
        DISABLED(1, "禁用"),
        ;
        private final Integer code;
        private final String desc;

        public static PaperStatus fromCode(Integer code) {
            for (PaperStatus paperStatus : PaperStatus.values()) {
                if (paperStatus.getCode().equals(code)) {
                    return paperStatus;
                }
            }
            return null;
        }
    }

    /**
     * 考试状态（0未开始，1进行中，2已完成）
     */
    @Getter
    @AllArgsConstructor
    public enum ExamTimeStatus {
        NOT_STARTED(0, "未开始"),
        IN_PROGRESS(1, "进行中"),
        DONE(2, "完成"),
        NULLIFY(3, "作废"),
        ;
        private final Integer code;
        private final String desc;

        public static ExamTimeStatus fromCode(Integer code) {
            for (ExamTimeStatus examTimeStatus : ExamTimeStatus.values()) {
                if (examTimeStatus.getCode().equals(code)) {
                    return examTimeStatus;
                }
            }
            return null;
        }
    }

    /**
     * 考试分数计算方式（1固定分，2百分比）
     */
    @Getter
    @AllArgsConstructor
    public enum ExamScoreCheckType {

        FIXED(1, "固定分"),
        PERCENTAGE(2, "百分比");

        private final Integer code;
        private final String desc;

        public static ExamScoreCheckType fromCode(Integer code) {
            for (ExamScoreCheckType examScoreCheckType : ExamScoreCheckType.values()) {
                if (examScoreCheckType.getCode().equals(code)) {
                    return examScoreCheckType;
                }
            }
            return null;
        }
    }

    /**
     * 审核人类型
     */
    @Getter
    @AllArgsConstructor
    public enum ReviewerType {
        // 0: 直属主管
        DIRECT_SUPERVISOR(0, "直属主管"),
        // 1: 指定人
        SPECIFIED_PERSON(1, "指定人");

        private final Integer code;
        private final String desc;

    }

    /**
     * 考试记录是否在App显示枚举
     */
    @Getter
    @AllArgsConstructor
    public enum ExamRecordDisplay {
        SHOW(0, "显示"),
        HIDDEN(1, "隐藏");
        private final Integer code;
        private final String desc;

    }

    /**
     * 考试限制
     */
    @Getter
    @AllArgsConstructor
    public enum RepeatExam {
        SINGLE_EXAM(0, "单次考试"),
        REPEAT_EXAM(1, "重复测试");
        private final Integer code;
        private final String desc;
        public static CourseEnums.RepeatExam fromCode(Integer code) {
            for (CourseEnums.RepeatExam status : values()) {
                if (status.getCode().equals(code)) {
                    return status;
                }
            }
            return null;
        }
    }

    /**
     * 用户考试来源
     */
    @Getter
    @AllArgsConstructor
    public enum RelationExamSource {
        COURSE_RELATED_EXAM(1, "课程关联考试"),
        JOB_LEARNING_RELATED_EXAM(2, "岗位学习职等关联考试"),
        REGULAR_EXAM(3, "（常规考试）自定义考试"),
        TASK_EXAM(4, "任务考试");

        private final Integer code;
        private final String desc;
    }

    /**
     * 是否是草稿
     */
    @Getter
    @AllArgsConstructor
    public enum DraftStatus {
        NO(0, "否"),
        YES(1, "是");
        private final Integer code;
        private final String desc;
    }

    /**
     * 是否是草稿
     */
    @Getter
    @AllArgsConstructor
    public enum YesOrNo {
        NO(0, "否"),
        YES(1, "是");
        private final Integer code;
        private final String desc;
    }
}

