Browse Source

BUILDINGS DONE

master
esoe 6 months ago
parent
commit
c416c26007
  1. 117
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/BuildingController.java
  2. 30
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Building.java
  3. 46
      client-service-teachers/src/main/resources/templates/building-add.html
  4. 45
      client-service-teachers/src/main/resources/templates/building-edit.html
  5. 71
      client-service-teachers/src/main/resources/templates/buildings.html
  6. BIN
      out/resource-service-api/src/main/docs/erd/ERD.png
  7. 1
      out/resource-service-api/src/main/docs/erd/ERD.svg
  8. 6
      resource-service-api/src/main/docs/erd/erd.puml
  9. BIN
      resource-service-api/src/main/resources/static/content/images/ERD.png
  10. 2
      resource-service-api/src/main/resources/static/content/images/ERD.svg
  11. 16
      resource-service-api/src/main/resources/static/content/md/hello.md

117
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/BuildingController.java

@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
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.Building;
import ru.molokoin.clientserviceteachers.entities.Teacher;
@Controller
@RequestMapping(path = "/")
public class BuildingController {
@Autowired
private WebClient client;
@GetMapping("/buildings")
public String buildingList(Model model) throws JsonMappingException, JsonProcessingException{
List<Building> buildings = client.method(HttpMethod.GET)
.uri("/building/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Building>>(){})
.block();
model.addAttribute("building_list", buildings);
model.addAttribute("b", new Building());
System.out.println("BUILDINGS:" + buildings.toString());
return "buildings";
}
@GetMapping("/building-edit/{id}")
public String buildingById(Model model, @PathVariable Long id) {
Building b = client.get()
.uri("/building/" + id)
.retrieve()
.bodyToMono(Building.class)
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("building", b);
return "building-edit";
}
@PostMapping(
path = "/building/add",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String addBuilding(@ModelAttribute("b") @Validated Building building) throws JsonMappingException, JsonProcessingException{
client.post()
.uri("/building/create")
.body(Mono.just(building), Building.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/buildings";
}
@GetMapping(
path = "/building/add"
)
public String addBuildingFrame(Model model){
Building building = new Building();
model.addAttribute("newBuilding", building);
return "building-add";
}
@GetMapping(path = "/building/delete/{id}")
public String deleteBuilding(@PathVariable Long id) throws JsonMappingException, JsonProcessingException{
client.delete()
.uri("/building/delete/" + id)
.retrieve()
.bodyToMono(String.class)
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/buildings";
}
@PostMapping(
path = "/building/update/{id}",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String updateTeacher(@PathVariable Long id
, @ModelAttribute("b") @Validated Building building) throws JsonMappingException, JsonProcessingException{
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");
System.out.println(">>>>>>>>>>>>>>" + building.toString());
client.post()
.uri("/building/update/" + building.getId())
.body(Mono.just(building), Building.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/buildings";
}
}

30
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Building.java

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
package ru.molokoin.clientserviceteachers.entities;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Сущность объекта строительства
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Building implements Serializable{
private long id;
private String name_short;//Сокращенное наименование
private String name_full;//Полное наименование
private String code_short;//Краткий код
private String code_full;//Полный код
// подготовить конструкторы на все варианты внесения информации о преподавателях
public Building(String name_short, String name_full, String code_short, String code_full){
this.name_short = name_short;
this.name_full = name_full;
this.code_short = code_short;
this.code_full = code_full;
}
}

46
client-service-teachers/src/main/resources/templates/building-add.html

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Building</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 : building
</header>
<main>
<h2>Добавление нового объекта строительства:</h2>
<form th:action="@{/building/add}" method="post" th:object="${newBuilding}">
<div>
<label>id: </label>
<input type="text" th:field="${newBuilding.id}" placeholder="" readonly />
</div>
<div>
<label>Наименование полное: </label>
<input type="text" th:field="${newBuilding.name_full}" placeholder="" />
</div>
<div>
<label>Наименование сокращенно: </label>
<input type="text" th:field="${newBuilding.name_short}" placeholder="" />
</div>
<div>
<label>Кодовое обозначение полное: </label>
<input type="text" th:field="${newBuilding.code_full}" placeholder="" />
</div>
<div>
<label>Кодовое обозначение сокращенно: </label>
<input type="text" th:field="${newBuilding.code_short}" placeholder="" />
</div>
<br>
<input type="submit" value="СОХРАНИТЬ И ВЕРНУТЬСЯ"/>
</form>
<br>
<form th:action="@{/buildings}" th:method="get">
<input type="submit" value="ВЕРНУТЬСЯ"/>
</form>
</main>
</body>

45
client-service-teachers/src/main/resources/templates/building-edit.html

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Buildings</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 : building
</header>
<main>
<h2>Редактирование сведений об объекте строительства:</h2>
<form th:action="@{/building/add}" method="post" th:object="${b}">
<div>
<label>id: </label>
<input type="text" th:field="${building.id}" placeholder="" readonly />
</div>
<div>
<label>Наименование полное: </label>
<input type="text" th:field="${building.name_full}" placeholder="" />
</div>
<div>
<label>Наименование сокращенно: </label>
<input type="text" th:field="${building.name_short}" placeholder="" />
</div>
<div>
<label>Кодовое обозначение полное: </label>
<input type="text" th:field="${building.code_full}" placeholder="" />
</div>
<div>
<label>Кодовое обозначение сокращенно: </label>
<input type="text" th:field="${building.code_short}" placeholder="" />
</div>
<br>
<input type="submit" value="СОХРАНИТЬ И ВЕРНУТЬСЯ"/>
</form>
<br>
<form th:action="@{/buildings}" th:method="get">
<input type="submit" value="ВЕРНУТЬСЯ"/>
</form>
</main>
</body>

71
client-service-teachers/src/main/resources/templates/buildings.html

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Buildings</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>BUILDINGS</h1>
menu : auth : buildings
<br>
</header>
<main>
<div class="main-wraper">
<!-- Вывод сведений о приложении из *.md файла (client-service-teachers\src\main\resources\static\teachers.md) -->
<!-- <zero-md th:src="@{/teachers.md}"></zero-md>
<br> -->
<h2>Перечень объектов строительства:</h2>
<form th:action="@{/buildings}" method="get" th:object="${b}"></form>
<table>
<thead>
<tr>
<th>id</th>
<th>name_short</th>
<th>name_full</th>
<th>code_short</th>
<th>code_full</th>
<th>
<form th:action="@{/building/add}" th:method="get">
<input type="submit" value="ADD --|>"/>
</form>
</th>
</tr>
</thead>
<tbody>
<tr th:each="b: ${building_list}">
<td>
<input type="text" id="id" name="id" th:value="${b.id}" readonly />
</td>
<td>
<input type="text" id="name_short" name="name_short" th:value="${b.name_short}" readonly />
</td>
<td>
<input type="text" id="name_full" name="name_full" th:value="${b.name_full}" readonly />
</td>
<td>
<input type="text" id="code_short" name="code_short" th:value="${b.code_short}" readonly />
</td>
<td>
<input type="text" id="code_full" name="code_full" th:value="${b.code_full}" readonly />
</td>
<td>
<form th:action="@{building-edit/{id}(id=${b.id})}" th:method="get">
<input type="submit" value="--|>"/>
</form>
<form th:action="@{/building/delete/{id}(id=${b.id})}" th:method="get">
<input type="submit" value="X"/>
</form>
</td>
</tr>
</tbody>
</table>
</table>
</div>
</main>
</body>
</html>

BIN
out/resource-service-api/src/main/docs/erd/ERD.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

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

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 74 KiB

6
resource-service-api/src/main/docs/erd/erd.puml

@ -23,7 +23,7 @@ title "Entity Relationship Diagram (ERD): education-records (учет обуче @@ -23,7 +23,7 @@ title "Entity Relationship Diagram (ERD): education-records (учет обуче
entity "Реестр обученных" as repository
' Реестр обученных
table(repository){
table(repository) #eaa{
primary_key(id): LONGSERIAL >>"Идентификатор"
' column(psk_type): VARCHAR[40] >>"Вид ПСК"
' column(psk_name): VARCHAR[40] >>"Наименование ПСК"
@ -52,7 +52,7 @@ table(repository){ @@ -52,7 +52,7 @@ table(repository){
foreign_key(student_id): INTEGER >>"Данные о студенте"
}
courses }-- repository
students }-- repository
courses -up-{ repository
students --{ repository
@enduml

BIN
resource-service-api/src/main/resources/static/content/images/ERD.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

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

16
resource-service-api/src/main/resources/static/content/md/hello.md

@ -72,6 +72,22 @@ @@ -72,6 +72,22 @@
### DELETE:domain:port/program/delete/{id}
Удаление сведений о программе
## 2.6. Объекты строительтва
### GET:domain:port/building/list
Получение сведений обо всех объектах строительства в json-формате
### GET:domain:port/building/{id}
Получение сведений об объекте строительства в json-формате
### POST:domain:port/building/create
Создание записи о новом объекте строительства
### PUT:domain:port/building/update/{id}
Обновление сведений об объекте строительства
### DELETE:domain:port/building/delete/{id}
Удаление сведений об объекте строительства
# 3. Структура базы данных сервиса : SCHEME
![image entity relationship diagram](content/images/ERD.svg "entity relationship diagram")

Loading…
Cancel
Save