DeptRest.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package cn.hhj.controller;
  2. import cn.hhj.service.IDeptService;
  3. import cn.hhj.vo.Dept;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.cloud.client.discovery.DiscoveryClient;
  6. import org.springframework.web.bind.annotation.*;
  7. import javax.servlet.http.HttpServletRequest;
  8. @RestController
  9. public class DeptRest {
  10. @Autowired
  11. private IDeptService deptService;
  12. @Autowired
  13. private DiscoveryClient discoveryClient; // Eureka的发现服务
  14. @RequestMapping("/dept/discover")
  15. public Object discover(){ // 直接返回发现服务信息
  16. return this.discoveryClient;
  17. }
  18. @GetMapping("/dept/sessionId")
  19. public Object id(HttpServletRequest request){
  20. return request.getSession().getId();
  21. }
  22. @GetMapping("/dept/get/{id}")
  23. public Object get(@PathVariable("id") long id) {
  24. return this.deptService.get(id);
  25. }
  26. @PostMapping("/dept/add")
  27. public Object add(Dept dept) {
  28. return this.deptService.add(dept);
  29. }
  30. @GetMapping( "/dept/list")
  31. public Object list() {
  32. return this.deptService.list();
  33. }
  34. }