esoe 6 months ago
parent
commit
3022a857ca
  1. 2
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/ProgramController.java
  2. 153
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/StudentController.java
  3. 55
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Student.java
  4. 76
      client-service-teachers/src/main/resources/templates/student-add.html
  5. 76
      client-service-teachers/src/main/resources/templates/student-edit.html
  6. 98
      client-service-teachers/src/main/resources/templates/students.html
  7. 1
      out/resource-service-api/src/main/docs/erd/erd/ERD.svg
  8. 4
      resource-service-api/src/main/docs/erd/erd-course.puml
  9. 4
      resource-service-api/src/main/docs/erd/erd-program.puml
  10. 2
      resource-service-api/src/main/docs/erd/erd-psk.puml
  11. 4
      resource-service-api/src/main/docs/erd/erd-student.puml
  12. 2
      resource-service-api/src/main/docs/erd/erd-teacher.puml
  13. 2
      resource-service-api/src/main/resources/static/content/images/ERD.svg

2
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/ProgramController.java

@ -140,7 +140,7 @@ public class ProgramController { @@ -140,7 +140,7 @@ public class ProgramController {
public String updateProgram(@PathVariable Long id
, @ModelAttribute("p") @Validated Program program) throws JsonMappingException, JsonProcessingException{
client.post()
.uri("/teacher/update/" + program.getId())
.uri("/program/update/" + program.getId())
.body(Mono.just(program), Program.class)
.retrieve()
.toBodilessEntity()

153
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/StudentController.java

@ -0,0 +1,153 @@ @@ -0,0 +1,153 @@
package ru.molokoin.clientserviceteachers.controllers;
import java.time.Duration;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.reactive.function.client.WebClient;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import reactor.core.publisher.Mono;
import ru.molokoin.clientserviceteachers.entities.Organization;
import ru.molokoin.clientserviceteachers.entities.Student;
@Controller
@RequestMapping(path = "/")
public class StudentController {
@Autowired
private WebClient client;
@GetMapping("/students")
public String studentList(Model model) throws JsonMappingException, JsonProcessingException{
List<Student> students = client.method(HttpMethod.GET)
.uri("/student/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Student>>(){})
.block();
model.addAttribute("students", students);
model.addAttribute("stu", new Student());
System.out.println("STUDENTS:" + students.toString());
return "students";
}
@GetMapping("/student-edit/{id}")
public String studentById(Model model, @PathVariable Long id) {
/**
* получение списка организаций из ресурсов
* - для select поля формы
*/
List<Organization> orgs = client.get()
.uri("/organization/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Organization>>(){})
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("orgs", orgs);
/**
* Получение сведений о студенте из ресурсов
*/
Student stu = client.get()
.uri("/student/" + id)
.retrieve()
.bodyToMono(Student.class)
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("student", stu);
return "student-edit";
}
@PostMapping(
path = "/student/add",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String addStudent(Model model, @ModelAttribute("student") @Validated Student stu) throws JsonMappingException, JsonProcessingException{
/**
* получение списка организаций из ресурсов
* - для select поля формы
*/
List<Organization> orgs = client.get()
.uri("/organization/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Organization>>(){})
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("orgs", orgs);
client.post()
.uri("/student/create")
.body(Mono.just(stu), Student.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/students";
}
@GetMapping(path = "/student/add")
public String addStudentFrame(Model model){
/**
* получение списка организаций из ресурсов
* - для select поля формы
*/
List<Organization> orgs = client.get()
.uri("/organization/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Organization>>(){})
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("orgs", orgs);
/**
* Создание нового объекта, для последующего заполнения данными из формы
*/
Student student = new Student();
model.addAttribute("newStudent", student);
return "student-add";
}
@GetMapping(path = "/student/delete/{id}")
public String deleteStudent(@PathVariable Long id) throws JsonMappingException, JsonProcessingException{
client.delete()
.uri("/student/delete/" + id)
.retrieve()
.bodyToMono(String.class)
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/students";
}
@PostMapping(
path = "/student/update/{id}",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String updateStudent(@PathVariable Long id
, @ModelAttribute("stu") @Validated Student student) throws JsonMappingException, JsonProcessingException{
client.post()
.uri("/student/update/" + student.getId())
.body(Mono.just(student), Student.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/students";
}
}

55
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Student.java

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
package ru.molokoin.clientserviceteachers.entities;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Student implements Serializable{
private long id;
private String first_name;//Имя
private String second_name;//Отчество
private String last_name;//Фамилия
private String profession;//Профессия
private String category;//Категория (ИТР или рабочий)
private String direction;//Структурное подразделение
private String snils;//СНИЛС
private Date berth;//Дата рождения
private String sitizenship;//Гражданство
private String sex;//Пол (Муж/Жен)
private Organization organization;//Организация - работодатель
/**
* Конструктор со всеми полями сущности кроме id
* @param first_name
* @param second_name
* @param last_name
* @param profession
* @param category
* @param direction
* @param snils
* @param berth
* @param sitizenship
* @param sex
* @param organization
*/
public Student(String first_name, String second_name, String last_name, String profession, String category,
String direction, String snils, Date berth, String sitizenship, String sex, Organization organization) {
this.first_name = first_name;
this.second_name = second_name;
this.last_name = last_name;
this.profession = profession;
this.category = category;
this.direction = direction;
this.snils = snils;
this.berth = berth;
this.sitizenship = sitizenship;
this.sex = sex;
this.organization = organization;
}
}

76
client-service-teachers/src/main/resources/templates/student-add.html

@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Student-add</title>
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head>
<body>
<header>
add : student
</header>
<main>
<h2>Добавление сведений о суденте:</h2>
<form th:action="@{/student/add}" method="post" th:object="${newStudent}">
<div>
<label>id: </label>
<input type="text" th:field="${newStudent.id}" placeholder="" readonly />
</div>
<div>
<label>Имя: </label>
<input type="text" th:field="${newStudent.first_name}" placeholder="" />
</div>
<div>
<label>Отчество: </label>
<input type="text" th:field="${newStudent.second_name}" placeholder="" />
</div>
<div>
<label>Фамилия: </label>
<input type="text" th:field="${newStudent.last_name}" placeholder="" />
</div>
<div>
<label>Профессия: </label>
<input type="text" th:field="${newStudent.profession}" placeholder="" />
</div>
<div>
<label>Категория работника (ИТР/рабочий): </label>
<input type="text" th:field="${newStudent.category}" placeholder="" />
</div>
<div>
<label>Структурное подразделение: </label>
<input type="text" th:field="${newStudent.direction}" placeholder="" />
</div>
<div>
<label>СИЛС: </label>
<input type="text" th:field="${newStudent.snils}" placeholder="" />
</div>
<div>
<label>Дата рождения: </label>
<input type="date" th:field="${newStudent.berth}" placeholder="" />
</div>
<div>
<label>Гражданство: </label>
<input type="text" th:field="${newStudent.sitizenship}" placeholder="" />
</div>
<div>
<label>Пол: </label>
<input type="text" th:field="${newStudent.sex}" placeholder="" />
</div>
<div>
<label>Организация:</label>
<select th:field="${newStudent.organization.id}">
<option value="0" disabled >выберите организацию</option>
<option th:each="option : ${orgs}" th:value="${option.id}" th:text="${option.name_short}"></option>
</select>
</div>
<br>
<input type="submit" value="СОХРАНИТЬ И ВЕРНУТЬСЯ"/>
</form>
<br>
<form th:action="@{/students}" th:method="get">
<input type="submit" value="ВЕРНУТЬСЯ"/>
</form>
</main>
</body>

76
client-service-teachers/src/main/resources/templates/student-edit.html

@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Student-edit</title>
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head>
<body>
<header>
edit : student
</header>
<main>
<h2>Редактирование сведений о студенте:</h2>
<form th:action="@{/student/add}" method="post" th:object="${student}">
<div>
<label>id: </label>
<input type="text" th:field="${student.id}" placeholder="" readonly />
</div>
<div>
<label>Имя: </label>
<input type="text" th:field="${student.first_name}" placeholder="" />
</div>
<div>
<label>Отчество: </label>
<input type="text" th:field="${student.second_name}" placeholder="" />
</div>
<div>
<label>Фамилия: </label>
<input type="text" th:field="${student.last_name}" placeholder="" />
</div>
<div>
<label>Профессия: </label>
<input type="text" th:field="${student.profession}" placeholder="" />
</div>
<div>
<label>Категория (ИТР или рабочий): </label>
<input type="text" th:field="${student.category}" placeholder="" />
</div>
<div>
<label>Структурное подразделение: </label>
<input type="text" th:field="${student.direction}" placeholder="" />
</div>
<div>
<label>СНИЛС: </label>
<input type="text" th:field="${student.snils}" placeholder="" />
</div>
<div>
<label>Дата рождения: </label>
<input type="date" th:field="${student.berth}" placeholder="" />
</div>
<div>
<label>Гражданство: </label>
<input type="text" th:field="${student.sitizenship}" placeholder="" />
</div>
<div>
<label>Пол (Муж/Жен): </label>
<input type="text" th:field="${student.sex}" placeholder="" />
</div>
<div>
<label>Организация - работодатель: </label>
<select th:field="${student.organization.id}">
<option value="0" disabled >выберите организацию</option>
<option th:each="option : ${orgs}" th:value="${option.id}" th:text="${option.name_short}"></option>
</select>
</div>
<br>
<input type="submit" value="СОХРАНИТЬ И ВЕРНУТЬСЯ"/>
</form>
<br>
<form th:action="@{/students}" th:method="get">
<input type="submit" value="ВЕРНУТЬСЯ"/>
</form>
</main>
</body>

98
client-service-teachers/src/main/resources/templates/students.html

@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Students</title>
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>
</head>
<body>
<header>
<h1>Students</h1>
menu : auth : Students
<br>
</header>
<main>
<div class="main-wraper">
<h2>Перечень студентов:</h2>
<form th:action="@{/students}" method="get" th:object="${stu}"></form>
<table>
<thead>
<tr>
<th>id</th>
<th>first_name</th>
<th>second_name</th>
<th>last_name</th>
<th>profession</th>
<th>category</th>
<th>direction</th>
<th>snils</th>
<th>berth</th>
<th>sitizenship</th>
<th>sex</th>
<th>organization</th>
<th>
<!-- Переход на страницу добавления записи о новом студенте -->
<form th:action="@{/student/add}" th:method="get">
<input type="submit" value="ADD --|>"/>
</form>
</th>
</tr>
</thead>
<tbody>
<tr th:each="stu: ${students}">
<td>
<input type="text" id="id" name="id" th:value="${stu.id}" readonly />
</td>
<td>
<input type="text" id="first_name" name="first_name" th:value="${stu.first_name}" readonly />
</td>
<td>
<input type="text" id="second_name" name="second_name" th:value="${stu.second_name}" readonly />
</td>
<td>
<input type="text" id="last_name" name="last_name" th:value="${stu.last_name}" readonly />
</td>
<td>
<input type="text" id="profession" name="profession" th:value="${stu.profession}" readonly />
</td>
<td>
<input type="text" id="category" name="category" th:value="${stu.category}" readonly />
</td>
<td>
<input type="text" id="direction" name="direction" th:value="${stu.direction}" readonly />
</td>
<td>
<input type="text" id="snils" name="snils" th:value="${stu.snils}" readonly />
</td>
<td>
<input type="text" id="berth" name="berth" th:value="${stu.berth}" readonly />
</td>
<td>
<input type="text" id="sitizenship" name="sitizenship" th:value="${stu.sitizenship}" readonly />
</td>
<td>
<input type="text" id="sex" name="sex" th:value="${stu.sex}" readonly />
</td>
<td>
<input type="text" id="organization" name="organization" th:value="${stu.organization.name_short}" readonly />
</td>
<td>
<form th:action="@{student-edit/{id}(id=${stu.id})}" th:method="get">
<input type="submit" value="--|>"/>
</form>
<form th:action="@{/student/delete/{id}(id=${stu.id})}" th:method="get">
<input type="submit" value="X"/>
</form>
</td>
</tr>
</tbody>
</table>
</table>
</div>
</main>
</body>
</html>

1
out/resource-service-api/src/main/docs/erd/erd/ERD.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 74 KiB

4
resource-service-api/src/main/docs/erd/erd-course.puml

@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): course (данные о группе @@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): course (данные о группе
entity "Курс" as courses
entity "Объекты строительства" as building_objects
table(courses){
table(courses) #338AFF {
primary_key(id): SERIAL >>"Идентификатор"
column(place): VARCHAR[10] >>"Место проведения занятий"
column(start_date): DATE >>"Дата начала обучения"
@ -25,7 +25,7 @@ table(courses){ @@ -25,7 +25,7 @@ table(courses){
foreign_key(building_id): INTEGER >>"Идентификатор объекта строительства"
}
table(building_objects){
table(building_objects) #338AFF {
primary_key(id): SERIAL >>"Идентификатор"
column(name_short): VARCHAR[80] >>"Сокращенное наименование"
column(name_full): VARCHAR[80] >>"Полное наименование"

4
resource-service-api/src/main/docs/erd/erd-program.puml

@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): psk (данные производст @@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): psk (данные производст
entity "Программы обучения" as programms
table(programms){
table(programms) #338AFF{
primary_key(id): SERIAL >>"Идентификатор"
column(name): VARCHAR[200] >>"Наименование программы"
column(lenght): TIME >>"Продолжительность программы обучения"
@ -22,7 +22,7 @@ table(programms){ @@ -22,7 +22,7 @@ table(programms){
foreign_key(cretarea_id): INTEGER >>"Идентификатор направления обучения"
}
table(program_cretareas){
table(program_cretareas) #338AFF{
primary_key(id): SERIAL >>"Идентификатор"
column(name): VARCHAR[200] >>"Наименование направления обучения"
column(name_short): VARCHAR[200] >>"Сокращенное наименование направления обучения"

2
resource-service-api/src/main/docs/erd/erd-psk.puml

@ -9,7 +9,7 @@ title "Entity Relationship Diagram (ERD): psk (данные производст @@ -9,7 +9,7 @@ title "Entity Relationship Diagram (ERD): psk (данные производст
entity "ПСК" as psk
table(psk){
table(psk) #338AFF{
primary_key(id): SERIAL >>"Идентификатор"
column(ownership): VARCHAR[10] >>"Форма собственности ПСК"
column(name_full): VARCHAR[120] >>"Наименование ПСК полное"

4
resource-service-api/src/main/docs/erd/erd-student.puml

@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): students (данные об обуче @@ -13,7 +13,7 @@ title "Entity Relationship Diagram (ERD): students (данные об обуче
entity "Студенты" as students
table(students){
table(students) #338AFF{
primary_key(id): SERIAL >>"Идентификатор"
column(first_name): VARCHAR[80] >>"Имя обучающегося"
column(second_name): VARCHAR[80] >>"Отчество обучающегося"
@ -28,7 +28,7 @@ table(students){ @@ -28,7 +28,7 @@ table(students){
foreign_key(psk_id): INTEGER >>"Данные о ПСК"
}
table(aside_reestr){
table(aside_reestr) #338AFF{
column(document_type): VARCHAR[20] >>"Наименование документа о образовании"
column(document_sery): VARCHAR[20] >>"Серия документа о образовании"
column(document_number): VARCHAR[20] >>"Номер документа о образовании"

2
resource-service-api/src/main/docs/erd/erd-teacher.puml

@ -9,7 +9,7 @@ title "Entity Relationship Diagram (ERD): teachers (данные о препод @@ -9,7 +9,7 @@ title "Entity Relationship Diagram (ERD): teachers (данные о препод
entity "Преподаватели" as teachers
table(teachers){
table(teachers) #338AFF{
primary_key(id): SERIAL >>"Идентификатор"
column(first_name): VARCHAR[80] >>"Имя"
column(second_name): VARCHAR[80] >>"Отчество"

2
resource-service-api/src/main/resources/static/content/images/ERD.svg

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Loading…
Cancel
Save