Remove surname from staff

Co-authored-by: Simon Bruder <simon.bruder@mailbox.tu-dresden.de>
This commit is contained in:
Denis Natusch 2023-11-21 15:59:26 +01:00 committed by Simon Bruder
parent 3ecdcffbcd
commit 5aeaf01e0e
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
4 changed files with 3 additions and 24 deletions

View file

@ -7,16 +7,15 @@ import jakarta.persistence.Id;
@Entity
public class Staff {
private String surname, name, job;
private String name, job;
private @Id @GeneratedValue Long id;
protected Staff() {
// No-argument constructor for JPA
}
public Staff(String name, String surname, String job) {
public Staff(String name, String job) {
this.name = name;
this.surname = surname;
this.job = job;
}
@ -24,10 +23,6 @@ public class Staff {
return id;
}
public String getSurname() {
return surname;
}
public String getName() {
return name;
}
@ -36,9 +31,6 @@ public class Staff {
return job;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void setName(String name) {
this.name = name;

View file

@ -37,11 +37,10 @@ public class StaffController {
@PreAuthorize("hasRole('ADMIN')")
public String addStaff(
@RequestParam String name,
@RequestParam String surname,
@RequestParam String job,
Model model
) {
Staff newStaff = new Staff(name, surname, job);
Staff newStaff = new Staff(name, job);
staffManagement.save(newStaff);
return "redirect:/staff";
}
@ -58,12 +57,10 @@ public class StaffController {
public String updateStaff(
@PathVariable("id") Staff staff,
@RequestParam String name,
@RequestParam String surname,
@RequestParam String job
) {
staff.setJob(job);
staff.setName(name);
staff.setSurname(surname);
staffManagement.save(staff);
return "redirect:/staff";
}

View file

@ -13,10 +13,6 @@
<label class="form-label" for="name">Name:</label>
<input class="form-control" type="text" th:field="*{name}" required />
</div>
<div class="mb-3">
<label class="form-label" for="surname">Nachname:</label>
<input class="form-control" type="text" th:field="*{surname}" required />
</div>
<div class="mb-3">
<label class="form-label" for="job">Beruf:</label>
<input class="form-control" type="text" th:field="*{job}" required />

View file

@ -13,7 +13,6 @@
<table class="table">
<tr>
<th>Name</th>
<th>Nachname</th>
<th>Beruf</th>
<th></th>
<th></th>
@ -21,7 +20,6 @@
<tr th:each="staff : ${staff}">
<td th:text="${staff.name}">Max</td>
<td th:text="${staff.surname}">Musterkoch</td>
<td th:text="${staff.job}">Koch</td>
<td>
<a th:href="@{'/staff/edit/' + ${staff.id}}"
@ -44,10 +42,6 @@
<label class="form-label" for="name">Name</label>
<input class="form-control" type="text" name="name" required />
</div>
<div class="mb-3">
<label class="form-label" for="surname">Nachname</label>
<input class="form-control" type="text" name="surname" required />
</div>
<div class="mb-3">
<label class="form-label" for="job">Beruf</label>
<input class="form-control" type="text" name="job" required />