diff --git a/orgmanax-integration/src/main/java/cn/axzo/orgmanax/integration/core/RpcWrapper.java b/orgmanax-integration/src/main/java/cn/axzo/orgmanax/integration/core/RpcWrapper.java index 055a39d..5da3dd5 100644 --- a/orgmanax-integration/src/main/java/cn/axzo/orgmanax/integration/core/RpcWrapper.java +++ b/orgmanax-integration/src/main/java/cn/axzo/orgmanax/integration/core/RpcWrapper.java @@ -2,7 +2,9 @@ package cn.axzo.orgmanax.integration.core; import cn.axzo.apollo.core.web.Result; import cn.axzo.foundation.exception.BusinessException; +import cn.axzo.framework.domain.web.result.ApiResult; import cn.axzo.orgmanax.common.config.BizResultCode; +import cn.azxo.framework.common.model.CommonResponse; import cn.hutool.core.convert.Convert; import cn.hutool.http.HttpStatus; import lombok.extern.slf4j.Slf4j; @@ -29,4 +31,38 @@ public class RpcWrapper { } return result.getData(); } + + /** + * common res 返回 + * @param t + * @return + * @param + */ + public static T commonRes(Supplier> t) { + CommonResponse result = t.get(); + if (result == null) { + throw new BusinessException(BizResultCode.RPC_ERROR); + } + if (!Objects.equals(result.getCode(), HttpStatus.HTTP_OK)) { + throw new BusinessException(Convert.toStr(result.getCode()), result.getMsg(), null); + } + return result.getData(); + } + + /** + * Api result 返回 + * @param supplier + * @return + * @param + */ + protected T wrapApiResult(Supplier> supplier) { + ApiResult result = supplier.get(); + if (result == null) { + throw new BusinessException(BizResultCode.RPC_ERROR); + } + if (!Objects.equals(result.getCode(), HttpStatus.HTTP_OK)) { + throw new BusinessException(Convert.toStr(result.getCode()), result.getMsg(), null); + } + return result.getData(); + } }