From 8788a78ad30c1bb9d50d91b10e76d3ae47ed8da2 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期一, 07 六月 2021 09:28:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test_future_wangge' into test_future_wangge --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java index 0e9d3e4..4575728 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/RealNameUtil.java @@ -1,10 +1,10 @@ package com.panzhihua.common.utlis; import com.alibaba.fastjson.JSONObject; +import com.panzhihua.common.exceptions.ServiceException; import lombok.extern.slf4j.Slf4j; import java.util.Base64; -import java.util.Date; /** * @program: springcloud_k8s_panzhihuazhihuishequ @@ -29,11 +29,7 @@ boolean result=false; String headerkey="Authorization"; String headervalue="Basic "; - Long time = new Date().getTime(); - //1619420449081 - //1619420637940 - String basicStr = CLIENT_ID + ":" + SECRET + ":" + time; - log.info("请求时间戳:" + time); + String basicStr = CLIENT_ID + ":" + SECRET + ":" + System.currentTimeMillis(); String encodeToString = Base64.getEncoder().encodeToString(basicStr.getBytes()); JSONObject jsonObject=new JSONObject(); jsonObject.put("idNumber",idcard); @@ -42,11 +38,18 @@ log.info("请求公安实名认证接口,请求地址:" + URL); log.info("请求公安实名认证接口,请求参数:" + param); log.info("请求公安实名认证接口,请求头参数:" + headervalue + encodeToString); - String postByJson = HttpClientUtil.sendPostByJson(URL, param, 0, headerkey, headervalue + encodeToString); + String postByJson = HttpClientUtil.sendPostByJson(URL, param, 2, headerkey, headervalue + encodeToString); log.info("请求公安实名认证接口,返回参数:" + postByJson); - int code = JSONObject.parseObject(postByJson).getIntValue("code"); - if (0==code) { - result =true; + if(postByJson!=null && StringUtils.isNotEmpty(postByJson)) { + JSONObject obj = JSONObject.parseObject(postByJson); + if(obj!=null) { + int code = JSONObject.parseObject(postByJson).getIntValue("code"); + if (0 == code) { + result = true; + } + } + }else{ + throw new ServiceException("公安实名认证接口超时,请重试"); } return result; } -- Gitblit v1.7.1