From 2164e9b9894c5af2966d86644dc97edd7c1541a6 Mon Sep 17 00:00:00 2001 From: WeiRan <2392355487@qq.com> Date: Mon, 9 Sep 2024 16:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=9A=E5=90=88=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RealNameServiceImpl.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/cloud-juhe-server/src/main/java/com/muyu/data/mart/service/impl/RealNameServiceImpl.java b/cloud-juhe-server/src/main/java/com/muyu/data/mart/service/impl/RealNameServiceImpl.java index 4b231e0..b76f9f6 100644 --- a/cloud-juhe-server/src/main/java/com/muyu/data/mart/service/impl/RealNameServiceImpl.java +++ b/cloud-juhe-server/src/main/java/com/muyu/data/mart/service/impl/RealNameServiceImpl.java @@ -2,6 +2,7 @@ package com.muyu.data.mart.service.impl; +import com.alibaba.fastjson.JSONObject; import com.muyu.cloud.background.common.BasicApi; import com.muyu.cloud.background.domin.juhe.JuHeResult; import com.muyu.cloud.background.domin.realname.RealNameReq; @@ -76,27 +77,27 @@ public class RealNameServiceImpl implements BasicApi{ } in.close(); System.out.println(response); -// //{"reason":"参数错误:身份证不合法","result":null,"error_code":210304} 或 -// //{"reason":"成功","result":{"realname":"魏然","idcard":"321183200303152916","res":1},"error_code":0} -// StringBuffer stringBuffer = new StringBuffer(response); -// JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString()); -// String reason = jsonObject.getString("reason"); -// JSONObject resultObj = jsonObject.getJSONObject("result"); -// String realname = resultObj.getString("realname"); -// String idcard = resultObj.getString("idcard"); -// int res = resultObj.getIntValue("res"); -// int errorCode = jsonObject.getIntValue("error_code"); -// return new JuHeResult(){{ -// setErrorCode(errorCode); -// setReason(reason); -// setResult( -// RealNameJuHeResp.builder() -// .realName(realname) -// .idCard(idcard) -// .res(res) -// .build() -// ); -// }}; + //{"reason":"参数错误:身份证不合法","result":null,"error_code":210304} 或 + //{"reason":"成功","result":{"realname":"魏然","idcard":"321183200303152916","res":1},"error_code":0} + StringBuffer stringBuffer = new StringBuffer(response); + JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString()); + String reason = jsonObject.getString("reason"); + JSONObject resultObj = jsonObject.getJSONObject("result"); + String realname = resultObj.getString("realname"); + String idcard = resultObj.getString("idcard"); + int res = resultObj.getIntValue("res"); + int errorCode = jsonObject.getIntValue("error_code"); + return new JuHeResult(){{ + setErrorCode(errorCode); + setReason(reason); + setResult( + RealNameJuHeResp.builder() + .realName(realname) + .idCard(idcard) + .res(res) + .build() + ); + }}; // return new JuHeResult(){{ // setErrorCode(0); @@ -109,7 +110,7 @@ public class RealNameServiceImpl implements BasicApi{ // .build() // ); // }}; - return null; + }