package com.ruoyi.iot.util;

import cn.hutool.http.HttpRequest;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class HutoolHttpUtil {

    public static String get(String url, Map<String, Object> queryParams) throws IOException {
        return get(url, queryParams, new HashMap<>(1));
    }

    public static String get(String url, Map<String, Object> queryParams, Map<String, String> headers) throws IOException {
        String body = HttpRequest.get(url).timeout(3000).form(queryParams).addHeaders(headers).execute().body();
        return body;
    }

    public static String post(String url, String json, Map<String, String> headers) {
        String body = HttpRequest.post(url).body(json).addHeaders(headers).execute().body();
        return body;
    }
    
}
