From ff6d7a3c3aafc6a0feee5e6197cc9395bffa4e68 Mon Sep 17 00:00:00 2001 From: xiafang Date: Fri, 27 Nov 2020 09:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=94=E5=9B=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechat/v3/WechatResponseEntity.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java index e7f7435..687bc92 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java +++ b/payment-spring-boot-autoconfigure/src/main/java/com/enongm/dianji/payment/wechat/v3/WechatResponseEntity.java @@ -2,8 +2,11 @@ package com.enongm.dianji.payment.wechat.v3; import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import java.util.Objects; + /** * @author Dax * @since 13:20 @@ -17,9 +20,18 @@ public class WechatResponseEntity { public void convert(ResponseEntity responseEntity) { if (log.isDebugEnabled()) { - log.info("wechat response {}", responseEntity); + log.debug("wechat response {}", responseEntity); } - this.httpStatus = responseEntity.getStatusCodeValue(); - this.body = responseEntity.getBody(); + if (Objects.nonNull(responseEntity)) { + this.httpStatus = responseEntity.getStatusCodeValue(); + this.body = responseEntity.getBody(); + } else { + this.httpStatus = HttpStatus.REQUEST_TIMEOUT.value(); + this.body = null; + } + } + + public boolean successful() { + return this.httpStatus == HttpStatus.OK.value(); } }