package com.qmth.themis.business.cache;

import com.qmth.themis.business.enums.MobileModeEnum;

public class RedisKeyHelper {
    private static String underLine = "_";

//    /**
//     * 场次
//     */
//    private static String examActivityKeyPrefix = "exam_activity:";
    /**
     * 考生
     */
    private static String examStudentKeyPrefix = "exam_student:";
    /**
     * 考试记录
     */
    private static String examRecordKeyPrefix = "exam_record:";
    /**
     * 考生试卷结构
     */
    private static String studentPaperStructKeyPrefix = "student_paper_struct:";
    /**
     * 考生作答
     */
    private static String studentAnswerKeyPrefix = "student_answer:";
    /**
     * 剩余音频播放次数
     */
    private static String audioLeftPlayCountKeyPrefix = "audio_left_play_count:";

    /**
     * 人脸验证
     */
    private static String faceVerifyKeyPrefix = "face_verify:";

    /**
     * 断点
     */
    private static String examBreakKeyPrefix = "exam_break:";

    /**
     * 活体验证
     */
    private static String livenessVerifyKeyPrefix = "liveness_verify:";


    /**
     * 场次-考试记录
     */
    private static String examActivityRecordKeyPrefix = "exam_activity_record:";

    /**
     * 移动端临时认证
     */
    private static String mobileAuthKeyPrefix = "mobile_auth:";

    /**
     * 未完成考试记录id
     */
    private static String unFinishedRecordIdKeyPrefix = "un_finished_record_id:student_id_";

    /**
     * 正在考试记录id
     */
    private static String examingRecordIdKeyPrefix = "examing_record_id:student_id_";

    /**
     * 客观题答案
     */
    private static String objectiveAnswerKeyPrefix = "objective_answer:exam_id_";

    /**
     * 客观题答案
     */
    private static String objectiveAnswerHashKeyPrefix = "paper_id_";

//    /**
//     * 监考通话
//     */
//    private static String examInvigilateCallCachePrefix = "exam_invigilate_call:";
//
//    /**
//     * 场次
//     *
//     * @param activityId
//     * @return
//     */
//    public static String examActivityCacheKey(Long activityId) {
//        return examActivityKeyPrefix + activityId;
//    }

    /**
     * 考生
     *
     * @param examStudentId
     * @return
     */
    public static String examStudentCacheKey(Long examStudentId) {
        return examStudentKeyPrefix + examStudentId;
    }

    /**
     * 考试记录
     *
     * @param examRecordId
     * @return
     */
    public static String examRecordCacheKey(Long examRecordId) {
        return examRecordKeyPrefix + examRecordId;
    }

    /**
     * 考生试卷结构
     *
     * @param examRecordId
     * @return
     */
    public static String studentPaperStructKey(Long examRecordId) {
        return studentPaperStructKeyPrefix + examRecordId;
    }

    /**
     * 考生作答
     *
     * @param examRecordId
     * @return
     */
    public static String examAnswerKey(Long examRecordId) {
        return studentAnswerKeyPrefix + examRecordId;
    }

    /**
     * 考生作答 hashKey
     *
     * @param mainNumber
     * @param subNumber
     * @param subIndex
     * @return
     */
    public static String examAnswerHashKey(Integer mainNumber, Integer subNumber, Integer subIndex) {
        if (subIndex == null) {
            return mainNumber + underLine + subNumber;
        } else {
            return mainNumber + underLine + subNumber + underLine + subIndex;
        }
    }

    /**
     * 音频剩余播放次数
     *
     * @param examRecordId
     * @return
     */
    public static String audioLeftPlayCountKey(Long examRecordId) {
        return audioLeftPlayCountKeyPrefix + examRecordId;
    }

    /**
     * 人脸验证 大key
     *
     * @param examRecordId
     * @return
     */
    public static String faceVerifyCacheKey(Long examRecordId) {
        return faceVerifyKeyPrefix + examRecordId;
    }

    /**
     * 活体验证 大key
     *
     * @param examRecordId
     * @return
     */
    public static String livenessVerifyCacheKey(Long examRecordId) {
        return livenessVerifyKeyPrefix + examRecordId;
    }

    /**
     * 断点缓存大key
     *
     * @param id
     * @return
     */
    public static String examBreakCacheKey(Long id) {
        return examBreakKeyPrefix + id;
    }

//    /**
//     * 场次-考试记录大key
//     *
//     * @return
//     */
//    public static String examActivityRecordCacheKey(Long activityId) {
//        return examActivityRecordKeyPrefix + activityId;
//    }

    /**
     * 移动端临时认证大key
     *
     * @param mode
     * @param code
     * @return
     */
    public static String mobileAuthCacheKey(MobileModeEnum mode, String code) {
        return mobileAuthKeyPrefix + mode.name().toLowerCase() + underLine + code;
    }

    /**
     * 未完成考试记录id key
     *
     * @param studentId
     * @return
     */
    public static String unFinishedRecordIdCacheKey(Long studentId) {
        return unFinishedRecordIdKeyPrefix + studentId;
    }

    /**
     * 正在考试记录id key
     *
     * @param studentId
     * @return
     */
    public static String examingRecordIdCacheKey(Long studentId) {
        return examingRecordIdKeyPrefix + studentId;
    }

    /**
     * 客观题答案大key
     *
     * @param examId
     * @return
     */
    public static String objectiveAnswerCacheKey(Long examId) {
        return objectiveAnswerKeyPrefix + examId;
    }

    /**
     * 客观题答案小key
     *
     * @param paperId
     * @return
     */
    public static String objectiveAnswerCacheHashKey(Long paperId) {
        return objectiveAnswerHashKeyPrefix + paperId;
    }

//    /**
//     * 学生记录id key
//     *
//     * @param studentId
//     * @return
//     */
//    public static String studentCacheKey(Long studentId) {
//        return SystemConstant.studentAccount + ":" + studentId;
//    }

//    /**
//     * 监考通话缓存大key
//     *
//     * @param id
//     * @return
//     */
//    public static String examInvigilateCallCacheKey(Long id) {
//        return examInvigilateCallCachePrefix + id;
//    }
}
