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")
|
||||
@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";
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in a new issue