package com.zksy.common.utils.result;

/**
 * @Author sy
 * @Date 2022/04/11
 * @Description
 */
public class Constant {
    // Header的认证的key
    public static final String AUTH_HEADER_KEY = "NFMBR";
    // 认证存放到REDIS中前缀
    public static final String AUTH_REDIS_PREFIX_KEY = "auth:";
    // Header的认证刷新令牌的key，当本地会话失效之后，需要通过刷新令牌刷新认证令牌
    public static final String AUTH_HEADER_REFRESH_KEY = "OCVID";
    // 认证刷新令牌存放到REDIS中前缀
    public static final String AUTH_REFRESH_REDIS_PREFIX_KEY = "auth:refresh:";
    // 认证令牌存放到REIDS中前缀
    public static final String AUTH_TOKEN_REDIS_PREFIX_KEY = "auth:token:";

    public static class Page {
        //Page参数
        public static final Integer PAGE_SIZE_DEFAULT = 10;
        public static final Integer CURR_PAGE_DEFAULT = 1;
        public static final Integer TOTAL_PAGE_DEFAULT = 1;
        public static final Integer TOTAL_RECORD_DEFAULT = 0;
        public static final Integer START_ROW_DEFAULT = 0;
    }

    public static class RedisKey {
        private static String USER_AUTH_PERI_KEY = "sys:auth:permission:%d";
        //token保存用户登录信息
        private static String ADMIN_TOKEN_USER_KEY = "sys:auth:manage:token:%s";
        private static String ADMIN_UID_USER_KEY = "sys:auth:manage:uid:%s";


        public static String getUserAuthPeriKey(long userId) {
            return String.format(USER_AUTH_PERI_KEY, userId);
        }

        public static String getAdminTokenUserKey(String token) {
            return String.format(ADMIN_TOKEN_USER_KEY, token);
        }

        public static String getAdminUidUserKey(String uid) {
            return String.format(ADMIN_UID_USER_KEY, uid);
        }
    }

    public static class ClientRedisKey {
        //token保存用户登录信息
        private static String CLIENT_TOKEN_USER_KEY = "sys:auth:client:token:%s";

        public static String getClientTokenUserKey(String token) {
            return String.format(CLIENT_TOKEN_USER_KEY, token);
        }
    }

    /**
     * 邮件header name
     */
    public static final String MAIL_HEADER_NAME = "java-mail-id";
}
