예제 #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";
 }
 @RequestMapping(value = "/student/delete/{id}", method = RequestMethod.GET)
 public String deleteStudent(@PathVariable Long id) {
   schoolService.deleteStudent(id);
   return "redirect:/students";
 }
 @RequestMapping(value = "/students", method = RequestMethod.GET)
 public String getStudents(Model model) {
   model.addAttribute("students", schoolService.getStudents());
   return "students";
 }
 @RequestMapping(value = "/course/delete/{id}", method = RequestMethod.GET)
 public String deleteCourse(@PathVariable Long id) {
   schoolService.deleteCourse(id);
   return "redirect:/courses";
 }
 @RequestMapping(value = "/course/edit/{id}", method = RequestMethod.GET)
 public String editCourse(@PathVariable Long id, Model model) {
   model.addAttribute("course", schoolService.getCourse(id));
   return "course";
 }
 @RequestMapping(value = "/course/save", method = RequestMethod.POST)
 public String addCourse(@ModelAttribute Course course) {
   schoolService.saveCourse(course);
   return "redirect:/courses";
 }
 @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";
 }