Skip to content
Snippets Groups Projects
Commit 2c52f5b4 authored by Pierre-Louis BERTRAND's avatar Pierre-Louis BERTRAND
Browse files

add get student by id in API

parent fb9564e4
Branches
No related tags found
No related merge requests found
...@@ -22,6 +22,11 @@ public class StudentController { ...@@ -22,6 +22,11 @@ public class StudentController {
return studentService.findAll(); return studentService.findAll();
} }
@GetMapping("/{id}")
public Student getStudentById(@PathVariable Long id) {
return studentService.getById(id);
}
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public void deleteStudent(@PathVariable Long id) { public void deleteStudent(@PathVariable Long id) {
studentService.deleteById(id); studentService.deleteById(id);
......
...@@ -24,6 +24,10 @@ public class StudentService { ...@@ -24,6 +24,10 @@ public class StudentService {
return users ; return users ;
} }
public Student getById(Long id) {
return studentDao.findById(id).orElseThrow();
}
public void deleteById(Long id) { public void deleteById(Long id) {
studentDao.deleteById(id); studentDao.deleteById(id);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment