package com.qmth.themis.business.cache;

import com.qmth.themis.business.constant.SpringContextHolder;
import com.qmth.themis.business.enums.MobileModeEnum;
import com.qmth.themis.business.util.RedisUtil;
import com.qmth.themis.common.enums.Source;

/**
 * 移动端临时认证
 *
 * @Description:
 * @Author: xiatian
 * @Date: 2020-08-14
 */
public class MobileAuthCacheUtil {
    private static RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);

    public static void setSessionId(MobileModeEnum mode, String code, String sessionId) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "sessionId", sessionId);
    }

    public static void setUserType(MobileModeEnum mode, String code, String userType) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "userType", userType);
    }

    public static void setSource(MobileModeEnum mode, String code, Source source) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "source", source);
    }

    public static void setMode(MobileModeEnum mode, String code) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "mode", mode);
    }

    public static MobileModeEnum getMode(MobileModeEnum mode, String code) {
        return (MobileModeEnum) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "mode");
    }

    public static void setCode(MobileModeEnum mode, String code) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "code", code);
    }

    public static String getCode(MobileModeEnum mode, String code) {
        return (String) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "code");
    }

    public static void setRecordId(MobileModeEnum mode, String code, Long recordId) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "recordId", recordId);
    }

    public static Long getRecordId(MobileModeEnum mode, String code) {
        return (Long) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "recordId");
    }

    public static void setMainNumber(MobileModeEnum mode, String code, Integer mainNumber) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "mainNumber", mainNumber);
    }

    public static Integer getMainNumber(MobileModeEnum mode, String code) {
        return (Integer) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "mainNumber");
    }

    public static void setSubNumber(MobileModeEnum mode, String code, Integer subNumber) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "subNumber", subNumber);
    }

    public static Integer getSubNumber(MobileModeEnum mode, String code) {
        return (Integer) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "subNumber");
    }

    public static void setSubIndex(MobileModeEnum mode, String code, Integer subIndex) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "subIndex", subIndex);
    }

    public static Integer getSubIndex(MobileModeEnum mode, String code) {
        return (Integer) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "subIndex");
    }

    public static void setMonitorKey(MobileModeEnum mode, String code, String monitorKey) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorKey", monitorKey);
    }

    public static String getMonitorKey(MobileModeEnum mode, String code) {
        return (String) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorKey");
    }

    public static void setMonitorVideoSource(MobileModeEnum mode, String code, Source monitorVideoSource) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorVideoSource", monitorVideoSource);
    }

    public static Source getMonitorVideoSource(MobileModeEnum mode, String code) {
        return (Source) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorVideoSource");
    }

    public static void setMonitorAudioEnable(MobileModeEnum mode, String code, Boolean monitorAudioEnable) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorAudioEnable", monitorAudioEnable);
    }

    public static Boolean getMonitorAudioEnable(MobileModeEnum mode, String code) {
        return (Boolean) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "monitorAudioEnable");
    }

    public static Source getSource(MobileModeEnum mode, String code) {
        return (Source) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "source");
    }

    public static String getSessionId(MobileModeEnum mode, String code) {
        return (String) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "sessionId");
    }

    public static String getPlatformSource(MobileModeEnum mode, String code) {
        return (String) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "platformSource");
    }

    public static void setPlatformSource(MobileModeEnum mode, String code, String source) {
        redisUtil.set(RedisKeyHelper.mobileAuthCacheKey(mode, code), "platformSource", source);
    }

    public static String getUserType(MobileModeEnum mode, String code) {
        return (String) redisUtil.get(RedisKeyHelper.mobileAuthCacheKey(mode, code), "userType");
    }
}
