package com.skr.mdm.util;

/**
 * @author nfq
 * @date 2020/7/10 17:38
 */
public class RedisGetKeyUtil {


    public static final String DOWNLOAD_TOKEN_KEY = "mdm:down:token:";

    /**
     * admin token
     */
    public static String getAdminTokenKey(String uuid) {
        return "admin:token:" + uuid;
    }

    public static String getAdminRefreshToken(String refreshToken) {
        return "admin:refresh_token:" + refreshToken;
    }

    public static String getVerifyCodeKey(String ip) {
        return "admin:verifyCode:" + ip;
    }

    public static String getAdminLoginIdKey(String adminId) {
        return "admin:loginId:" + adminId;
    }

    /**
     * user token
     */
    public static String getUserTokenKey(String token) {
        return "user:token:" + token;
    }

    public static String getUserRefreshTokenKey(String refreshToken) {
        return "user:refreshToken:" + refreshToken;
    }

    public static String getUserIdKey(Integer id) {
        return "user:id:" + id.toString();
    }

    /**
     * admin nonce
     */
    public static String getAdminQuestNonceKey(String nonce) {
        return "admin:antiReplay:nonce:" + nonce;
    }

    /**
     * user nonce
     */
    public static String getUserQuestNonceKey(String nonce) {
        return "user:antiReplay:nonce:" + nonce;
    }

    /**
     * 文件进度条
     *
     * @param fileName
     * @return
     */
    public static String getFileProgressKey(String fileName) {
        return "admin:fileProgress:" + fileName;
    }

    /**
     * 文件进度数据获取失败请求次数
     *
     * @return
     */
    public static String getAdminRequestCountKey() {
        return "admin:request:count";
    }

    /**
     * 用户上线记录key
     *
     * @param equipmentId
     * @return
     */
    public static String getUserOnlineKey(Integer equipmentId) {
        return "user:online:" + equipmentId;
    }

    /**
     * 用户channelId key
     *
     * @param channelId
     * @return
     */
    public static String getUserChannelIdKey(String channelId) {
        return "user:channelId:" + channelId;
    }

    /**
     * 用户准备离线key
     *
     * @param equipmentId
     * @return
     */
    public static String getUserReadyOfflineKey(Integer equipmentId) {
        return "user:read:offline:" + equipmentId;
    }

    /**
     * 公司下载计数器key
     * @param companyId
     * @return
     */
    public static String getCompanyDownloadCounterKey(Integer companyId) {
        return "mdm:down:company:" + companyId;
    }

    /**
     * 获取用户下载key
     * @param equipmentId
     * @return
     */
    public static String getUserDownloadKey(Integer companyId, Integer equipmentId, String accessToken) {
        return DOWNLOAD_TOKEN_KEY.concat(String.valueOf(companyId)).concat(":") + equipmentId + "-" + accessToken;
    }

    public static String getFileUploadProgressKey(String fileId) {
        return "mdm:file:progress:" + fileId;
    }
}
