mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Simplify staff addition and update
This commit is contained in:
parent
14dc478e41
commit
a90a8cc051
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue