修改FeignClient接口名称和服务降级处理类名称及路径

This commit is contained in:
wr
2025-03-25 20:29:59 +08:00
parent 3ced1ce287
commit 92aa6063eb
5 changed files with 28 additions and 20 deletions

View File

@@ -2,7 +2,7 @@ package com.njcn.algorithm.pojo.liteflow;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.fallback.LiteFlowFeignClientFallbackFactory;
import com.njcn.algorithm.pojo.liteflow.fallback.LiteFlowAlgorithmFeignClientFallbackFactory;
import com.njcn.common.pojo.constant.ServerInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
@@ -13,11 +13,11 @@ import org.springframework.web.bind.annotation.RequestBody;
* @author xuyang
*/
@FeignClient(
value = ServerInfo.DATA_PLATFORM,//对应模块名
path = "/executor",//对应controller请求类
fallbackFactory = LiteFlowFeignClientFallbackFactory.class//服务降级处理类
value = ServerInfo.ALGORITHM_BOOT,//对应模块名
path = "/algorithmExecutor",//对应controller请求类
fallbackFactory = LiteFlowAlgorithmFeignClientFallbackFactory.class//服务降级处理类
)
public interface LiteFlowFeignClient {
public interface LiteFlowAlgorithmFeignClient {
@ApiOperation("监测点算法执行链")
@PostMapping("/measurementPointExecutor")

View File

@@ -1,7 +1,7 @@
package com.njcn.algorithm.pojo.liteflow.fallback;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.LiteFlowFeignClient;
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
import com.njcn.algorithm.pojo.util.PrepareEnumUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -11,9 +11,9 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public class LiteFlowFeignClientFallbackFactory implements FallbackFactory<LiteFlowFeignClient> {
public class LiteFlowAlgorithmFeignClientFallbackFactory implements FallbackFactory<LiteFlowAlgorithmFeignClient> {
@Override
public LiteFlowFeignClient create(Throwable throwable) {
public LiteFlowAlgorithmFeignClient create(Throwable throwable) {
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException)throwable.getCause();
@@ -21,7 +21,7 @@ public class LiteFlowFeignClientFallbackFactory implements FallbackFactory<LiteF
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new LiteFlowFeignClient() {
return new LiteFlowAlgorithmFeignClient() {
@Override
public void measurementPointExecutor(BaseParam baseParam) {
log.error("{}异常,降级处理,异常为:{}", "监测点算法执行链: ", throwable.toString());