blob: c7b38047816cb60519cb0bcde36ed81d56fbf60a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package com.example.spring.bank.account;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.restclient.RestTemplateBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class AccountService {
@Value("${rest.baseURL}")
private String restBaseURL;
private final RestTemplate restTemplate;
public AccountService(RestTemplateBuilder restTemplateBuilder) {
this.restTemplate = restTemplateBuilder.build();
}
public Account getAccount(Integer accno) {
return this.restTemplate.getForObject(restBaseURL + "/account/{accno}", Account.class, accno);
}
}
|