Browse Source

Organizations done

master
esoe 6 months ago
parent
commit
586a1c765b
  1. 3
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/BuildingController.java
  2. 124
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/OrganizationController.java
  3. 1
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Building.java
  4. 38
      client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Organization.java
  5. 50
      client-service-teachers/src/main/resources/templates/organization-add.html
  6. 49
      client-service-teachers/src/main/resources/templates/organization-edit.html
  7. 71
      client-service-teachers/src/main/resources/templates/organizations.html
  8. 6
      resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/Organization.java

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

@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.JsonMappingException; @@ -22,7 +22,6 @@ 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 = "/")
@ -99,7 +98,7 @@ public class BuildingController { @@ -99,7 +98,7 @@ public class BuildingController {
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String updateTeacher(@PathVariable Long id
public String updateBuilding(@PathVariable Long id
, @ModelAttribute("b") @Validated Building building) throws JsonMappingException, JsonProcessingException{
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");

124
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/controllers/OrganizationController.java

@ -0,0 +1,124 @@ @@ -0,0 +1,124 @@
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.Organization;
@Controller
@RequestMapping(path = "/")
public class OrganizationController {
@Autowired
private WebClient client;
/**
* Получение страницы списка организаций
* @param model
* @return
* @throws JsonMappingException
* @throws JsonProcessingException
*/
@GetMapping("/organizations")
public String organizationList(Model model) throws JsonMappingException, JsonProcessingException{
List<Organization> organizations = client.method(HttpMethod.GET)
.uri("/organization/list")
.retrieve()
.bodyToMono(new ParameterizedTypeReference <List<Organization>>(){})
.block();
model.addAttribute("organization_list", organizations);
model.addAttribute("org", new Organization());
System.out.println("ORGANIZATIONS:" + organizations.toString());
return "organizations";
}
@GetMapping("/organization-edit/{id}")
public String organizationById(Model model, @PathVariable Long id) {
Organization org = client.get()
.uri("/organization/" + id)
.retrieve()
.bodyToMono(Organization.class)
.timeout(Duration.ofSeconds(1))
.block();
model.addAttribute("organization", org);
return "organization-edit";
}
@PostMapping(
path = "/organization/add",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String addOrganization(@ModelAttribute("org") @Validated Organization organization) throws JsonMappingException, JsonProcessingException{
client.post()
.uri("/organization/create")
.body(Mono.just(organization), Organization.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/organizations";
}
@GetMapping(path = "/organization/add")
public String addOrganizationFrame(Model model){
Organization organization = new Organization();
model.addAttribute("newOrganization", organization);
return "organization-add";
}
@GetMapping(path = "/organization/delete/{id}")
public String deleteOrganization(@PathVariable Long id) throws JsonMappingException, JsonProcessingException{
client.delete()
.uri("/organization/delete/" + id)
.retrieve()
.bodyToMono(String.class)
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/organizations";
}
@PostMapping(
path = "/organization/update/{id}",
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE,
produces = {
MediaType.APPLICATION_JSON_VALUE
})
public String updateOrganization(@PathVariable Long id
, @ModelAttribute("org") @Validated Organization organization) throws JsonMappingException, JsonProcessingException{
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");
System.out.println(">>>>>>>>>>>>>> ####################### <<<<<<<<<<<<<<<<<<<<");
System.out.println(">>>>>>>>>>>>>>" + organization.toString());
client.post()
.uri("/organization/update/" + organization.getId())
.body(Mono.just(organization), Organization.class)
.retrieve()
.toBodilessEntity()
.timeout(Duration.ofSeconds(1))
.block();
return "redirect:/organizations";
}
}

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

@ -26,5 +26,4 @@ public class Building implements Serializable{ @@ -26,5 +26,4 @@ public class Building implements Serializable{
this.code_short = code_short;
this.code_full = code_full;
}
}

38
client-service-teachers/src/main/java/ru/molokoin/clientserviceteachers/entities/Organization.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package ru.molokoin.clientserviceteachers.entities;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Сущность организации
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Organization implements Serializable{
private long id;
private String ownership;//Форма собственности ПСК
private String name_short;//Сокращенное наименование
private String name_full;//Полное наименование
private String type;//вид ПСК - производственная/сервисная
private String inn;//ИНН организации
/**
* Конструктор без id
* @param ownership
* @param name_short
* @param name_full
* @param type
* @param inn
*/
public Organization(String ownership, String name_short, String name_full, String type, String inn) {
this.ownership = ownership;
this.name_short = name_short;
this.name_full = name_full;
this.type = type;
this.inn = inn;
}
}

50
client-service-teachers/src/main/resources/templates/organization-add.html

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

49
client-service-teachers/src/main/resources/templates/organization-edit.html

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

71
client-service-teachers/src/main/resources/templates/organizations.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>Organizations</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>ORGANIZATIONS</h1>
menu : auth : Organizations
<br>
</header>
<main>
<div class="main-wraper">
<h2>Перечень объектов строительства:</h2>
<form th:action="@{/organizations}" method="get" th:object="${org}"></form>
<table>
<thead>
<tr>
<th>id</th>
<th>ownership</th>
<th>name_short</th>
<th>name_full</th>
<th>type</th>
<th>inn</th>
<th>
<form th:action="@{/organization/add}" th:method="get">
<input type="submit" value="ADD --|>"/>
</form>
</th>
</tr>
</thead>
<tbody>
<tr th:each="org: ${organization_list}">
<td>
<input type="text" id="id" name="id" th:value="${org.id}" readonly />
</td>
<td>
<input type="text" id="ownership" name="ownership" th:value="${org.ownership}" readonly />
</td>
<td>
<input type="text" id="name_short" name="name_short" th:value="${org.name_short}" readonly />
</td>
<td>
<input type="text" id="name_full" name="name_full" th:value="${org.name_full}" readonly />
</td>
<td>
<input type="text" id="type" name="type" th:value="${org.type}" readonly />
</td>
<td>
<input type="text" id="inn" name="inn" th:value="${org.inn}" readonly />
</td>
<td>
<form th:action="@{organization-edit/{id}(id=${org.id})}" th:method="get">
<input type="submit" value="--|>"/>
</form>
<form th:action="@{/organization/delete/{id}(id=${org.id})}" th:method="get">
<input type="submit" value="X"/>
</form>
</td>
</tr>
</tbody>
</table>
</table>
</div>
</main>
</body>
</html>

6
resource-service-api/src/main/java/ru/molokoin/resourceserviceapi/entities/Organization.java

@ -20,11 +20,11 @@ public class Organization { @@ -20,11 +20,11 @@ public class Organization {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
private String ownership;
private String ownership;//Форма собственности ПСК
private String name_short;//Сокращенное наименование
private String name_full;//Полное наименование
private String type;
private String inn;
private String type;//вид ПСК - производственная/сервисная
private String inn;//ИНН организации
/**
* подготовить конструкторы на все варианты внесения информации о преподавателях

Loading…
Cancel
Save