package cn.reghao.oss.console.util;

import cn.reghao.jutil.web.ServletUtil;

/**
 * @author reghao
 * @date 2023-02-03 15:57:06
 */
public class CacheKeys {
    public static String getCaptchaKey() {
        String sessionId = ServletUtil.getSessionId();
        return String.format("account:code:%s:captcha", sessionId);
    }

    public static String getVerifyCodeKey(String receiver) {
        String sessionId = ServletUtil.getSessionId();
        return String.format("account:code:%s:mobile:%s", sessionId, receiver);
    }

    public static String getPubkeyRKey() {
        String sessionId = ServletUtil.getSessionId();
        return String.format("account:rsa:r:%s", sessionId);
    }

    public static String getRsaPubkeyKey() {
        return String.format("account:rsa:pubkey");
    }

    public static String getRsaPrikeyKey() {
        return String.format("account:rsa:prikey");
    }

    public static String getLoginSuccessKey(int userId, int plat, String loginId) {
        return String.format("account:login:success:%s:%s:%s", userId, plat, loginId);
    }

    public static String getLoginSuccessKey(String sessId) {
        return String.format("account:login:success:%s", sessId);
    }

    public static String getLoginSuccessKeyPattern(int userId) {
        return String.format("account:login:success:%s:*", userId);
    }

    public static String getLoginFailedCountKey(String userId, int plat) {
        return String.format("account:login:failed:count:%s:%s", userId, plat);
    }

    public static String getLoginFailedLockKey(String userId, int plat) {
        return String.format("account:login:failed:lock:%s:%s", userId, plat);
    }
}
