63 lines
1.9 KiB
Java
63 lines
1.9 KiB
Java
package de.jottyfan.bico.modules.subject;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import de.jottyfan.bico.db.tables.records.TSubjectRecord;
|
|
import de.jottyfan.bico.modules.CommonController;
|
|
|
|
/**
|
|
*
|
|
* @author jotty
|
|
*
|
|
*/
|
|
@Controller
|
|
public class SubjectController extends CommonController {
|
|
|
|
@Autowired
|
|
private SubjectService service;
|
|
|
|
@GetMapping("/subject/list")
|
|
public String getSubjectList(Model model) {
|
|
model.addAttribute("list", service.getSubjects());
|
|
return "/subject/list";
|
|
}
|
|
|
|
@GetMapping("/subject/{id}")
|
|
public String getSubject(@PathVariable("id") Integer pkSubject, Model model) {
|
|
model.addAttribute("bean", service.getSubject(pkSubject));
|
|
model.addAttribute("sources", service.getSources());
|
|
return "/subject/item";
|
|
}
|
|
|
|
@PostMapping("/subject/save")
|
|
public String saveSubject(@ModelAttribute("bean") TSubjectRecord bean) {
|
|
service.save(bean);
|
|
return "redirect:/subject/list";
|
|
}
|
|
|
|
@GetMapping("/subject/{id}/delete")
|
|
public String checkDeletionOfSubject(@PathVariable("id") Integer pkSubject, Model model) {
|
|
model.addAttribute("bean", service.getBeanIfDeletable(pkSubject));
|
|
return "/subject/delete";
|
|
}
|
|
|
|
@GetMapping("/subject/{id}/remove")
|
|
public String removeSubject(@PathVariable("id") Integer pkSubject, Model model) {
|
|
service.removeSubject(pkSubject);
|
|
return "redirect:/subject/list";
|
|
}
|
|
|
|
@GetMapping("/subject/new")
|
|
public String loadNewSubjectForm(Model model) {
|
|
model.addAttribute("bean", new TSubjectRecord());
|
|
model.addAttribute("sources", service.getSources());
|
|
return "/subject/item";
|
|
}
|
|
}
|