在domain包的feign文件夹中建立要请求的Gateway文件
public interface PMCServiceGateway {
List<ProjectResultDTO> projectInfoList( List<String> projectIds);
String getBasicProjectInfo(String id);
}
在infrastructure中的feign包下写对应的实现类
@Component
@Slf4j
@RequiredArgsConstructor
public class PMCServiceGatewayImpl implements PMCServiceGateway {
private final ApiPMCService apiPMCService;}
在infrastructure中的feign的api下写对应的调用接口,利用@FeignClient注解确定调用的程序,value值为nacos的服务
@FeignClient(value = "qfc-business-pmc")
public interface ApiPMCService {
@PostMapping("/project/config/projectInfoList")
Result<List<ProjectResultDTO>> projectInfoList(@RequestBody List<String> projectIds);
@GetMapping("/project/config/getBasicProjectInfo")
Result<ProjectInfoDTO>getBasicProjectInfo(@RequestParam String id);
}
也可以用如下代码调用本地接口
@FeignClient(value = "qfc-business-bcc", url = "http://localhost:8091",contextId="1")
contextId字段用来编号,防止重复