BAEL-5300: add payment resources code

This commit is contained in:
sharifi 2022-01-31 10:49:51 +03:30
parent d1ef70e63d
commit e459737a66
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package com.baeldung.cloud.openfeign.client;
import com.baeldung.cloud.openfeign.model.Payment;
import com.baeldung.cloud.openfeign.oauthfeign.OAuthFeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
@FeignClient(name = "payment-client", url = "http://localhost:8081/resource-server-jwt", configuration = OAuthFeignConfig.class)
public interface PaymentClient {
@RequestMapping(value = "/payments", method = RequestMethod.GET)
List<Payment> getPayments();
}

View File

@ -0,0 +1,24 @@
package com.baeldung.cloud.openfeign.controller;
import com.baeldung.cloud.openfeign.client.PaymentClient;
import com.baeldung.cloud.openfeign.model.Payment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class PaymentController {
private final PaymentClient paymentClient;
public PaymentController(PaymentClient paymentClient) {
this.paymentClient = paymentClient;
}
@GetMapping("/payments")
public List<Payment> getPayments() {
List<Payment> payments = paymentClient.getPayments();
return payments;
}
}

View File

@ -0,0 +1,23 @@
package com.baeldung.cloud.openfeign.model;
public class Payment {
private String id;
private double amount;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
}