package com.tourism.common.additional.constant;

/**
 * 缓存的key 常量
 * 
 * @author tourism
 */
public class CacheConstants
{
    /**
     * 登录用户 redis key
     */
    public static final String LOGIN_TOKEN_KEY = "login_tokens:";

    /**
     * 验证码 redis key
     */
    private static final String CAPTCHA_CODE_KEY = "captcha_codes:%s";

    /**
     * 短信验证码 redis key
     */
    private static final String SMS_CODE_KEY = "sms_codes:%s";

    /**
     * 短信验证码有效时长 S
     */
    private static final Integer SMS_EFFECTIVE_SECONDS = 5 * 60;


    /**
     * 短信验证码 redis key
     */
    private static final String SMS_REPEAT_LIMIT_KEY = "sms_repeat_limit:%s";

    /**
     * 短信验证码不能重复发送控制时长 S
     */
    private static final Integer SMS_REPEAT_LIMIT_SECONDS = 60;

    /**
     * 参数管理 cache key
     */
    public static final String SYS_CONFIG_KEY = "sys_config:";

    /**
     * 字典管理 cache key
     */
    public static final String SYS_DICT_KEY = "sys_dict:";

    /**
     * 防重提交 redis key
     */
    public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";

    /**
     * 限流 redis key
     */
    public static final String RATE_LIMIT_KEY = "rate_limit:";

    /**
     * 登录账户密码错误次数 redis key
     */
    public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
    /**
     * 预定ip redis key
     */
    public static final String TOUR_BOOK_IP = "tour_book_ip:";


    public static String getCaptchaCodeKey(String uuid){
        return String.format(CAPTCHA_CODE_KEY, uuid);
    }

    public static String getSmsCodeKey(String uuid){
        return String.format(SMS_CODE_KEY, uuid);
    }

    public static Integer getSmsEffectiveSeconds(){
        return SMS_EFFECTIVE_SECONDS;
    }

    public static String getSmsRepeatLimitKey(String mobile){
        return String.format(SMS_REPEAT_LIMIT_KEY, mobile);
    }

    private static Integer getSmsRepeatLimitSeconds(){
        return SMS_REPEAT_LIMIT_SECONDS;
    }
}
