Bladeren bron

重大项目联审

master
PoffyZhang 1 jaar geleden
bovenliggende
commit
d0ea71864a
2 gewijzigde bestanden met toevoegingen van 124 en 3 verwijderingen
  1. +121
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java
  2. +3
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java

+ 121
- 0
pmapi/src/main/java/com/ningdatech/pmapi/provincial/model/dto/ProvinceApiResponse.java Bestand weergeven

@@ -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;

/**
* <p>
* ApiResponse - 统一的接口返回值封装
* </p>
*
* @author WendyYang
* @since 14:29 2022/9/29
*/
@Data
@NoArgsConstructor
public class ProvinceApiResponse<T> 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 <T> ProvinceApiResponse<T> of(Integer code, String message, T data) {
return new ProvinceApiResponse<T>(code, message, data);
}

/**
* 构造一个成功且不带数据的API返回
*
* @return ApiResponse
*/
public static <T> ProvinceApiResponse<T> ofSuccess() {
return ofSuccess(null);
}

/**
* 构造一个成功且带数据的API返回
*
* @param data 返回数据
* @return ApiResponse
*/
public static <T> ProvinceApiResponse<T> ofSuccess(T data) {
return ofStatus(Status.OK, data);
}

/**
* 构造一个成功且自定义消息的API返回
*
* @param message 返回内容
* @return ApiResponse
*/
public static <T> ProvinceApiResponse<T> ofMessage(String message) {
return of(Status.OK.getCode(), message, null);
}

/**
* 构造一个有状态的API返回
*
* @param status 状态 {@link Status}
* @return ApiResponse
*/
public static <T> ProvinceApiResponse<T> ofStatus(ApiStatus status) {
return ofStatus(status, null);
}

/**
* 构造一个有状态且带数据的API返回
*
* @param status 状态 {@link Status}
* @param data 返回数据
* @return ApiResponse
*/
public static <T> ProvinceApiResponse<T> ofStatus(ApiStatus status, T data) {
return of(status.getCode(), status.getReasonPhrase(), data);
}
}

+ 3
- 3
pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java Bestand weergeven

@@ -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<ApiResponse> responseEntity = null;
ResponseEntity<ProvinceApiResponse> 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;


Laden…
Annuleren
Opslaan