23 lines
658 B
Java
23 lines
658 B
Java
package cn.hezhaohui.serviceconsumer.controller;
|
|||
|
|
|
||
|
|
import jakarta.annotation.Resource;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
import org.springframework.web.client.RestTemplate;
|
||
|
|
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api")
|
||
|
|
public class ConsumeController {
|
||
|
|
|
||
|
|
@Resource
|
||
|
|
private RestTemplate restTemplate;
|
||
|
|
|
||
|
|
@GetMapping("/print")
|
||
|
|
public String print() {
|
||
|
|
String number = restTemplate.getForObject("http://service-producer/api/number", String.class);
|
||
|
|
return "[Generate]: " + number;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|