@@ -0,0 +1,120 @@ | |||||
package com.ningdatech.pmapi.provincial.model.res; | |||||
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 ZPF | |||||
* @since 14:29 2022/9/29 | |||||
*/ | |||||
@Data | |||||
@NoArgsConstructor | |||||
public class SjApiResponse<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 msg; | |||||
/** | |||||
* 返回数据 | |||||
*/ | |||||
private T data; | |||||
/** | |||||
* 全参构造函数 | |||||
* | |||||
* @param code 状态码 | |||||
* @param msg 返回内容 | |||||
* @param data 返回数据 | |||||
*/ | |||||
private SjApiResponse(Integer code, String msg, T data) { | |||||
this.code = code; | |||||
this.msg = msg; | |||||
this.data = data; | |||||
} | |||||
/** | |||||
* 构造一个自定义的API返回 | |||||
* | |||||
* @param code 状态码 | |||||
* @param msg 返回内容 | |||||
* @param data 返回数据 | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> of(Integer code, String msg, T data) { | |||||
return new SjApiResponse<T>(code, msg, data); | |||||
} | |||||
/** | |||||
* 构造一个成功且不带数据的API返回 | |||||
* | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> ofSuccess() { | |||||
return ofSuccess(null); | |||||
} | |||||
/** | |||||
* 构造一个成功且带数据的API返回 | |||||
* | |||||
* @param data 返回数据 | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> ofSuccess(T data) { | |||||
return ofStatus(Status.OK, data); | |||||
} | |||||
/** | |||||
* 构造一个成功且自定义消息的API返回 | |||||
* | |||||
* @param msg 返回内容 | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> ofMessage(String msg) { | |||||
return of(Status.OK.getCode(), msg, null); | |||||
} | |||||
/** | |||||
* 构造一个有状态的API返回 | |||||
* | |||||
* @param status 状态 {@link Status} | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> ofStatus(ApiStatus status) { | |||||
return ofStatus(status, null); | |||||
} | |||||
/** | |||||
* 构造一个有状态且带数据的API返回 | |||||
* | |||||
* @param status 状态 {@link Status} | |||||
* @param data 返回数据 | |||||
* @return ApiResponse | |||||
*/ | |||||
public static <T> SjApiResponse<T> ofStatus(ApiStatus status, T data) { | |||||
return of(status.getCode(), status.getReasonPhrase(), data); | |||||
} | |||||
} |
@@ -1,7 +1,7 @@ | |||||
package com.ningdatech.pmapi.provincial.service; | package com.ningdatech.pmapi.provincial.service; | ||||
import com.ningdatech.basic.model.ApiResponse; | |||||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | ||||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||||
/** | /** | ||||
* @Classname JointReviewProvincialBureauService | * @Classname JointReviewProvincialBureauService | ||||
@@ -22,5 +22,5 @@ public interface IJoinReviewProvincialBureauService { | |||||
* 查看 本区域 省局联审 的项目审核详情 | * 查看 本区域 省局联审 的项目审核详情 | ||||
* @return | * @return | ||||
*/ | */ | ||||
ApiResponse processInfo(String projectId); | |||||
SjApiResponse processInfo(String projectId); | |||||
} | } |
@@ -8,6 +8,7 @@ import com.ningdatech.basic.model.ApiResponse; | |||||
import com.ningdatech.pmapi.common.config.ProvincialProperties; | import com.ningdatech.pmapi.common.config.ProvincialProperties; | ||||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | ||||
import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; | import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; | ||||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||||
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; | import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
@@ -80,13 +81,13 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc | |||||
* @return | * @return | ||||
*/ | */ | ||||
@Override | @Override | ||||
public ApiResponse processInfo(String projectId) { | |||||
public SjApiResponse processInfo(String projectId) { | |||||
Long timeStamp = System.currentTimeMillis()/1000; | Long timeStamp = System.currentTimeMillis()/1000; | ||||
String url = provincialProperties.getHost() + provincialProperties.getDetailUrl() | String url = provincialProperties.getHost() + provincialProperties.getDetailUrl() | ||||
+ "?timestamp=" + timeStamp; | + "?timestamp=" + timeStamp; | ||||
log.info("省局获取审核详情 url {}",url); | log.info("省局获取审核详情 url {}",url); | ||||
ResponseEntity<ApiResponse> responseEntity = null; | |||||
ResponseEntity<SjApiResponse> responseEntity = null; | |||||
String signature = getSha256(timeStamp,provincialProperties.getDetailUrl(), | String signature = getSha256(timeStamp,provincialProperties.getDetailUrl(), | ||||
HttpMethod.POST.name()); | HttpMethod.POST.name()); | ||||
@@ -104,7 +105,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc | |||||
.body(jsonBaby); //也可以是DTO | .body(jsonBaby); //也可以是DTO | ||||
try { | try { | ||||
responseEntity = restTemplate.exchange(requestEntity,ApiResponse.class); | |||||
responseEntity = restTemplate.exchange(requestEntity,SjApiResponse.class); | |||||
log.info("获取审批详情 响应 :{}",responseEntity); | log.info("获取审批详情 响应 :{}",responseEntity); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log.error("[省局获取审核详情] http request error", e); | log.error("[省局获取审核详情] http request error", e); | ||||