优化返回体

This commit is contained in:
xiafang
2020-11-27 09:16:58 +08:00
parent dd36d2dbdb
commit ff6d7a3c3a

View File

@@ -2,8 +2,11 @@ package com.enongm.dianji.payment.wechat.v3;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import java.util.Objects;
/** /**
* @author Dax * @author Dax
* @since 13:20 * @since 13:20
@@ -17,9 +20,18 @@ public class WechatResponseEntity<T> {
public void convert(ResponseEntity<T> responseEntity) { public void convert(ResponseEntity<T> responseEntity) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.info("wechat response {}", responseEntity); log.debug("wechat response {}", responseEntity);
} }
if (Objects.nonNull(responseEntity)) {
this.httpStatus = responseEntity.getStatusCodeValue(); this.httpStatus = responseEntity.getStatusCodeValue();
this.body = responseEntity.getBody(); this.body = responseEntity.getBody();
} else {
this.httpStatus = HttpStatus.REQUEST_TIMEOUT.value();
this.body = null;
}
}
public boolean successful() {
return this.httpStatus == HttpStatus.OK.value();
} }
} }