Simplify staff addition and update

This commit is contained in:
Simon Bruder 2023-11-23 16:43:48 +01:00 committed by Denis Natusch
parent 14dc478e41
commit a90a8cc051
No known key found for this signature in database
GPG key ID: 5E57BD8EDACFA985

View file

@ -34,13 +34,8 @@ public class StaffController {
@PostMapping("/staff/add")
@PreAuthorize("hasRole('ADMIN')")
public String addStaff(
@RequestParam String name,
@RequestParam JobType job,
Model model
) {
Staff newStaff = new Staff(name, job);
staffManagement.save(newStaff);
public String addStaff(@RequestParam String name, @RequestParam JobType job) {
staffManagement.save(new Staff(name, job));
return "redirect:/staff";
}
@ -53,11 +48,7 @@ public class StaffController {
@PostMapping("/staff/edit/{id}")
@PreAuthorize("hasRole('ADMIN')")
public String updateStaff(
@PathVariable("id") Staff staff,
@RequestParam String name,
@RequestParam JobType job
) {
public String updateStaff(@PathVariable("id") Staff staff, @RequestParam String name, @RequestParam JobType job) {
staff.setJob(job);
staff.setName(name);
staffManagement.save(staff);