package cn.hhj.controller; import cn.hhj.service.IDeptService; import cn.hhj.vo.Dept; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; @RestController public class DeptRest { @Autowired private IDeptService deptService; @Autowired private DiscoveryClient discoveryClient; // Eureka的发现服务 @RequestMapping("/dept/discover") public Object discover(){ // 直接返回发现服务信息 return this.discoveryClient; } @GetMapping("/dept/sessionId") public Object id(HttpServletRequest request){ return request.getSession().getId(); } @GetMapping("/dept/get/{id}") public Object get(@PathVariable("id") long id) { return this.deptService.get(id); } @PostMapping("/dept/add") public Object add(Dept dept) { return this.deptService.add(dept); } @GetMapping( "/dept/list") public Object list() { return this.deptService.list(); } }