LabWork05.
This commit is contained in:
parent
167ca7eb82
commit
9b72e39432
@ -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;
|
||||
}
|
||||
}
|
@ -4,10 +4,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import premium_store.controller.DTO.LevelDTO;
|
||||
import premium_store.controller.DTO.SimpleNationDTO;
|
||||
import premium_store.controller.DTO.SupportTankDTO;
|
||||
import premium_store.controller.DTO.TankDTO;
|
||||
import premium_store.controller.DTO.*;
|
||||
import premium_store.service.NationService;
|
||||
import premium_store.service.TankLevelService;
|
||||
import premium_store.service.TankService;
|
||||
@ -47,6 +44,8 @@ public class TankMvcController {
|
||||
|
||||
model.addAttribute("levels", levels);
|
||||
|
||||
model.addAttribute("sortDTO", new SortDTO());
|
||||
|
||||
return "tank";
|
||||
}
|
||||
|
||||
@ -75,12 +74,10 @@ public class TankMvcController {
|
||||
return "tank-edit";
|
||||
}
|
||||
|
||||
@GetMapping("/filteredList/{nation}?{firstLevel}&{secondLevel}")
|
||||
public String getFilteredTanks(@RequestParam("nation") String nation,
|
||||
@RequestParam("firstLevel") int firstLevel,
|
||||
@RequestParam("secondLevel") int secondLevel,
|
||||
Model model) {
|
||||
List<TankDTO> tanks = tankService.findListTank(nation, firstLevel, secondLevel).stream()
|
||||
@GetMapping("/filteredList")
|
||||
public String getFilteredTanks(@ModelAttribute SortDTO sortDTO,
|
||||
Model model) {
|
||||
List<TankDTO> tanks = tankService.findListTank(sortDTO.getNation(), sortDTO.getFirstLevel(), sortDTO.getSecondLevel()).stream()
|
||||
.map(TankDTO::new)
|
||||
.toList();
|
||||
|
||||
|
@ -73,6 +73,7 @@
|
||||
.myModalContent{
|
||||
display: inline-block;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
background: #FF652F;
|
||||
border-radius: 16px;
|
||||
min-width: 300px;
|
||||
|
@ -1,3 +1,10 @@
|
||||
.add-level-button{
|
||||
border-radius: 10px;
|
||||
border-color: #505050;
|
||||
background-color: #FFE430;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.level-card{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
@ -57,6 +64,7 @@
|
||||
.myModalContent{
|
||||
display: flex;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
background: #FF652F;
|
||||
border-radius: 16px;
|
||||
min-width: 300px;
|
||||
|
@ -17,6 +17,7 @@
|
||||
.myModalContent{
|
||||
display: flex;
|
||||
padding: 15px;
|
||||
width: 100%;
|
||||
background: #FF652F;
|
||||
border-radius: 16px;
|
||||
min-width: 300px;
|
||||
|
@ -60,7 +60,8 @@
|
||||
.Main_head{
|
||||
display: flex;
|
||||
padding: 15px;
|
||||
margin-top: 30px;
|
||||
width: 80%;
|
||||
margin: 30px;
|
||||
border: 5px solid;
|
||||
border-color: #FF652F;
|
||||
border-radius: 10px;
|
||||
|
@ -6,6 +6,13 @@
|
||||
border-color: #505050;
|
||||
}
|
||||
|
||||
.add-tank-button{
|
||||
border-radius: 10px;
|
||||
border-color: #505050;
|
||||
background-color: #FFE430;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.tank-card{
|
||||
display: flex;
|
||||
width: 100%;
|
||||
@ -64,6 +71,7 @@
|
||||
|
||||
.myModalContent{
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
background: #FF652F;
|
||||
border-radius: 16px;
|
||||
|
@ -11,10 +11,12 @@
|
||||
<div layout:fragment="content">
|
||||
<div class="Group_create_level">
|
||||
<h1>Генератор клиентов</h1>
|
||||
<a class="add-client-button" type="button"
|
||||
th:href="@{/client/edit/}">
|
||||
Создать клиента
|
||||
</a>
|
||||
<h2>
|
||||
<a class="add-level-button text-dark" type="button"
|
||||
th:href="@{/client/edit/}">
|
||||
Создать клиента
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
|
||||
|
@ -24,18 +24,18 @@
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="Main_head navbar-nav me-auto 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"
|
||||
<div class="collapse navbar-collapse justify-content-around" id="navbarNav">
|
||||
<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 text-dark" href="/level"
|
||||
th:classappend="${#strings.equals(activeLink, '/level')} ? 'active' : ''">Обзор уровней
|
||||
</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' : ''">Обзор танков
|
||||
</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' : ''">Обзор наций
|
||||
</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' : ''">Обзор клиентов
|
||||
</a>
|
||||
</ul>
|
||||
|
@ -1,10 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" href="/css/nation.css"/>
|
||||
<link rel="stylesheet" href="/css/modal-nation.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<div layout:fragment="content">
|
||||
<div th:each="tank, iterator: ${tanks}">
|
||||
<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>
|
@ -11,10 +11,12 @@
|
||||
<div layout:fragment="content">
|
||||
<div class="Group_create_level">
|
||||
<h1>Генератор уровней</h1>
|
||||
<a class="add-level-button" type="button"
|
||||
th:href="@{/level/edit/}">
|
||||
Создать уровень
|
||||
</a>
|
||||
<h2>
|
||||
<a class="add-level-button text-dark" type="button"
|
||||
th:href="@{/level/edit/}">
|
||||
Создать уровень
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
|
||||
|
@ -11,14 +11,12 @@
|
||||
<div layout:fragment="content">
|
||||
<div class="Group_create_level">
|
||||
<h1>Генератор наций</h1>
|
||||
<a class="add-level-button" type="button"
|
||||
th:href="@{/nation/edit/}">
|
||||
Создать нацию
|
||||
</a>
|
||||
<button class='add-level-button'
|
||||
>
|
||||
Вывести все нации
|
||||
</button>
|
||||
<h2>
|
||||
<a class="add-level-button text-dark" type="button"
|
||||
th:href="@{/nation/edit/}">
|
||||
Создать нацию
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div>
|
||||
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
|
||||
|
@ -10,7 +10,7 @@
|
||||
<div class="Group_create_level">
|
||||
<h1>Генератор танков</h1>
|
||||
</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">
|
||||
<label for="name" class="form-label">Название: </label>
|
||||
<input
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
@ -11,40 +12,37 @@
|
||||
<div layout:fragment="content">
|
||||
<div class="Group_create_level">
|
||||
<h1>Генератор танков</h1>
|
||||
<a class="add-tank-button" type="button"
|
||||
th:href="@{/tank/edit/}">
|
||||
Создать танк
|
||||
</a>
|
||||
<!--<a class="add-tank-button" type="button"
|
||||
id="filterStart"
|
||||
th:href="@{/tank/filteredList/}">
|
||||
Фильтрация
|
||||
</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">
|
||||
<h2>
|
||||
<a class="add-tank-button text-dark" type="button"
|
||||
th:href="@{/tank/edit/}">
|
||||
Создать танк
|
||||
</a>
|
||||
</h2>
|
||||
<form id="filterForm" th:action="@{/tank/filteredList}" th:object="${sortDTO}" method="get">
|
||||
<button class="tank-button" type="submit"
|
||||
th:id="filterStart"
|
||||
>
|
||||
Фильтрация
|
||||
</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}"
|
||||
th:value="${value.nation}"
|
||||
th:text="${value.nation}">
|
||||
</option>
|
||||
</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}"
|
||||
th:value="${value.level}"
|
||||
th:text="${value.level}">
|
||||
</option>
|
||||
</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}"
|
||||
th:value="${value.level}"
|
||||
th:text="${value.level}">
|
||||
</option>
|
||||
</select>
|
||||
</form>-->
|
||||
</form>
|
||||
</div>
|
||||
<div>
|
||||
<h1 style="text-align: center; font-family: courier, monospace; background: #FF652F; border-radius: 10px">
|
||||
@ -90,4 +88,10 @@
|
||||
});
|
||||
});
|
||||
</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})}"-->
|
Loading…
x
Reference in New Issue
Block a user