package com.qmth.themis.business.cache;

import com.qmth.themis.business.constant.SpringContextHolder;
import com.qmth.themis.business.enums.ExceptionEnum;
import com.qmth.themis.business.enums.VerifyExceptionEnum;
import com.qmth.themis.business.util.RedisUtil;

/**
 * 断点缓存hash值操作
 *
 * @Description:
 * @Author: xiatian
 * @Long: 2020-07-29
 */
public class ExamBreakCacheUtil {
    private static RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);

    public static void setExamRecordId(Long examBreakId, Long examRecordId) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "examRecordId", examRecordId);
    }

    public static Long getExamRecordId(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "examRecordId");
    }

    public static void setBreakTime(Long examBreakId, Long breakTime) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "breakTime", breakTime);
    }

    public static Long getBreakTime(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "breakTime");
    }

    public static void setBreakReason(Long examBreakId, ExceptionEnum breakReason) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "breakReason", breakReason);
    }

    public static ExceptionEnum getBreakReason(Long examBreakId) {
        return (ExceptionEnum) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "breakReason");
    }

    public static void setResumeReason(Long examBreakId, String resumeReason) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "resumeReason", resumeReason);
    }

    public static Long getResumeReason(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "resumeReason");
    }


    public static void setPrepareTime(Long examBreakId, Long prepareTime) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "prepareTime", prepareTime);
    }

    public static Long getPrepareTime(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "prepareTime");
    }


    public static void setStartTime(Long examBreakId, Long startTime) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "startTime", startTime);
    }

    public static Long getStartTime(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "startTime");
    }

    public static void setEntryAuthenticationResult(Long examBreakId, VerifyExceptionEnum entryAuthenticationResult) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "entryAuthenticationResult", entryAuthenticationResult);
    }

    public static VerifyExceptionEnum getEntryAuthenticationResult(Long examBreakId) {
        return (VerifyExceptionEnum) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "entryAuthenticationResult");
    }

    public static void setEntryAuthenticationId(Long examBreakId, Long entryAuthenticationId) {
        redisUtil.set(RedisKeyHelper.examBreakCacheKey(examBreakId), "entryAuthenticationId", entryAuthenticationId);
    }

    public static Long getEntryAuthenticationId(Long examBreakId) {
        return (Long) redisUtil.get(RedisKeyHelper.examBreakCacheKey(examBreakId), "entryAuthenticationId");
    }
}
