package com.ruoyi.web.controller.tool;

import org.springframework.data.redis.core.StringRedisTemplate;

import javax.annotation.Resource;
import java.util.Map;
import java.util.stream.Collectors;

public class RedisMapUtil {

    private static StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();

    public static Map<Object, Object> getMapUserNameToUserId() {
        return stringRedisTemplate.opsForHash().entries("sys_map");
    }

    public static Map<Object, Object> getMapUserIdToUserName() {
        Map<Object, Object> map = stringRedisTemplate.opsForHash().entries("sys_map");
        return map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
    }
}
