Compare commits
3 Commits
a503a36e8b
...
85936721aa
Author | SHA1 | Date | |
---|---|---|---|
85936721aa | |||
f15a658f56 | |||
4d1844d256 |
@ -8,8 +8,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import ru.ulstu.admin.model.AspirantForm;
|
||||
import ru.ulstu.admin.service.AdminAspirantService;
|
||||
import ru.ulstu.aspirant.model.Aspirant;
|
||||
import ru.ulstu.indicator.model.Course;
|
||||
import ru.ulstu.indicator.model.Indicator;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("admin")
|
||||
@ -31,8 +31,9 @@ public class AdminAspirantController {
|
||||
model.addAttribute("aspirant",
|
||||
(id != null && id != 0)
|
||||
? adminAspirantService.getAspirantById(id)
|
||||
: new Indicator());
|
||||
: new Aspirant());
|
||||
model.addAttribute("courses", Course.values());
|
||||
model.addAttribute("managers", adminAspirantService.getManagers());
|
||||
return "admin/editAspirant";
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ public class AdminIndicatorController {
|
||||
}
|
||||
|
||||
@GetMapping("/editIndicator/{indicatorId}")
|
||||
@Secured({UserRoleConstants.ADMIN})
|
||||
public String editIndicator(@PathVariable(value = "indicatorId") Integer id, Model model) {
|
||||
model.addAttribute("indicator",
|
||||
(id != null && id != 0)
|
||||
|
@ -4,15 +4,20 @@ import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.admin.model.AspirantForm;
|
||||
import ru.ulstu.aspirant.model.Aspirant;
|
||||
import ru.ulstu.aspirant.service.AspirantService;
|
||||
import ru.ulstu.manager.model.Manager;
|
||||
import ru.ulstu.manager.service.ManagerService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AdminAspirantService {
|
||||
private final AspirantService aspirantService;
|
||||
private final ManagerService managerService;
|
||||
|
||||
public AdminAspirantService(AspirantService aspirantService) {
|
||||
public AdminAspirantService(AspirantService aspirantService,
|
||||
ManagerService managerService) {
|
||||
this.aspirantService = aspirantService;
|
||||
this.managerService = managerService;
|
||||
}
|
||||
|
||||
public List<Aspirant> getAspirants() {
|
||||
@ -42,4 +47,8 @@ public class AdminAspirantService {
|
||||
public void deleteAspirant(AspirantForm aspirantForm) {
|
||||
aspirantService.deleteAspirant(aspirantForm);
|
||||
}
|
||||
|
||||
public List<Manager> getManagers() {
|
||||
return managerService.getManagers();
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,16 @@ public class Aspirant extends BaseEntity {
|
||||
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.manager.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.manager.model.Manager;
|
||||
|
||||
public interface ManagerRepository extends JpaRepository<Manager, Integer> {
|
||||
}
|
20
src/main/java/ru/ulstu/manager/service/ManagerService.java
Normal file
20
src/main/java/ru/ulstu/manager/service/ManagerService.java
Normal file
@ -0,0 +1,20 @@
|
||||
package ru.ulstu.manager.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.manager.model.Manager;
|
||||
import ru.ulstu.manager.repository.ManagerRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ManagerService {
|
||||
private final ManagerRepository managerRepository;
|
||||
|
||||
public ManagerService(ManagerRepository managerRepository) {
|
||||
this.managerRepository = managerRepository;
|
||||
}
|
||||
|
||||
public List<Manager> getManagers() {
|
||||
return managerRepository.findAll();
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
<ul>
|
||||
<li th:each="a : ${aspirants}">
|
||||
<a th:href="@{'/admin/editAspirant/' + ${a.id}}">
|
||||
<span th:text="{${a.surname} + ' '+ ${a.name} + ' ' + ${a.patronymic}}"></span>
|
||||
<span th:text="${a.surname} + ' '+ ${a.name} + ' ' + ${a.patronymic}"></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -3,20 +3,33 @@
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
|
||||
layout:decorate="~{default}">
|
||||
<div class="container" layout:fragment="content">
|
||||
<h3>Редактирование показателя:</h3>
|
||||
<form action="#" th:action="@{/admin/saveIndicator}"
|
||||
th:object="${indicator}"
|
||||
method="post"
|
||||
enctype="multipart/form-data">
|
||||
<h3>Редактирование аспиранта:</h3>
|
||||
<form action="#" th:action="@{/admin/saveAspirant}"
|
||||
th:object="${aspirant}"
|
||||
method="post">
|
||||
<input type="hidden" th:field="*{id}">
|
||||
<div class="form-group">
|
||||
<label for="name">Название</label>
|
||||
<label for="surname">Фамилия</label>
|
||||
<input th:field="*{surname}"
|
||||
id="surname"
|
||||
type="text"
|
||||
required
|
||||
class="form-control"
|
||||
placeholder="Фамилия">
|
||||
<p th:if="${#fields.hasErrors('surname')}"
|
||||
th:class="${#fields.hasErrors('surname')}? error">
|
||||
Не может быть пустым
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Имя</label>
|
||||
<input th:field="*{name}"
|
||||
id="name"
|
||||
type="text"
|
||||
required
|
||||
class="form-control"
|
||||
placeholder="Название показателя">
|
||||
placeholder="Имя">
|
||||
<p th:if="${#fields.hasErrors('name')}"
|
||||
th:class="${#fields.hasErrors('name')}? error">
|
||||
Не может быть пустым
|
||||
@ -24,36 +37,23 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Максимальная сумма баллов</label>
|
||||
<input th:field="*{max}"
|
||||
required
|
||||
id="max"
|
||||
type="number"
|
||||
<label for="patronymic">Отчество</label>
|
||||
<input th:field="*{patronymic}"
|
||||
id="patronymic"
|
||||
type="text"
|
||||
class="form-control"
|
||||
min="0"
|
||||
max="30">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name">Описание подтверждающих документов</label>
|
||||
<textarea th:field="*{proofDocuments}"
|
||||
required
|
||||
id="proofDocuments"
|
||||
class="form-control"
|
||||
placeholder="Описание подтверждающих документов"
|
||||
style="height: 100px">
|
||||
</textarea>
|
||||
<p th:if="${#fields.hasErrors('proofDocuments')}"
|
||||
th:class="${#fields.hasErrors('proofDocuments')}? error">
|
||||
placeholder="Отчество">
|
||||
<p th:if="${#fields.hasErrors('patronymic')}"
|
||||
th:class="${#fields.hasErrors('patronymic')}? error">
|
||||
Не может быть пустым
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="courses">Для каких курсов применяется</label>
|
||||
|
||||
<select class="form-select form-control" id="courses" multiple aria-label="multiple select example"
|
||||
th:field="*{courses}"
|
||||
>
|
||||
<div class="form-group">
|
||||
<label for="course">Курс</label>
|
||||
<select class="form-select form-control"
|
||||
id="course" aria-label="multiple select example"
|
||||
th:field="*{course}">
|
||||
<option th:each="c : ${courses}"
|
||||
th:value="${c}"
|
||||
th:text="${c.name}">
|
||||
@ -61,14 +61,35 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="theme">Тема</label>
|
||||
<input th:field="*{theme}"
|
||||
id="theme"
|
||||
type="text"
|
||||
class="form-control"
|
||||
placeholder="Тема">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="manager">Научный руководитель</label>
|
||||
<select class="form-select form-control"
|
||||
id="manager" aria-label="select example"
|
||||
th:field="*{manager}">
|
||||
<option th:each="m : ${managers}"
|
||||
th:value="${m}"
|
||||
th:text="${m.name}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button name="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
|
||||
<button name="delete"
|
||||
type="submit"
|
||||
class="btn btn-outline-dark"
|
||||
onclick="return confirm('Удалить показатель?')">
|
||||
onclick="return confirm('Удалить запись?')">
|
||||
Удалить
|
||||
</button>
|
||||
<a href="/admin/indicators" class="btn btn-outline-dark">Отмена</a>
|
||||
<a href="/admin/aspirants" class="btn btn-outline-dark">Отмена</a>
|
||||
</form>
|
||||
<link rel="stylesheet" href="/webjars/font-awesome/4.7.0/css/font-awesome.min.css"/>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap-glyphicons/bdd2cbfba0/css/bootstrap-glyphicons.css"/>
|
||||
|
@ -60,6 +60,7 @@
|
||||
aria-haspopup="true" aria-expanded="false">Администратору</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="/admin/indicators">Список показателей</a>
|
||||
<a class="dropdown-item" href="/admin/aspirants">Список аспирантов</a>
|
||||
<a class="dropdown-item" href="/admin">Новости и заседания</a>
|
||||
</div>
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user