From d0ea71864a0cf590e0cb20b3fae1f12eb2e3e3a0 Mon Sep 17 00:00:00 2001
From: PoffyZhang <99775271@qq.com>
Date: Tue, 11 Jul 2023 13:45:03 +0800
Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=A7=E9=A1=B9=E7=9B=AE=E8=81=94?=
=?UTF-8?q?=E5=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../provincial/model/dto/ProvinceApiResponse.java | 121 +++++++++++++++++++++
.../JoinReviewProvincialBureauServiceImpl.java | 6 +-
2 files changed, 124 insertions(+), 3 deletions(-)
create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java
new file mode 100644
index 0000000..b966f62
--- /dev/null
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java
@@ -0,0 +1,121 @@
+package com.ningdatech.pmapi.provincial.model.dto;
+
+import com.ningdatech.basic.enumeration.Status;
+import com.ningdatech.basic.model.ApiStatus;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ *
+ * ApiResponse - 统一的接口返回值封装
+ *
+ *
+ * @author WendyYang
+ * @since 14:29 2022/9/29
+ */
+@Data
+@NoArgsConstructor
+public class ProvinceApiResponse implements Serializable {
+ private static final long serialVersionUID = 532384723325394156L;
+
+ public static final int SUCCESS_CODE = 200;
+
+ public static final String SUCCESS_MSG = "success";
+
+ public static final int ERROR_CODE = 500;
+
+ public static final String ERROR_MSG = "Internal server error";
+
+ /**
+ * 状态码
+ */
+ private Integer code;
+
+ /**
+ * 返回内容
+ */
+ private String message;
+ private String msg;
+
+ /**
+ * 返回数据
+ */
+ private T data;
+
+ /**
+ * 全参构造函数
+ *
+ * @param code 状态码
+ * @param message 返回内容
+ * @param data 返回数据
+ */
+ private ProvinceApiResponse(Integer code, String message, T data) {
+ this.code = code;
+ this.message = message;
+ this.data = data;
+ }
+
+ /**
+ * 构造一个自定义的API返回
+ *
+ * @param code 状态码
+ * @param message 返回内容
+ * @param data 返回数据
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse of(Integer code, String message, T data) {
+ return new ProvinceApiResponse(code, message, data);
+ }
+
+ /**
+ * 构造一个成功且不带数据的API返回
+ *
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse ofSuccess() {
+ return ofSuccess(null);
+ }
+
+ /**
+ * 构造一个成功且带数据的API返回
+ *
+ * @param data 返回数据
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse ofSuccess(T data) {
+ return ofStatus(Status.OK, data);
+ }
+
+ /**
+ * 构造一个成功且自定义消息的API返回
+ *
+ * @param message 返回内容
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse ofMessage(String message) {
+ return of(Status.OK.getCode(), message, null);
+ }
+
+ /**
+ * 构造一个有状态的API返回
+ *
+ * @param status 状态 {@link Status}
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse ofStatus(ApiStatus status) {
+ return ofStatus(status, null);
+ }
+
+ /**
+ * 构造一个有状态且带数据的API返回
+ *
+ * @param status 状态 {@link Status}
+ * @param data 返回数据
+ * @return ApiResponse
+ */
+ public static ProvinceApiResponse ofStatus(ApiStatus status, T data) {
+ return of(status.getCode(), status.getReasonPhrase(), data);
+ }
+}
diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java
index 8a7e762..d5d12f9 100644
--- a/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java
+++ b/pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java
@@ -6,8 +6,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ningdatech.basic.model.ApiResponse;
import com.ningdatech.pmapi.common.config.ProvincialProperties;
+import com.ningdatech.pmapi.provincial.model.dto.ProvinceApiResponse;
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO;
-import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes;
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse;
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService;
import lombok.extern.slf4j.Slf4j;
@@ -45,7 +45,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
String url = provincialProperties.getHost() + provincialProperties.getPushUrl()
+ "?timestamp=" + timeStamp;
log.info("省局推送联审url {}",url);
- ResponseEntity responseEntity = null;
+ ResponseEntity responseEntity = null;
String signature = getSha256(timeStamp,provincialProperties.getPushUrl(),
HttpMethod.POST.name());
@@ -63,7 +63,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
log.info("省局联审 提交 :{}", requestEntity);
log.info("省局联审 提交body :{}", JSON.toJSONString(requestEntity.getBody()));
try {
- responseEntity = restTemplate.exchange(requestEntity, ApiResponse.class);
+ responseEntity = restTemplate.exchange(requestEntity, ProvinceApiResponse.class);
log.info("省局联审 响应 :{}",responseEntity);
if(responseEntity.getBody().getCode().equals(200)){
return Boolean.TRUE;