@RequestMapping(value="/dept", method = RequestMethod.GET) public ResponseEntity<List<DeptJson>> listAllDepts() { Iterable<Department> depts = deptRepo.findAll(); List<DeptJson> deptJsons = new ArrayList<DeptJson>(); if(depts==null){ return new ResponseEntity<List<DeptJson>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND } else { for (Department dept: depts) { DeptJson deptJson = new DeptJson(dept, dept.getEmps()); deptJsons.add(deptJson); } return new ResponseEntity<List<DeptJson>>(deptJsons, HttpStatus.OK); } } //-------------------Retrieve One Departments by Dept Id-------------------
@RequestMapping(value="/dept", method = RequestMethod.GET) public ResponseEntity<List<DeptJson>> listAllDepts() { Iterable<Department> depts = deptRepo.findAll(); List<DeptJson> deptJsons = new ArrayList<DeptJson>(); if(depts==null){ return new ResponseEntity<List<DeptJson>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND } else { for (Department dept: depts) { DeptJson deptJson = new DeptJson(dept, dept.getEmps()); deptJsons.add(deptJson); } return new ResponseEntity<List<DeptJson>>(deptJsons, HttpStatus.OK); } } //-------------------Retrieve One Departments by Dept Id-------------------
@RequestMapping(value="/dept", method = RequestMethod.GET) public ResponseEntity<List<DeptJson>> listAllDepts() { Iterable<Department> depts = deptRepo.findAll(); List<DeptJson> deptJsons = new ArrayList<DeptJson>(); if(depts==null){ return new ResponseEntity<List<DeptJson>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND } else { for (Department dept: depts) { DeptJson deptJson = new DeptJson(dept, dept.getEmps()); deptJsons.add(deptJson); } return new ResponseEntity<List<DeptJson>>(deptJsons, HttpStatus.OK); } } //-------------------Retrieve One Departments by Dept Id-------------------