Read additionally aspirant fields

This commit is contained in:
Anton Romanov 2025-01-29 19:33:09 +04:00
parent f15a658f56
commit 85936721aa
4 changed files with 23 additions and 4 deletions

View File

@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import ru.ulstu.admin.model.AspirantForm; import ru.ulstu.admin.model.AspirantForm;
import ru.ulstu.admin.service.AdminAspirantService; import ru.ulstu.admin.service.AdminAspirantService;
import ru.ulstu.aspirant.model.Aspirant;
import ru.ulstu.indicator.model.Course; import ru.ulstu.indicator.model.Course;
import ru.ulstu.indicator.model.Indicator;
@Controller @Controller
@RequestMapping("admin") @RequestMapping("admin")
@ -31,8 +31,9 @@ public class AdminAspirantController {
model.addAttribute("aspirant", model.addAttribute("aspirant",
(id != null && id != 0) (id != null && id != 0)
? adminAspirantService.getAspirantById(id) ? adminAspirantService.getAspirantById(id)
: new Indicator()); : new Aspirant());
model.addAttribute("courses", Course.values()); model.addAttribute("courses", Course.values());
model.addAttribute("managers", adminAspirantService.getManagers());
return "admin/editAspirant"; return "admin/editAspirant";
} }

View File

@ -30,7 +30,6 @@ public class AdminIndicatorController {
} }
@GetMapping("/editIndicator/{indicatorId}") @GetMapping("/editIndicator/{indicatorId}")
@Secured({UserRoleConstants.ADMIN})
public String editIndicator(@PathVariable(value = "indicatorId") Integer id, Model model) { public String editIndicator(@PathVariable(value = "indicatorId") Integer id, Model model) {
model.addAttribute("indicator", model.addAttribute("indicator",
(id != null && id != 0) (id != null && id != 0)

View File

@ -4,15 +4,20 @@ import org.springframework.stereotype.Service;
import ru.ulstu.admin.model.AspirantForm; import ru.ulstu.admin.model.AspirantForm;
import ru.ulstu.aspirant.model.Aspirant; import ru.ulstu.aspirant.model.Aspirant;
import ru.ulstu.aspirant.service.AspirantService; import ru.ulstu.aspirant.service.AspirantService;
import ru.ulstu.manager.model.Manager;
import ru.ulstu.manager.service.ManagerService;
import java.util.List; import java.util.List;
@Service @Service
public class AdminAspirantService { public class AdminAspirantService {
private final AspirantService aspirantService; private final AspirantService aspirantService;
private final ManagerService managerService;
public AdminAspirantService(AspirantService aspirantService) { public AdminAspirantService(AspirantService aspirantService,
ManagerService managerService) {
this.aspirantService = aspirantService; this.aspirantService = aspirantService;
this.managerService = managerService;
} }
public List<Aspirant> getAspirants() { public List<Aspirant> getAspirants() {
@ -42,4 +47,8 @@ public class AdminAspirantService {
public void deleteAspirant(AspirantForm aspirantForm) { public void deleteAspirant(AspirantForm aspirantForm) {
aspirantService.deleteAspirant(aspirantForm); aspirantService.deleteAspirant(aspirantForm);
} }
public List<Manager> getManagers() {
return managerService.getManagers();
}
} }

View File

@ -44,6 +44,16 @@ public class Aspirant extends BaseEntity {
public Aspirant(AspirantForm aspirantForm) { public Aspirant(AspirantForm aspirantForm) {
this.name = aspirantForm.getName(); 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() {
} }