|
4 | 4 | import java.util.Collections; |
5 | 5 | import java.util.Map; |
6 | 6 |
|
| 7 | +import com.alibaba.fastjson.JSONObject; |
7 | 8 | import com.xlongwei.light4j.handler.service.IpHandler; |
8 | 9 | import com.xlongwei.light4j.handler.service.MobileHandler; |
9 | 10 | import com.xlongwei.light4j.util.JsonUtil; |
|
12 | 13 | import com.xlongwei.light4j.util.WeixinUtil.AbstractMessageHandler.AbstractTextHandler; |
13 | 14 |
|
14 | 15 | import cn.hutool.core.map.MapUtil; |
| 16 | +import cn.hutool.http.HttpRequest; |
15 | 17 | import cn.hutool.http.HttpUtil; |
16 | 18 |
|
17 | 19 | /** |
@@ -40,7 +42,18 @@ public String handle(String content) { |
40 | 42 | } |
41 | 43 | return response.toString(); |
42 | 44 | } |
43 | | - }else if(StringUtil.isIp(content)) { |
| 45 | + }else if(content.startsWith("ip=")){ |
| 46 | + content = content.substring("ip=".length()); |
| 47 | + String openid = message.get().getFromUserName(); |
| 48 | + if(!StringUtil.isBlank(openid)) { |
| 49 | + JSONObject alidnsConfig = JsonUtil.parseNew(RedisConfig.get("alidns.config")); |
| 50 | + String token = alidnsConfig.getString("token"), recordId = alidnsConfig.getString(openid); |
| 51 | + if(!StringUtil.isBlank(recordId)) { |
| 52 | + String ip = StringUtil.isIp(content) ? content : ""; |
| 53 | + return HttpRequest.get("https://log.xlongwei.com/log?type=alidns&recordId="+recordId+"&ip="+ip).header("X-Request-Token", token).execute().body(); |
| 54 | + } |
| 55 | + } |
| 56 | + }else if(StringUtil.isIp(content)) { |
44 | 57 | Map<String, String> searchToMap = IpHandler.searchToMap(content); |
45 | 58 | if(searchToMap!=null) { |
46 | 59 | return searchToMap.get("region"); |
|
0 commit comments