package com.dxhy.auth.util;

import com.dxhy.common.util.HttpUtils;
import com.dxhy.common.util.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Configuration;

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

/**
* @Description 保存大B用户信息
* @Author wangruwei
* @Date 2024/8/29 16:46
**/
@Configuration
@Slf4j
public class UserInfoRedisUtils {
    @Resource
    private RedisUtils redisUtils;

    public String getRedisUserInfo(String requestToken, String basicUserInfourl, Map<String, String> headers) {
        log.info("redisutil是:{}",redisUtils);
        String response = redisUtils.get(requestToken);
        if(StringUtils.isBlank(response)){
            //调大B生成
            response = HttpUtils.doPostWithHeader(basicUserInfourl, null, headers);
            redisUtils.set(requestToken, response, 300);
        }
        return response;
    }

}
