package com.prolog.cs.biz.outbound.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class IntegrationUtil {

    @Value("${prolog.interfaceId.token:http://prolog.bocai-cloud.com:10001/}")
    private String integrationUrl;

    /**
     * 调用接口平台
     * @param interfaceId
     * @param param
     * @return
     */
    public JSONObject askIntegration(String interfaceId, Map<String,Object> param){
        //http://server_url/api/**
        //http://prolog.bocai-cloud.com:10001/
        ///api/siyuan/v1/outbound/pull/billlist
        String baseUrl = "http://prolog.bocai-cloud.com:10001";
        String paramJson = JSONObject.toJSONString(param);
        HttpResponse response = HttpRequest.post(baseUrl + interfaceId).body(paramJson).execute();
        return JSONObject.parseObject(response.body());
    }
}
