diff --git a/src/main/java/ru/ulstu/admin/controller/AdminAspirantController.java b/src/main/java/ru/ulstu/admin/controller/AdminAspirantController.java
index d10ec23..ee62056 100644
--- a/src/main/java/ru/ulstu/admin/controller/AdminAspirantController.java
+++ b/src/main/java/ru/ulstu/admin/controller/AdminAspirantController.java
@@ -29,9 +29,9 @@ public class AdminAspirantController {
@GetMapping("/editAspirant/{aspirantId}")
public String editAspirant(@PathVariable(value = "aspirantId") Integer id, Model model) {
model.addAttribute("aspirant",
- (id != null && id != 0)
+ new AspirantForm((id != null && id != 0)
? adminAspirantService.getAspirantById(id)
- : new Aspirant());
+ : new Aspirant()));
model.addAttribute("courses", Course.values());
model.addAttribute("managers", adminAspirantService.getManagers());
return "admin/editAspirant";
diff --git a/src/main/java/ru/ulstu/admin/model/AspirantForm.java b/src/main/java/ru/ulstu/admin/model/AspirantForm.java
index 6ac6e3c..828bdb1 100644
--- a/src/main/java/ru/ulstu/admin/model/AspirantForm.java
+++ b/src/main/java/ru/ulstu/admin/model/AspirantForm.java
@@ -1,9 +1,9 @@
package ru.ulstu.admin.model;
+import ru.ulstu.aspirant.model.Aspirant;
import ru.ulstu.aspirant.model.Base;
import ru.ulstu.aspirant.model.Speciality;
import ru.ulstu.indicator.model.Course;
-import ru.ulstu.manager.model.Manager;
import java.util.Date;
@@ -18,7 +18,7 @@ public class AspirantForm {
private Course course;
- private Manager manager;
+ private Integer managerId;
private Date birthDate;
@@ -28,6 +28,22 @@ public class AspirantForm {
private Base base;
+ public AspirantForm() {
+ }
+
+ public AspirantForm(Aspirant aspirant) {
+ this.id = aspirant.getId();
+ this.name = aspirant.getName();
+ this.surname = aspirant.getSurname();
+ this.patronymic = aspirant.getPatronymic();
+ this.base = aspirant.getBase();
+ this.course = aspirant.getCourse();
+ this.managerId = aspirant.getManager() == null ? null : aspirant.getManager().getId();
+ this.birthDate = aspirant.getBirthDate();
+ this.speciality = aspirant.getSpeciality();
+ this.theme = aspirant.getTheme();
+ }
+
public Integer getId() {
return id;
}
@@ -68,12 +84,12 @@ public class AspirantForm {
this.course = course;
}
- public Manager getManager() {
- return manager;
+ public Integer getManagerId() {
+ return managerId;
}
- public void setManager(Manager manager) {
- this.manager = manager;
+ public void setManagerId(Integer managerId) {
+ this.managerId = managerId;
}
public Date getBirthDate() {
diff --git a/src/main/java/ru/ulstu/admin/service/AdminAspirantService.java b/src/main/java/ru/ulstu/admin/service/AdminAspirantService.java
index cdbfde9..3889aa1 100644
--- a/src/main/java/ru/ulstu/admin/service/AdminAspirantService.java
+++ b/src/main/java/ru/ulstu/admin/service/AdminAspirantService.java
@@ -30,14 +30,14 @@ public class AdminAspirantService {
public void saveAspirant(AspirantForm aspirantForm) {
Aspirant aspirant = aspirantForm.getId() == null
- ? new Aspirant(aspirantForm)
+ ? new Aspirant()
: aspirantService.getAspirantById(aspirantForm.getId());
aspirant.setName(aspirantForm.getName());
aspirant.setSurname(aspirantForm.getSurname());
aspirant.setPatronymic(aspirantForm.getPatronymic());
aspirant.setBase(aspirantForm.getBase());
aspirant.setCourse(aspirantForm.getCourse());
- aspirant.setManager(aspirantForm.getManager());
+ aspirant.setManager(managerService.getManagerById(aspirantForm.getManagerId()));
aspirant.setBirthDate(aspirantForm.getBirthDate());
aspirant.setSpeciality(aspirantForm.getSpeciality());
aspirant.setTheme(aspirantForm.getTheme());
diff --git a/src/main/java/ru/ulstu/aspirant/model/Aspirant.java b/src/main/java/ru/ulstu/aspirant/model/Aspirant.java
index 5393e1f..50571a5 100644
--- a/src/main/java/ru/ulstu/aspirant/model/Aspirant.java
+++ b/src/main/java/ru/ulstu/aspirant/model/Aspirant.java
@@ -8,7 +8,6 @@ import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
-import ru.ulstu.admin.model.AspirantForm;
import ru.ulstu.indicator.model.Course;
import ru.ulstu.manager.model.Manager;
import ru.ulstu.model.BaseEntity;
@@ -42,17 +41,6 @@ public class Aspirant extends BaseEntity {
@Enumerated(EnumType.STRING)
private Base base;
- public Aspirant(AspirantForm aspirantForm) {
- this.name = aspirantForm.getName();
- this.surname = aspirantForm.getSurname();
- this.patronymic = aspirantForm.getPatronymic();
- this.theme = aspirantForm.getTheme();
- this.manager = aspirantForm.getManager();
- this.speciality = aspirantForm.getSpeciality();
- this.base = aspirantForm.getBase();
- this.birthDate = aspirantForm.getBirthDate();
- }
-
public Aspirant() {
}
diff --git a/src/main/resources/templates/admin/editAspirant.html b/src/main/resources/templates/admin/editAspirant.html
index 4258f91..98b104a 100644
--- a/src/main/resources/templates/admin/editAspirant.html
+++ b/src/main/resources/templates/admin/editAspirant.html
@@ -74,9 +74,9 @@