|
@@ -2,6 +2,7 @@ package com.diagbot.util;
|
|
|
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
|
|
|
/**
|
|
|
* @Description: 结果验证工具类
|
|
@@ -12,11 +13,12 @@ public class RespDTOUtil {
|
|
|
|
|
|
/**
|
|
|
* 远程调度是否成功
|
|
|
+ *
|
|
|
* @param respDTO 返回结果
|
|
|
- * @param <T> 泛型
|
|
|
+ * @param <T> 泛型
|
|
|
* @return 是否成功
|
|
|
*/
|
|
|
- public static <T> boolean respIsOK(RespDTO<T> respDTO){
|
|
|
+ public static <T> boolean respIsOK(RespDTO<T> respDTO) {
|
|
|
if (null == respDTO
|
|
|
|| null == respDTO.data
|
|
|
|| !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
@@ -28,11 +30,12 @@ public class RespDTOUtil {
|
|
|
|
|
|
/**
|
|
|
* 远程调度是否不成功
|
|
|
+ *
|
|
|
* @param respDTO 返回结果
|
|
|
- * @param <T> 泛型
|
|
|
+ * @param <T> 泛型
|
|
|
* @return 是否成功
|
|
|
*/
|
|
|
- public static <T> boolean respIsNG(RespDTO<T> respDTO){
|
|
|
+ public static <T> boolean respIsNG(RespDTO<T> respDTO) {
|
|
|
if (null == respDTO
|
|
|
|| null == respDTO.data
|
|
|
|| !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
@@ -40,4 +43,41 @@ public class RespDTOUtil {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调度不成功错误处理(错误不直接覆盖)
|
|
|
+ *
|
|
|
+ * @param respDTO 返回结果
|
|
|
+ * @param errmsg 错误信息
|
|
|
+ * @param <T> 泛型
|
|
|
+ */
|
|
|
+ public static <T> void respNGDeal(RespDTO<T> respDTO, String errmsg) {
|
|
|
+ respNGDeal(respDTO, false,errmsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 远程调度不成功错误处理(错误直接覆盖)
|
|
|
+ *
|
|
|
+ * @param respDTO 返回结果
|
|
|
+ * @param errmsg 错误信息
|
|
|
+ * @param <T> 泛型
|
|
|
+ */
|
|
|
+ public static <T> void respNGDealCover(RespDTO<T> respDTO, String errmsg) {
|
|
|
+ respNGDeal(respDTO, true,errmsg);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static <T> void respNGDeal(RespDTO<T> respDTO, Boolean isCover, String errmsg) {
|
|
|
+ if (null == respDTO
|
|
|
+ || null == respDTO.data
|
|
|
+ || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
+ if (!isCover){
|
|
|
+ if (StringUtil.isNotBlank(respDTO.msg)) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, respDTO.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, errmsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|