2424import org .springframework .boot .SpringApplication ;
2525import org .springframework .boot .autoconfigure .SpringBootApplication ;
2626import org .springframework .context .annotation .Bean ;
27+ import org .springframework .http .HttpEntity ;
28+ import org .springframework .http .ResponseEntity ;
2729import org .springframework .stereotype .Controller ;
28- import org .springframework .web .bind .annotation .*;
30+ import org .springframework .web .bind .annotation .RequestMapping ;
31+ import org .springframework .web .bind .annotation .RequestParam ;
32+ import org .springframework .web .bind .annotation .ResponseBody ;
33+ import org .springframework .web .client .RestTemplate ;
2934
3035import javax .sql .DataSource ;
3136import java .sql .Connection ;
3237import java .sql .ResultSet ;
3338import java .sql .SQLException ;
3439import java .sql .Statement ;
40+ import java .text .MessageFormat ;
3541import java .util .ArrayList ;
36- import java .util .List ;
3742import java .util .Map ;
3843
3944@ Controller
@@ -43,6 +48,9 @@ public class Main {
4348 @ Value ("${spring.datasource.url}" )
4449 private String dbUrl ;
4550
51+ @ Value ("${test-app.url}" )
52+ private String testUrl ;
53+
4654 @ Autowired
4755 private DataSource dataSource ;
4856
@@ -76,7 +84,6 @@ String db(Map<String, Object> model) {
7684 }
7785 }
7886
79- //Save a account to the postgres DB
8087 @ RequestMapping (value = "/account" )
8188 public @ ResponseBody
8289 Result saveSfContact (@ RequestParam (name = "name" ) String name , @ RequestParam (name = "id" )String id ) {
@@ -95,6 +102,15 @@ Result saveSfContact(@RequestParam(name = "name") String name, @RequestParam(nam
95102 return result ;
96103 }
97104
105+ @ RequestMapping (value = "/get-account" )
106+ public @ ResponseBody
107+ Result getSfContact (@ RequestParam (name = "name" ) String name , @ RequestParam (name = "id" )String id ) {
108+ RestTemplate restTemplate = new RestTemplate ();
109+ String formattedQuoteUrl = MessageFormat .format (testUrl , name , id );
110+ ResponseEntity <Result > result = restTemplate .getForEntity (formattedQuoteUrl , Result .class );
111+ return result .getBody ();
112+ }
113+
98114 @ Bean
99115 public DataSource dataSource () throws SQLException {
100116 if (dbUrl == null || dbUrl .isEmpty ()) {
0 commit comments