package cn.iocoder.yudao.module.system.controller.admin.myUtils;

import cn.iocoder.yudao.module.system.controller.admin.auth.myVo.LoginUserInfo;
import cn.iocoder.yudao.module.system.controller.admin.auth.myVo.PtResult;
import cn.iocoder.yudao.module.system.controller.admin.conf.PtUrlConf;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.HashMap;
import java.util.Map;

public class PtTokenUtils {

    public static PtResult<LoginUserInfo> getUserByToken(PtUrlConf ptUrlConf, String appkey, String authorization) {
        // 带参数和请求头
        Map<String, String> headers = new HashMap<>();
        headers.put("appkey", appkey);
        headers.put("Authorization", authorization);


        String rStr = MyHttpUtils.get(ptUrlConf.getGetUserByToken(), headers, null);

        PtResult<LoginUserInfo> result = JSON.parseObject(rStr, new TypeReference<PtResult<LoginUserInfo>>() {});
        return result;
    }
}
