feat:更新快速开发的demo工程
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package ai.remi.demo.api.client;
|
||||
|
||||
import ai.remi.demo.api.factory.FeignClientFactory;
|
||||
import ai.remi.comm.feign.aspect.FeignAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(value = "remi-demo-web", configuration = FeignAutoConfiguration.class, fallbackFactory = FeignClientFactory.class)
|
||||
public interface FeignClientApi {
|
||||
|
||||
@GetMapping("/books/findByBooksId")
|
||||
String findById(@RequestParam("booksId") int booksId);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package ai.remi.demo.api.factory;
|
||||
|
||||
import ai.remi.demo.api.client.FeignClientApi;
|
||||
import ai.remi.demo.api.fallback.FeignClientFallback;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class FeignClientFactory implements FallbackFactory<FeignClientApi> {
|
||||
|
||||
@Override
|
||||
public FeignClientApi create(Throwable cause) {
|
||||
FeignClientFallback fallback = new FeignClientFallback();
|
||||
fallback.setCause(cause);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package ai.remi.demo.api.fallback;
|
||||
|
||||
import ai.remi.demo.api.client.FeignClientApi;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class FeignClientFallback implements FeignClientApi {
|
||||
@Setter
|
||||
private Throwable cause;
|
||||
|
||||
@Override
|
||||
public String findById(int goodsId) {
|
||||
log.error("findById = {}", cause.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user