Compare commits

..

No commits in common. "85936721aa32d7e8d54261ec7c967835b5a21078" and "a503a36e8b0e4c7b6e692d94459548faaa767e35" have entirely different histories.

9 changed files with 39 additions and 107 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,9 +31,8 @@ public class AdminAspirantController {
model.addAttribute("aspirant", model.addAttribute("aspirant",
(id != null && id != 0) (id != null && id != 0)
? adminAspirantService.getAspirantById(id) ? adminAspirantService.getAspirantById(id)
: new Aspirant()); : new Indicator());
model.addAttribute("courses", Course.values()); model.addAttribute("courses", Course.values());
model.addAttribute("managers", adminAspirantService.getManagers());
return "admin/editAspirant"; return "admin/editAspirant";
} }

View File

@ -30,6 +30,7 @@ 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,20 +4,15 @@ 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() {
@ -47,8 +42,4 @@ 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,16 +44,6 @@ 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() {
} }

View File

@ -1,7 +0,0 @@
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> {
}

View File

@ -1,20 +0,0 @@
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();
}
}

View File

@ -9,7 +9,7 @@
<ul> <ul>
<li th:each="a : ${aspirants}"> <li th:each="a : ${aspirants}">
<a th:href="@{'/admin/editAspirant/' + ${a.id}}"> <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> </a>
</li> </li>
</ul> </ul>

View File

@ -3,33 +3,20 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}"> layout:decorate="~{default}">
<div class="container" layout:fragment="content"> <div class="container" layout:fragment="content">
<h3>Редактирование аспиранта:</h3> <h3>Редактирование показателя:</h3>
<form action="#" th:action="@{/admin/saveAspirant}" <form action="#" th:action="@{/admin/saveIndicator}"
th:object="${aspirant}" th:object="${indicator}"
method="post"> method="post"
enctype="multipart/form-data">
<input type="hidden" th:field="*{id}"> <input type="hidden" th:field="*{id}">
<div class="form-group"> <div class="form-group">
<label for="surname">Фамилия</label> <label for="name">Название</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}" <input th:field="*{name}"
id="name" id="name"
type="text" type="text"
required required
class="form-control" class="form-control"
placeholder="Имя"> placeholder="Название показателя">
<p th:if="${#fields.hasErrors('name')}" <p th:if="${#fields.hasErrors('name')}"
th:class="${#fields.hasErrors('name')}? error"> th:class="${#fields.hasErrors('name')}? error">
Не может быть пустым Не может быть пустым
@ -37,23 +24,36 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="patronymic">Отчество</label> <label for="name">Максимальная сумма баллов</label>
<input th:field="*{patronymic}" <input th:field="*{max}"
id="patronymic" required
type="text" id="max"
type="number"
class="form-control" class="form-control"
placeholder="Отчество"> min="0"
<p th:if="${#fields.hasErrors('patronymic')}" max="30">
th:class="${#fields.hasErrors('patronymic')}? error"> </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">
Не может быть пустым Не может быть пустым
</p> </p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="course">Курс</label> <label for="courses">Для каких курсов применяется</label>
<select class="form-select form-control"
id="course" aria-label="multiple select example" <select class="form-select form-control" id="courses" multiple aria-label="multiple select example"
th:field="*{course}"> th:field="*{courses}"
>
<option th:each="c : ${courses}" <option th:each="c : ${courses}"
th:value="${c}" th:value="${c}"
th:text="${c.name}"> th:text="${c.name}">
@ -61,35 +61,14 @@
</select> </select>
</div> </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="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
<button name="delete" <button name="delete"
type="submit" type="submit"
class="btn btn-outline-dark" class="btn btn-outline-dark"
onclick="return confirm('Удалить запись?')"> onclick="return confirm('Удалить показатель?')">
Удалить Удалить
</button> </button>
<a href="/admin/aspirants" class="btn btn-outline-dark">Отмена</a> <a href="/admin/indicators" class="btn btn-outline-dark">Отмена</a>
</form> </form>
<link rel="stylesheet" href="/webjars/font-awesome/4.7.0/css/font-awesome.min.css"/> <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"/> <link rel="stylesheet" href="/webjars/bootstrap-glyphicons/bdd2cbfba0/css/bootstrap-glyphicons.css"/>

View File

@ -60,7 +60,6 @@
aria-haspopup="true" aria-expanded="false">Администратору</a> aria-haspopup="true" aria-expanded="false">Администратору</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/admin/indicators">Список показателей</a> <a class="dropdown-item" href="/admin/indicators">Список показателей</a>
<a class="dropdown-item" href="/admin/aspirants">Список аспирантов</a>
<a class="dropdown-item" href="/admin">Новости и заседания</a> <a class="dropdown-item" href="/admin">Новости и заседания</a>
</div> </div>
</li> </li>