package com.hai.common.utils;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 百度工具
 * @className: BaiduUtis
 * @author: HuRui
 * @date: 2022/10/21
 **/
public class BaiduUtils {

    private static Logger log = LoggerFactory.getLogger(BaiduUtils.class);

    /**
     * IP 定位
     * @param ip ip地址
     * @return
     */
    public static JSONObject ipLocation(String ip) {
        System.out.println(ip);
        try {
            if (ip != null) {
                JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip);
                return response;
            } else {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
    }

}
