Unify naming of employee id

This commit is contained in:
Simon Bruder 2023-11-23 16:42:56 +01:00 committed by Denis Natusch
parent 3ebedd4ad8
commit 14dc478e41
No known key found for this signature in database
GPG key ID: 5E57BD8EDACFA985
4 changed files with 7 additions and 7 deletions

View file

@ -27,7 +27,7 @@ public class StaffController {
@PostMapping("/staff/remove")
@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());
return "redirect:/staff";
}

View file

@ -17,8 +17,8 @@ public class StaffManagement {
this.staffRepository = staffRepository;
}
public Optional<Staff> findById(Long staffID) {
return staffRepository.findById(staffID);
public Optional<Staff> findById(Long id) {
return staffRepository.findById(id);
}
public Staff save(Staff staff) {
@ -29,8 +29,8 @@ public class StaffManagement {
return staffRepository.findAll();
}
public void deleteStaff(Long staffID) {
staffRepository.deleteById(staffID);
public void deleteStaff(Long id) {
staffRepository.deleteById(id);
}
}

View file

@ -28,7 +28,7 @@
</td>
<td>
<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>
</form>
</td>

View file

@ -81,7 +81,7 @@ class StaffControllerIntegrationTests {
@Test
@WithMockUser(username = "admin", password = "admin", roles = "ADMIN")
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
mvc.perform(get("/staff/edit/" + defaultEmployeeId.toString()))
.andExpect(status().isInternalServerError());