接口优化

This commit is contained in:
dzl 2025-05-29 18:24:27 +08:00
parent c385341a79
commit d03e995a37

View File

@ -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());
@ -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"))){
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"));
}
}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) {
@ -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;