bug修改
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package com.njcn.device.pq.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.fallback.TerminalBaseClientFallbackFactory;
|
||||
import com.njcn.device.pq.pojo.dto.transformer.EntityLogicDTO;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:02
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.DEVICE, path = "/pqsTransformer", fallbackFactory = TerminalBaseClientFallbackFactory.class, contextId = "pqsTransformer")
|
||||
public interface TransformerClient {
|
||||
|
||||
|
||||
HttpResult<List<EntityLogicDTO>> getLogic();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.njcn.device.pq.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.biz.utils.DeviceEnumUtil;
|
||||
import com.njcn.device.pq.api.TerminalBaseClient;
|
||||
import com.njcn.device.pq.api.TransformerClient;
|
||||
import com.njcn.device.pq.pojo.dto.transformer.EntityLogicDTO;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年02月14日 14:03
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TransformerClientFallbackFactory implements FallbackFactory<TransformerClient> {
|
||||
@Override
|
||||
public TransformerClient create(Throwable throwable) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (throwable.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) throwable.getCause();
|
||||
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new TransformerClient()
|
||||
{
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EntityLogicDTO>> getLogic() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user