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")
|
@PostMapping("/staff/add")
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public String addStaff(
|
public String addStaff(@RequestParam String name, @RequestParam JobType job) {
|
||||||
@RequestParam String name,
|
staffManagement.save(new Staff(name, job));
|
||||||
@RequestParam JobType job,
|
|
||||||
Model model
|
|
||||||
) {
|
|
||||||
Staff newStaff = new Staff(name, job);
|
|
||||||
staffManagement.save(newStaff);
|
|
||||||
return "redirect:/staff";
|
return "redirect:/staff";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +48,7 @@ public class StaffController {
|
||||||
|
|
||||||
@PostMapping("/staff/edit/{id}")
|
@PostMapping("/staff/edit/{id}")
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public String updateStaff(
|
public String updateStaff(@PathVariable("id") Staff staff, @RequestParam String name, @RequestParam JobType job) {
|
||||||
@PathVariable("id") Staff staff,
|
|
||||||
@RequestParam String name,
|
|
||||||
@RequestParam JobType job
|
|
||||||
) {
|
|
||||||
staff.setJob(job);
|
staff.setJob(job);
|
||||||
staff.setName(name);
|
staff.setName(name);
|
||||||
staffManagement.save(staff);
|
staffManagement.save(staff);
|
||||||
|
|
Loading…
Reference in a new issue