mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Unify naming of employee id
This commit is contained in:
parent
3ebedd4ad8
commit
14dc478e41
|
@ -27,7 +27,7 @@ public class StaffController {
|
||||||
|
|
||||||
@PostMapping("/staff/remove")
|
@PostMapping("/staff/remove")
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public String removeStaff(@RequestParam("staffID") Staff staff, Model model) {
|
public String removeStaff(@RequestParam("id") Staff staff, Model model) {
|
||||||
staffManagement.deleteStaff(staff.getId());
|
staffManagement.deleteStaff(staff.getId());
|
||||||
return "redirect:/staff";
|
return "redirect:/staff";
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class StaffManagement {
|
||||||
this.staffRepository = staffRepository;
|
this.staffRepository = staffRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Staff> findById(Long staffID) {
|
public Optional<Staff> findById(Long id) {
|
||||||
return staffRepository.findById(staffID);
|
return staffRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Staff save(Staff staff) {
|
public Staff save(Staff staff) {
|
||||||
|
@ -29,8 +29,8 @@ public class StaffManagement {
|
||||||
return staffRepository.findAll();
|
return staffRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteStaff(Long staffID) {
|
public void deleteStaff(Long id) {
|
||||||
staffRepository.deleteById(staffID);
|
staffRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form th:action="@{/staff/remove}" method="post">
|
<form th:action="@{/staff/remove}" method="post">
|
||||||
<input type="hidden" th:name="staffID" th:value="${staff.id}" />
|
<input type="hidden" th:name="id" th:value="${staff.id}" />
|
||||||
<button type="submit" class="btn btn-danger">Entfernen</button>
|
<button type="submit" class="btn btn-danger">Entfernen</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -81,7 +81,7 @@ class StaffControllerIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
|
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
|
||||||
void removeStaff() throws Exception {
|
void removeStaff() throws Exception {
|
||||||
mvc.perform(post("/staff/remove").param("staffID",defaultEmployeeId.toString()));
|
mvc.perform(post("/staff/remove").param("id", defaultEmployeeId.toString()));
|
||||||
// this should be replaced once we have proper access to all employees
|
// this should be replaced once we have proper access to all employees
|
||||||
mvc.perform(get("/staff/edit/" + defaultEmployeeId.toString()))
|
mvc.perform(get("/staff/edit/" + defaultEmployeeId.toString()))
|
||||||
.andExpect(status().isInternalServerError());
|
.andExpect(status().isInternalServerError());
|
||||||
|
|
Loading…
Reference in a new issue