Add aspirant manager
This commit is contained in:
parent
32d8779fd4
commit
d04c61b683
@ -29,9 +29,9 @@ public class AdminAspirantController {
|
|||||||
@GetMapping("/editAspirant/{aspirantId}")
|
@GetMapping("/editAspirant/{aspirantId}")
|
||||||
public String editAspirant(@PathVariable(value = "aspirantId") Integer id, Model model) {
|
public String editAspirant(@PathVariable(value = "aspirantId") Integer id, Model model) {
|
||||||
model.addAttribute("aspirant",
|
model.addAttribute("aspirant",
|
||||||
(id != null && id != 0)
|
new AspirantForm((id != null && id != 0)
|
||||||
? adminAspirantService.getAspirantById(id)
|
? adminAspirantService.getAspirantById(id)
|
||||||
: new Aspirant());
|
: new Aspirant()));
|
||||||
model.addAttribute("courses", Course.values());
|
model.addAttribute("courses", Course.values());
|
||||||
model.addAttribute("managers", adminAspirantService.getManagers());
|
model.addAttribute("managers", adminAspirantService.getManagers());
|
||||||
return "admin/editAspirant";
|
return "admin/editAspirant";
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package ru.ulstu.admin.model;
|
package ru.ulstu.admin.model;
|
||||||
|
|
||||||
|
import ru.ulstu.aspirant.model.Aspirant;
|
||||||
import ru.ulstu.aspirant.model.Base;
|
import ru.ulstu.aspirant.model.Base;
|
||||||
import ru.ulstu.aspirant.model.Speciality;
|
import ru.ulstu.aspirant.model.Speciality;
|
||||||
import ru.ulstu.indicator.model.Course;
|
import ru.ulstu.indicator.model.Course;
|
||||||
import ru.ulstu.manager.model.Manager;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public class AspirantForm {
|
|||||||
|
|
||||||
private Course course;
|
private Course course;
|
||||||
|
|
||||||
private Manager manager;
|
private Integer managerId;
|
||||||
|
|
||||||
private Date birthDate;
|
private Date birthDate;
|
||||||
|
|
||||||
@ -28,6 +28,22 @@ public class AspirantForm {
|
|||||||
|
|
||||||
private Base base;
|
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() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -68,12 +84,12 @@ public class AspirantForm {
|
|||||||
this.course = course;
|
this.course = course;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Manager getManager() {
|
public Integer getManagerId() {
|
||||||
return manager;
|
return managerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setManager(Manager manager) {
|
public void setManagerId(Integer managerId) {
|
||||||
this.manager = manager;
|
this.managerId = managerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getBirthDate() {
|
public Date getBirthDate() {
|
||||||
|
@ -30,14 +30,14 @@ public class AdminAspirantService {
|
|||||||
|
|
||||||
public void saveAspirant(AspirantForm aspirantForm) {
|
public void saveAspirant(AspirantForm aspirantForm) {
|
||||||
Aspirant aspirant = aspirantForm.getId() == null
|
Aspirant aspirant = aspirantForm.getId() == null
|
||||||
? new Aspirant(aspirantForm)
|
? new Aspirant()
|
||||||
: aspirantService.getAspirantById(aspirantForm.getId());
|
: aspirantService.getAspirantById(aspirantForm.getId());
|
||||||
aspirant.setName(aspirantForm.getName());
|
aspirant.setName(aspirantForm.getName());
|
||||||
aspirant.setSurname(aspirantForm.getSurname());
|
aspirant.setSurname(aspirantForm.getSurname());
|
||||||
aspirant.setPatronymic(aspirantForm.getPatronymic());
|
aspirant.setPatronymic(aspirantForm.getPatronymic());
|
||||||
aspirant.setBase(aspirantForm.getBase());
|
aspirant.setBase(aspirantForm.getBase());
|
||||||
aspirant.setCourse(aspirantForm.getCourse());
|
aspirant.setCourse(aspirantForm.getCourse());
|
||||||
aspirant.setManager(aspirantForm.getManager());
|
aspirant.setManager(managerService.getManagerById(aspirantForm.getManagerId()));
|
||||||
aspirant.setBirthDate(aspirantForm.getBirthDate());
|
aspirant.setBirthDate(aspirantForm.getBirthDate());
|
||||||
aspirant.setSpeciality(aspirantForm.getSpeciality());
|
aspirant.setSpeciality(aspirantForm.getSpeciality());
|
||||||
aspirant.setTheme(aspirantForm.getTheme());
|
aspirant.setTheme(aspirantForm.getTheme());
|
||||||
|
@ -8,7 +8,6 @@ import jakarta.persistence.Temporal;
|
|||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import ru.ulstu.admin.model.AspirantForm;
|
|
||||||
import ru.ulstu.indicator.model.Course;
|
import ru.ulstu.indicator.model.Course;
|
||||||
import ru.ulstu.manager.model.Manager;
|
import ru.ulstu.manager.model.Manager;
|
||||||
import ru.ulstu.model.BaseEntity;
|
import ru.ulstu.model.BaseEntity;
|
||||||
@ -42,17 +41,6 @@ public class Aspirant extends BaseEntity {
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private Base base;
|
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() {
|
public Aspirant() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,9 @@
|
|||||||
<label for="manager">Научный руководитель</label>
|
<label for="manager">Научный руководитель</label>
|
||||||
<select class="form-select form-control"
|
<select class="form-select form-control"
|
||||||
id="manager" aria-label="select example"
|
id="manager" aria-label="select example"
|
||||||
th:field="*{manager}">
|
th:field="*{managerId}">
|
||||||
<option th:each="m : ${managers}"
|
<option th:each="m : ${managers}"
|
||||||
th:value="${m}"
|
th:value="${m.id}"
|
||||||
th:text="${m.name}">
|
th:text="${m.name}">
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user