diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index c78458fa..3ea61e38 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -92,6 +92,8 @@ public class WechatController { // 记录登录信息 String requestIp = RequestUtils.getIpAddress(request); + JSONObject object =BaiduUtils.ipLocation(requestIp); + log.error("origin encryptedData:" + encryptedData + ";iv:" + iv); //校验openId不能为空 //encryptedData,iv与unionId不能同时为空 diff --git a/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java new file mode 100644 index 00000000..7f8d8fb0 --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java @@ -0,0 +1,30 @@ +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) { + JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip); + log.info(response.toJSONString()); + return response; + } + + +}