コード例 #1
0
 @RequestMapping(value = "/student/edit/{id}", method = RequestMethod.GET)
 public String editStudent(
     @PathVariable Long id, Model model, @RequestParam Optional<String> success) {
   Student student = schoolService.getStudent(id);
   model.addAttribute("student", student);
   model.addAttribute("courses", schoolService.getCourses());
   if (success.isPresent()) {
     model.addAttribute("success", true);
   }
   return "student";
 }
コード例 #2
0
 @RequestMapping(value = "/student/delete/{id}", method = RequestMethod.GET)
 public String deleteStudent(@PathVariable Long id) {
   schoolService.deleteStudent(id);
   return "redirect:/students";
 }
コード例 #3
0
 @RequestMapping(value = "/students", method = RequestMethod.GET)
 public String getStudents(Model model) {
   model.addAttribute("students", schoolService.getStudents());
   return "students";
 }
コード例 #4
0
 @RequestMapping(value = "/course/delete/{id}", method = RequestMethod.GET)
 public String deleteCourse(@PathVariable Long id) {
   schoolService.deleteCourse(id);
   return "redirect:/courses";
 }
コード例 #5
0
 @RequestMapping(value = "/course/edit/{id}", method = RequestMethod.GET)
 public String editCourse(@PathVariable Long id, Model model) {
   model.addAttribute("course", schoolService.getCourse(id));
   return "course";
 }
コード例 #6
0
 @RequestMapping(value = "/course/save", method = RequestMethod.POST)
 public String addCourse(@ModelAttribute Course course) {
   schoolService.saveCourse(course);
   return "redirect:/courses";
 }
コード例 #7
0
 @RequestMapping(value = "/courses", method = RequestMethod.GET)
 public String getCourses(Model model) {
   model.addAttribute("courses", schoolService.getCourses());
   return "courses";
 }
コード例 #8
0
 @RequestMapping(value = "/student/password", method = RequestMethod.POST)
 public String changePassword(@AuthenticationPrincipal User user, @RequestParam String password) {
   schoolService.changeStudentPassword(user, password);
   return "redirect:/?success=true";
 }
コード例 #9
0
 @RequestMapping(value = "/student/{studentId}/drop/{courseId}", method = RequestMethod.GET)
 public String dropCourse(@PathVariable Long studentId, @PathVariable Long courseId) {
   schoolService.dropCourse(studentId, courseId);
   return "redirect:/student/edit/" + studentId;
 }
コード例 #10
0
 @RequestMapping(value = "/student/save", method = RequestMethod.POST)
 public String saveStudent(
     @ModelAttribute Student student, @RequestParam Optional<String> password) {
   schoolService.saveStudent(student, password);
   return "redirect:/student/edit/" + student.getId() + "?success=true";
 }