package org.jeecg;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.jeecg.common.util.RestUtil;
import org.jeecg.config.aop.logprint.ThreadLocalUtil;
import org.jeecg.digital.infrastructure.leqi.util.LqResultUtil;
import org.jeecg.digital.infrastructure.leqi.vo.LeqiResultVO;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;

/**
 * @Description: TODO
 * @author: scott
 * @date: 2022年05月10日 14:02
 */
public class TestMain {
    public static void main(String[] args) throws JsonProcessingException {
//        // 请求地址
//        String url = "https://api.boot.jeecg.com/sys/user/list";
//        // 请求 Header （用于传递Token）
//        HttpHeaders headers = getHeaders();
//        // 请求方式是 GET 代表获取数据
//        HttpMethod method = HttpMethod.GET;
//
//        System.out.println("请求地址：" + url);
//        System.out.println("请求方式：" + method);
//
//        // 利用 RestUtil 请求该url
//        ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
//        if (result != null && result.getBody() != null) {
//            System.out.println("返回结果：" + result.getBody().toJSONString());
//        } else {
//            System.out.println("查询失败");
//        }
        ThreadLocalUtil.setTlsb(new StringBuffer("99ec90e7d70e409fb072c8a0a899db71"));
        String result = "ONtvunzTbYbRgEsxDSbY9jIwI03UMDNmcpvClSkQ/jDPJfhBEhuKl0afL3zmZe9KhT3hkSR3GSgjkMbozW1T9ynlcCDWxew4tdvvVWyZqd+54ThYy4aF7xoTN1o88JHQep79vi+IHPwcq6s3q3KjJczJ8gyk8t2J5ezgX2broxQlTbZ4IGR8gdJvTiF8oMNAJiSwJqFn3Ej1dIu0Q1j+tQ==";
        LeqiResultVO leqiResultVO = LqResultUtil.resultHandler(result, "");

        System.out.println(leqiResultVO.toString());
    }
    private static HttpHeaders getHeaders() {
        String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.50h-g6INOZRVnznExiawFb1U6PPjcVVA4POeYRA5a5Q";
        System.out.println("请求Token：" + token);

        HttpHeaders headers = new HttpHeaders();
        String mediaType = MediaType.APPLICATION_JSON_VALUE;
        headers.setContentType(MediaType.parseMediaType(mediaType));
        headers.set("Accept", mediaType);
        headers.set("X-Access-Token", token);
        return headers;
    }

}
