add, edit, delete and assign themes to dates

This commit is contained in:
Jottyfan
2023-12-16 22:51:27 +01:00
parent 5356e51f09
commit 0999d41d64
13 changed files with 505 additions and 29 deletions

View File

@ -1,8 +1,14 @@
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;
/**
@ -13,8 +19,44 @@ import de.jottyfan.bico.modules.CommonController;
@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() {
return "/subject/new";
public String loadNewSubjectForm(Model model) {
model.addAttribute("bean", new TSubjectRecord());
model.addAttribute("sources", service.getSources());
return "/subject/item";
}
}