|
@@ -11,6 +11,7 @@ import com.zanxiang.game.module.sdk.constant.RegexConstant;
|
|
|
import com.zanxiang.game.module.sdk.pojo.param.UserCardUpdateParam;
|
|
|
import com.zanxiang.game.module.sdk.pojo.param.UserData;
|
|
|
import com.zanxiang.game.module.sdk.pojo.result.CardCheckResult;
|
|
|
+import com.zanxiang.game.module.sdk.pojo.result.IpCheckResult;
|
|
|
import com.zanxiang.game.module.sdk.service.IUserCardService;
|
|
|
import com.zanxiang.game.module.sdk.service.IUserService;
|
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
@@ -20,15 +21,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import org.springframework.web.util.UriComponentsBuilder;
|
|
|
import reactor.util.function.Tuple2;
|
|
|
import reactor.util.function.Tuples;
|
|
|
|
|
@@ -227,4 +226,32 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
|
|
|
log.error("实名认证结果, result : {}", JsonUtil.toString(result));
|
|
|
return Tuples.of(result.past(), result.getAddress());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IpCheckResult userIpCheck(String ip) {
|
|
|
+ String url = "https://ipcity.market.alicloudapi.com/ip/city/query";
|
|
|
+ String appCode = "f395b1587fc04a49a975f908660fb1e9";
|
|
|
+
|
|
|
+ UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(url).queryParam("ip", ip);
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.set("Authorization", "APPCODE " + appCode);
|
|
|
+ RequestEntity<Object> requestEntity = new RequestEntity<>(headers, HttpMethod.GET, uriBuilder.build().toUri());
|
|
|
+
|
|
|
+ IpCheckResult result;
|
|
|
+ try {
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.exchange(requestEntity, String.class);
|
|
|
+ String body = responseEntity.getBody();
|
|
|
+ result = JsonUtil.toObj(body, IpCheckResult.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求阿里ip检测接口异常, ip : {}, e : {}", ip, e.getMessage());
|
|
|
+ throw new BaseException("请求阿里ip监测接口异常");
|
|
|
+ }
|
|
|
+ if (result == null || result.isFail()) {
|
|
|
+ log.error("请求阿里ip检测接口返回值为空, ip : {}, result : {}", ip, JsonUtil.toString(result));
|
|
|
+ throw new BaseException("请求阿里ip检测接口返回值为空");
|
|
|
+ }
|
|
|
+ log.error("ip检测结果, result : {}", JsonUtil.toString(result));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|