@RequestMapping(value = "form") public String form(Subject subject, Model model) { if (subject.getParent() == null || subject.getParent().getId() == null) { subject.setParent(new Subject(1L)); } subject.setParent(subjectService.getSubject(subject.getParent().getId())); model.addAttribute("subject", subject); return "modules/account/subjectForm"; }
@RequestMapping(value = "delete") public String delete(Long id, RedirectAttributes redirectAttributes) { if (Subject.isRoot(id)) { addMessage(redirectAttributes, "删除失败, 不允许删除顶级科目或编号为空"); } else { subjectService.deleteById(id); addMessage(redirectAttributes, "删除成功"); } return "redirect:" + Global.getAdminPath() + "/account/subject/"; }
@RequestMapping(value = "") public String incoming(Model model, String type) { type = type == null ? "0" : type; List<Subject> list = Lists.newArrayList(); List<Subject> sourcelist = subjectService.findAllSubjects(type); Subject.sortList(list, sourcelist, 1L); model.addAttribute("subjectList", list); model.addAttribute("type", type); return "modules/account/subjectList"; }