接口优化
This commit is contained in:
parent
c385341a79
commit
d03e995a37
@ -65,7 +65,6 @@ public class VerifyUtil {
|
||||
|
||||
/**
|
||||
* 微信工具类构造函数。
|
||||
*
|
||||
*/
|
||||
public VerifyUtil() throws IOException {
|
||||
client = new OkHttpClient();
|
||||
@ -77,7 +76,7 @@ public class VerifyUtil {
|
||||
* @param code 微信登录返回的code
|
||||
* @return openId
|
||||
*/
|
||||
public JSONObject wechatAuthority(String code){
|
||||
public JSONObject wechatAuthority(String code) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("appid", wechatConfig.getAppId());
|
||||
params.put("secret", wechatConfig.getAppSecret());
|
||||
@ -90,8 +89,8 @@ public class VerifyUtil {
|
||||
* 解密微信用户信息。
|
||||
*
|
||||
* @param encryptedData 加密数据
|
||||
* @param sessionKey 会话密钥
|
||||
* @param iv 初始向量
|
||||
* @param sessionKey 会话密钥
|
||||
* @param iv 初始向量
|
||||
* @return 解密后的用户信息
|
||||
*/
|
||||
public String decryptData(String encryptedData, String sessionKey, String iv) {
|
||||
@ -153,23 +152,22 @@ public class VerifyUtil {
|
||||
log.error("验证用户实名失败");
|
||||
return JsonResult.failed("验证用户实名失败");
|
||||
}
|
||||
if ("10000".equals(result.getString("code"))){
|
||||
if ("10000".equals(result.getString("code"))) {
|
||||
// 3. 解密结果
|
||||
String data = securityContext.decrypt(result.getString("data"), realNameVerifyConfig.getClientPrivateKey());
|
||||
JSONObject jsonData = JSON.parseObject(data);
|
||||
if("10000".equals(jsonData.getString("code"))&&"1".equals(jsonData.getJSONObject("data").getString("state"))){
|
||||
// 4. 更新用户实名信息
|
||||
String data = securityContext.decrypt(result.getString("data"), realNameVerifyConfig.getClientPrivateKey());
|
||||
JSONObject jsonData = JSON.parseObject(data);
|
||||
if ("10000".equals(jsonData.getString("code")) && "1".equals(jsonData.getJSONObject("data").getString("state"))) {
|
||||
// 4. 更新用户实名信息
|
||||
|
||||
return JsonResult.success("验证用户实名成功");
|
||||
}
|
||||
}else{
|
||||
log.error("验证用户实名失败,{} {}", result.getString("code"), result.getString("message"));
|
||||
return JsonResult.failed(result.getString("code") +", "+ result.getString("message"));
|
||||
return JsonResult.success("验证用户实名成功");
|
||||
}
|
||||
}
|
||||
}catch (EncryptFailureException e) {
|
||||
log.error("验证用户实名失败,{} {}", result.getString("code"), result.getString("message"));
|
||||
return JsonResult.failed(result.getString("code") + ", " + result.getString("message"));
|
||||
} catch (EncryptFailureException e) {
|
||||
log.error("加密失败", e);
|
||||
return JsonResult.failed("加密失败");
|
||||
}catch (SignFailureException e) {
|
||||
} catch (SignFailureException e) {
|
||||
log.error("签名失败", e);
|
||||
return JsonResult.failed("签名失败");
|
||||
} catch (DecryptFailureException e) {
|
||||
@ -181,8 +179,8 @@ public class VerifyUtil {
|
||||
/**
|
||||
* 发送HTTP GET请求。
|
||||
*
|
||||
* @param func_ 功能描述
|
||||
* @param url 请求URL
|
||||
* @param func_ 功能描述
|
||||
* @param url 请求URL
|
||||
* @param params 请求参数
|
||||
* @return 响应结果
|
||||
*/
|
||||
@ -206,7 +204,7 @@ public class VerifyUtil {
|
||||
}
|
||||
if (response.body() != null) {
|
||||
log.error("{}, 请求{}失败, {}", func_, url, response.body().string());
|
||||
}else {
|
||||
} else {
|
||||
log.error("{}, 请求{}失败", func_, url);
|
||||
}
|
||||
return null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user