治理暂态事件、文件解析功能

This commit is contained in:
2023-09-07 20:37:25 +08:00
parent 58feaf2aa0
commit d537021ffd
37 changed files with 1466 additions and 179 deletions

View File

@@ -0,0 +1,18 @@
package com.njcn.access.api;
import com.njcn.access.api.fallback.CsTopicClientFallbackFactory;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.ACCESS_BOOT, path = "/topic", fallbackFactory = CsTopicClientFallbackFactory.class,contextId = "topic")
public interface CsTopicFeignClient {
@PostMapping("/find")
HttpResult<String> find(@RequestParam("nDid") String nDid);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.access.api.fallback;
import com.njcn.access.api.CsTopicFeignClient;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class CsTopicClientFallbackFactory implements FallbackFactory<CsTopicFeignClient> {
@Override
public CsTopicFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsTopicFeignClient() {
@Override
public HttpResult<String> find(String nDid) {
log.error("{}异常,降级处理,异常为:{}","获取设备支持的主题版本",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}