package org.ta.pddserver.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.ta.pddserver.config.YJTConfig;


@Slf4j
public class YjtHttpTool {

    public static String sendJsonPost(String msg) {
        log.info("SEND TO YJT REQ:{}", msg);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json;charset=UTF-8");
        HttpEntity<String> requestEntity = new HttpEntity<>(msg, headers);

        // 2. 封装请求实体（参数 + 头信息）
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<String> resp = restTemplate.postForEntity(YJTConfig.URL, requestEntity, String.class);
        log.info("RESP:{}", resp.getBody());
        return resp.getBody();
    }
}
