LabWork05.

This commit is contained in:
Programmist73 2023-04-24 16:20:28 +04:00
parent 167ca7eb82
commit 9b72e39432
14 changed files with 125 additions and 55 deletions

View File

@ -0,0 +1,39 @@
package premium_store.controller.DTO;
public class SortDTO {
private String nation;
private int firstLevel;
private int secondLevel;
public SortDTO(){}
public SortDTO(String nation, int firstLevel, int secondLevel){
this.nation = nation;
this.firstLevel = firstLevel;
this.secondLevel = secondLevel;
}
public String getNation(){
return nation;
}
public int getFirstLevel() {
return firstLevel;
}
public int getSecondLevel() {
return secondLevel;
}
public void setNation(String nation){
this.nation = nation;
}
public void setFirstLevel(int firstLevel){
this.firstLevel = firstLevel;
}
public void setSecondLevel(int secondLevel) {
this.secondLevel = secondLevel;
}
}

View File

@ -4,10 +4,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.controller.DTO.LevelDTO; import premium_store.controller.DTO.*;
import premium_store.controller.DTO.SimpleNationDTO;
import premium_store.controller.DTO.SupportTankDTO;
import premium_store.controller.DTO.TankDTO;
import premium_store.service.NationService; import premium_store.service.NationService;
import premium_store.service.TankLevelService; import premium_store.service.TankLevelService;
import premium_store.service.TankService; import premium_store.service.TankService;
@ -47,6 +44,8 @@ public class TankMvcController {
model.addAttribute("levels", levels); model.addAttribute("levels", levels);
model.addAttribute("sortDTO", new SortDTO());
return "tank"; return "tank";
} }
@ -75,12 +74,10 @@ public class TankMvcController {
return "tank-edit"; return "tank-edit";
} }
@GetMapping("/filteredList/{nation}?{firstLevel}&{secondLevel}") @GetMapping("/filteredList")
public String getFilteredTanks(@RequestParam("nation") String nation, public String getFilteredTanks(@ModelAttribute SortDTO sortDTO,
@RequestParam("firstLevel") int firstLevel, Model model) {
@RequestParam("secondLevel") int secondLevel, List<TankDTO> tanks = tankService.findListTank(sortDTO.getNation(), sortDTO.getFirstLevel(), sortDTO.getSecondLevel()).stream()
Model model) {
List<TankDTO> tanks = tankService.findListTank(nation, firstLevel, secondLevel).stream()
.map(TankDTO::new) .map(TankDTO::new)
.toList(); .toList();

View File

@ -73,6 +73,7 @@
.myModalContent{ .myModalContent{
display: inline-block; display: inline-block;
padding: 15px; padding: 15px;
width: 100%;
background: #FF652F; background: #FF652F;
border-radius: 16px; border-radius: 16px;
min-width: 300px; min-width: 300px;

View File

@ -1,3 +1,10 @@
.add-level-button{
border-radius: 10px;
border-color: #505050;
background-color: #FFE430;
font-weight: 900;
}
.level-card{ .level-card{
display: flex; display: flex;
width: 100%; width: 100%;
@ -57,6 +64,7 @@
.myModalContent{ .myModalContent{
display: flex; display: flex;
padding: 15px; padding: 15px;
width: 100%;
background: #FF652F; background: #FF652F;
border-radius: 16px; border-radius: 16px;
min-width: 300px; min-width: 300px;

View File

@ -17,6 +17,7 @@
.myModalContent{ .myModalContent{
display: flex; display: flex;
padding: 15px; padding: 15px;
width: 100%;
background: #FF652F; background: #FF652F;
border-radius: 16px; border-radius: 16px;
min-width: 300px; min-width: 300px;

View File

@ -60,7 +60,8 @@
.Main_head{ .Main_head{
display: flex; display: flex;
padding: 15px; padding: 15px;
margin-top: 30px; width: 80%;
margin: 30px;
border: 5px solid; border: 5px solid;
border-color: #FF652F; border-color: #FF652F;
border-radius: 10px; border-radius: 10px;

View File

@ -6,6 +6,13 @@
border-color: #505050; border-color: #505050;
} }
.add-tank-button{
border-radius: 10px;
border-color: #505050;
background-color: #FFE430;
font-weight: 900;
}
.tank-card{ .tank-card{
display: flex; display: flex;
width: 100%; width: 100%;
@ -64,6 +71,7 @@
.myModalContent{ .myModalContent{
display: inline-block; display: inline-block;
width: 100%;
padding: 15px; padding: 15px;
background: #FF652F; background: #FF652F;
border-radius: 16px; border-radius: 16px;

View File

@ -11,10 +11,12 @@
<div layout:fragment="content"> <div layout:fragment="content">
<div class="Group_create_level"> <div class="Group_create_level">
<h1>Генератор клиентов</h1> <h1>Генератор клиентов</h1>
<a class="add-client-button" type="button" <h2>
th:href="@{/client/edit/}"> <a class="add-level-button text-dark" type="button"
Создать клиента th:href="@{/client/edit/}">
</a> Создать клиента
</a>
</h2>
</div> </div>
<div> <div>
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px"> <h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">

View File

@ -24,18 +24,18 @@
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarNav"> <div class="collapse navbar-collapse justify-content-around" id="navbarNav">
<ul class="Main_head navbar-nav me-auto align-items-center" th:with="activeLink=${#request.requestURI}"> <ul class="Main_head navbar-nav align-items-center" th:with="activeLink=${#request.requestURI}">
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group" href="/level" <a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/level"
th:classappend="${#strings.equals(activeLink, '/level')} ? 'active' : ''">Обзор уровней th:classappend="${#strings.equals(activeLink, '/level')} ? 'active' : ''">Обзор уровней
</a> </a>
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group " href="/tank" <a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/tank"
th:classappend="${#strings.equals(activeLink, '/tank')} ? 'active' : ''">Обзор танков th:classappend="${#strings.equals(activeLink, '/tank')} ? 'active' : ''">Обзор танков
</a> </a>
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group " href="/nation" <a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/nation"
th:classappend="${#strings.equals(activeLink, '/nation')} ? 'active' : ''">Обзор наций th:classappend="${#strings.equals(activeLink, '/nation')} ? 'active' : ''">Обзор наций
</a> </a>
<a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group" href="/client" <a class="nav-link btn border border-3 border-dark fs-4 lh-15 Button_Main_Group text-dark" href="/client"
th:classappend="${#strings.equals(activeLink, '/client')} ? 'active' : ''">Обзор клиентов th:classappend="${#strings.equals(activeLink, '/client')} ? 'active' : ''">Обзор клиентов
</a> </a>
</ul> </ul>

View File

@ -1,10 +1,19 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}">
<head> <head>
<meta charset="UTF-8"> <link rel="stylesheet" href="/css/nation.css"/>
<title>Title</title> <link rel="stylesheet" href="/css/modal-nation.css"/>
</head> </head>
<body> <body>
<div layout:fragment="content">
</body> <div th:each="tank, iterator: ${tanks}">
</html> <div class="nation-card">
<p class="nation-attribute" th:text="'Номер: ' + ${tank.id}"/>
<p class="nation-attribute" th:text="'Название: ' + ${tank.name}"/>
<p class="nation-attribute" th:text="'Стоимость: ' + ${tank.cost}"/>
<p class="nation-attribute" th:text="'Уровень: ' + ${tank.level.level}"/>
</div>
</div>
</div>

View File

@ -11,10 +11,12 @@
<div layout:fragment="content"> <div layout:fragment="content">
<div class="Group_create_level"> <div class="Group_create_level">
<h1>Генератор уровней</h1> <h1>Генератор уровней</h1>
<a class="add-level-button" type="button" <h2>
th:href="@{/level/edit/}"> <a class="add-level-button text-dark" type="button"
Создать уровень th:href="@{/level/edit/}">
</a> Создать уровень
</a>
</h2>
</div> </div>
<div> <div>
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px"> <h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">

View File

@ -11,14 +11,12 @@
<div layout:fragment="content"> <div layout:fragment="content">
<div class="Group_create_level"> <div class="Group_create_level">
<h1>Генератор наций</h1> <h1>Генератор наций</h1>
<a class="add-level-button" type="button" <h2>
th:href="@{/nation/edit/}"> <a class="add-level-button text-dark" type="button"
Создать нацию th:href="@{/nation/edit/}">
</a> Создать нацию
<button class='add-level-button' </a>
> </h2>
Вывести все нации
</button>
</div> </div>
<div> <div>
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px"> <h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">

View File

@ -10,7 +10,7 @@
<div class="Group_create_level"> <div class="Group_create_level">
<h1>Генератор танков</h1> <h1>Генератор танков</h1>
</div> </div>
<form action="#" th:action="@{/tank/{id}(id=${id})}" th:object="${supportTankDTO}" method="post"> <form class="justify-content-around" action="#" th:action="@{/tank/{id}(id=${id})}" th:object="${supportTankDTO}" method="post">
<div class="myModalContent"> <div class="myModalContent">
<label for="name" class="form-label">Название: </label> <label for="name" class="form-label">Название: </label>
<input <input

View File

@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" <html lang="en"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}"> layout:decorate="~{default}">
<head> <head>
@ -11,40 +12,37 @@
<div layout:fragment="content"> <div layout:fragment="content">
<div class="Group_create_level"> <div class="Group_create_level">
<h1>Генератор танков</h1> <h1>Генератор танков</h1>
<a class="add-tank-button" type="button" <h2>
th:href="@{/tank/edit/}"> <a class="add-tank-button text-dark" type="button"
Создать танк th:href="@{/tank/edit/}">
</a> Создать танк
<!--<a class="add-tank-button" type="button" </a>
id="filterStart" </h2>
th:href="@{/tank/filteredList/}"> <form id="filterForm" th:action="@{/tank/filteredList}" th:object="${sortDTO}" method="get">
Фильтрация
</a>-->
<!--<form id="filterForm" th:action="@{/tank/filteredList/{nation}(nation=${document.elements['nation'].value}){firstLevel}(firstLevel=${document.elements['firstLevel'].value}){secondLevel}(secondLevel=${document.elements['secondLevel'].value})}" method="get">
<button class="tank-button" type="submit" <button class="tank-button" type="submit"
th:id="filterStart" th:id="filterStart"
> >
Фильтрация Фильтрация
</button> </button>
<select id="nation" class="form-select" required="true"> <select id="nation" class="form-select" required="true" th:field="*{nation}">
<option th:each="value: ${nations}" <option th:each="value: ${nations}"
th:value="${value.nation}" th:value="${value.nation}"
th:text="${value.nation}"> th:text="${value.nation}">
</option> </option>
</select> </select>
<select id="firstLevel" class="form-select" required="true"> <select id="firstLevel" class="form-select" required="true" th:field="*{firstLevel}">
<option th:each="value: ${levels}" <option th:each="value: ${levels}"
th:value="${value.level}" th:value="${value.level}"
th:text="${value.level}"> th:text="${value.level}">
</option> </option>
</select> </select>
<select id="secondLevel" class="form-select" required="true"> <select id="secondLevel" class="form-select" required="true" th:field="*{secondLevel}">
<option th:each="value: ${levels}" <option th:each="value: ${levels}"
th:value="${value.level}" th:value="${value.level}"
th:text="${value.level}"> th:text="${value.level}">
</option> </option>
</select> </select>
</form>--> </form>
</div> </div>
<div> <div>
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px"> <h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
@ -91,3 +89,9 @@
}); });
</script> </script>
</html> </html>
<!--
-->
<!--th:action="@{/tank/filteredList/{nation}(nation=${document.elements['nation'].value}){firstLevel}(firstLevel=${document.elements['firstLevel'].value}){secondLevel}(secondLevel=${document.elements['secondLevel'].value})}"-->