mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Remove surname from staff
Co-authored-by: Simon Bruder <simon.bruder@mailbox.tu-dresden.de>
This commit is contained in:
parent
3ecdcffbcd
commit
5aeaf01e0e
|
@ -7,16 +7,15 @@ import jakarta.persistence.Id;
|
||||||
@Entity
|
@Entity
|
||||||
public class Staff {
|
public class Staff {
|
||||||
|
|
||||||
private String surname, name, job;
|
private String name, job;
|
||||||
private @Id @GeneratedValue Long id;
|
private @Id @GeneratedValue Long id;
|
||||||
|
|
||||||
protected Staff() {
|
protected Staff() {
|
||||||
// No-argument constructor for JPA
|
// No-argument constructor for JPA
|
||||||
}
|
}
|
||||||
|
|
||||||
public Staff(String name, String surname, String job) {
|
public Staff(String name, String job) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
|
||||||
this.job = job;
|
this.job = job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +23,6 @@ public class Staff {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSurname() {
|
|
||||||
return surname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +31,6 @@ public class Staff {
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSurname(String surname) {
|
|
||||||
this.surname = surname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -37,11 +37,10 @@ public class StaffController {
|
||||||
@PreAuthorize("hasRole('ADMIN')")
|
@PreAuthorize("hasRole('ADMIN')")
|
||||||
public String addStaff(
|
public String addStaff(
|
||||||
@RequestParam String name,
|
@RequestParam String name,
|
||||||
@RequestParam String surname,
|
|
||||||
@RequestParam String job,
|
@RequestParam String job,
|
||||||
Model model
|
Model model
|
||||||
) {
|
) {
|
||||||
Staff newStaff = new Staff(name, surname, job);
|
Staff newStaff = new Staff(name, job);
|
||||||
staffManagement.save(newStaff);
|
staffManagement.save(newStaff);
|
||||||
return "redirect:/staff";
|
return "redirect:/staff";
|
||||||
}
|
}
|
||||||
|
@ -58,12 +57,10 @@ public class StaffController {
|
||||||
public String updateStaff(
|
public String updateStaff(
|
||||||
@PathVariable("id") Staff staff,
|
@PathVariable("id") Staff staff,
|
||||||
@RequestParam String name,
|
@RequestParam String name,
|
||||||
@RequestParam String surname,
|
|
||||||
@RequestParam String job
|
@RequestParam String job
|
||||||
) {
|
) {
|
||||||
staff.setJob(job);
|
staff.setJob(job);
|
||||||
staff.setName(name);
|
staff.setName(name);
|
||||||
staff.setSurname(surname);
|
|
||||||
staffManagement.save(staff);
|
staffManagement.save(staff);
|
||||||
return "redirect:/staff";
|
return "redirect:/staff";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
<label class="form-label" for="name">Name:</label>
|
<label class="form-label" for="name">Name:</label>
|
||||||
<input class="form-control" type="text" th:field="*{name}" required />
|
<input class="form-control" type="text" th:field="*{name}" required />
|
||||||
</div>
|
</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">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="job">Beruf:</label>
|
<label class="form-label" for="job">Beruf:</label>
|
||||||
<input class="form-control" type="text" th:field="*{job}" required />
|
<input class="form-control" type="text" th:field="*{job}" required />
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Nachname</th>
|
|
||||||
<th>Beruf</th>
|
<th>Beruf</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -21,7 +20,6 @@
|
||||||
|
|
||||||
<tr th:each="staff : ${staff}">
|
<tr th:each="staff : ${staff}">
|
||||||
<td th:text="${staff.name}">Max</td>
|
<td th:text="${staff.name}">Max</td>
|
||||||
<td th:text="${staff.surname}">Musterkoch</td>
|
|
||||||
<td th:text="${staff.job}">Koch</td>
|
<td th:text="${staff.job}">Koch</td>
|
||||||
<td>
|
<td>
|
||||||
<a th:href="@{'/staff/edit/' + ${staff.id}}"
|
<a th:href="@{'/staff/edit/' + ${staff.id}}"
|
||||||
|
@ -44,10 +42,6 @@
|
||||||
<label class="form-label" for="name">Name</label>
|
<label class="form-label" for="name">Name</label>
|
||||||
<input class="form-control" type="text" name="name" required />
|
<input class="form-control" type="text" name="name" required />
|
||||||
</div>
|
</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">
|
<div class="mb-3">
|
||||||
<label class="form-label" for="job">Beruf</label>
|
<label class="form-label" for="job">Beruf</label>
|
||||||
<input class="form-control" type="text" name="job" required />
|
<input class="form-control" type="text" name="job" required />
|
||||||
|
|
Loading…
Reference in a new issue