package com.hfkj.common.utils;

import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;

/**
 * 高德API服务
 * @className: AmapApiService
 * @author: HuRui
 * @date: 2024/6/28
 **/
public class AmapApiService {

    /**
     * 获取ip
     */
    public static JSONObject queryIp(String ip) {
        JSONObject obj = HttpsUtils.doGet("https://restapi.amap.com/v3/ip?key=0083a5b1cc5289d7e9691424ee62136e&ip="+ip);
        if (obj.getString("status").equals("1")) {
            return obj;
        } else {
            throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, obj.getString("info"));
        }
    }

}
