1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| @RestController public class DeptConsumerController { @Autowired private RestTemplate restTemplate;
private static final String REST_URL_PREFIX = "http://localhost:8001/"; @RequestMapping("/comsumer/dept/get") public Dept get(@PathVariable("id") Long id){ return restTemplate.getForObject(REST_URL_PREFIX+"/dept/get?id="+id, Dept.class); }
@RequestMapping("/comsumer/dept/list") public List<Dept> queryAll(){ return restTemplate.getForObject(REST_URL_PREFIX+"/dept/list", List.class); } }
|