Добавление первых HTML файлов.

This commit is contained in:
Programmist73 2023-04-22 10:50:45 +04:00
parent b4e48f5c5e
commit 9560588d41
11 changed files with 104 additions and 6 deletions

View File

@ -6,7 +6,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//отключение Cors фильтра - не позволяет организовавыть взаимодействие с разных доменов //отключение Cors фильтра - не позволяет организовавыть взаимодействие с разных доменов
@Configuration @Configuration
class WebConfiguration implements WebMvcConfigurer { public class WebConfiguration implements WebMvcConfigurer {
public static final String REST_API = "/api";
@Override @Override
public void addCorsMappings(CorsRegistry registry) { public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*"); registry.addMapping("/**").allowedMethods("*");

View File

@ -1,6 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration;
import premium_store.controller.DTO.ClientDTO; import premium_store.controller.DTO.ClientDTO;
import premium_store.service.GameClientService; import premium_store.service.GameClientService;
import premium_store.service.TankService; import premium_store.service.TankService;
@ -8,7 +9,7 @@ import premium_store.service.TankService;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/client") @RequestMapping(WebConfiguration.REST_API + "/client")
public class GameClientController { public class GameClientController {
private final GameClientService gameClientService; private final GameClientService gameClientService;
private final TankService tankService; private final TankService tankService;

View File

@ -1,6 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration;
import premium_store.controller.DTO.FullNationDTO; import premium_store.controller.DTO.FullNationDTO;
import premium_store.service.NationService; import premium_store.service.NationService;
import premium_store.service.TankService; import premium_store.service.TankService;
@ -12,7 +13,7 @@ import java.util.List;
//так же здесь прописываем вызовы методов CRUD в привязке к URL //так же здесь прописываем вызовы методов CRUD в привязке к URL
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/nation") @RequestMapping(WebConfiguration.REST_API + "/nation")
public class NationController { public class NationController {
private final NationService nationService; private final NationService nationService;
private final TankService tankService; private final TankService tankService;

View File

@ -1,6 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration;
import premium_store.controller.DTO.TankDTO; 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;
@ -10,7 +11,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping("/tank") @RequestMapping(WebConfiguration.REST_API + "/tank")
public class TankController { public class TankController {
private final TankService tankService; private final TankService tankService;
private final TankLevelService tankLevelService; private final TankLevelService tankLevelService;

View File

@ -1,6 +1,7 @@
package premium_store.controller.controller; package premium_store.controller.controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import premium_store.WebConfiguration;
import premium_store.controller.DTO.LevelDTO; import premium_store.controller.DTO.LevelDTO;
import premium_store.service.TankLevelService; import premium_store.service.TankLevelService;
@ -10,7 +11,7 @@ import java.util.List;
//здесь происходит внедрение зависимости нашего сервиса //здесь происходит внедрение зависимости нашего сервиса
//так же здесь прописываем вызовы методов CRUD в привязке к URL //так же здесь прописываем вызовы методов CRUD в привязке к URL
@RestController @RestController
@RequestMapping("/level") @RequestMapping(WebConfiguration.REST_API + "/level")
public class TankLevelController { public class TankLevelController {
private final TankLevelService tankLevelService; private final TankLevelService tankLevelService;

View File

@ -6,6 +6,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import premium_store.service.exception.ClientNotFoundException; import premium_store.service.exception.ClientNotFoundException;
import premium_store.service.exception.LevelNotFoundException; import premium_store.service.exception.LevelNotFoundException;
import premium_store.service.exception.NationNotFoundException; import premium_store.service.exception.NationNotFoundException;
@ -15,7 +16,7 @@ import premium_store.util.validation.ValidationException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
//контроллер для обработки разнообразных ошибок при работе с запросами к БД //контроллер для обработки разнообразных ошибок при работе с запросами к БД
@ControllerAdvice @ControllerAdvice(annotations = RestController.class)
public class AdviceController { public class AdviceController {
//метод handleException будет вызываться при возникновении исключений типа LevelNotFoundException и т. д. //метод handleException будет вызываться при возникновении исключений типа LevelNotFoundException и т. д.
@ExceptionHandler({ @ExceptionHandler({

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="ru"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8"/>
<title>Премиум магазин</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="icon" href="/favicon.svg">
<script type="text/javascript" src="/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/webjars/font-awesome/6.1.0/css/all.min.css"/>
<link rel="stylesheet" href="/css/style.css"/>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<i class="fa-solid fa-font-awesome"></i>
Премиум магазин
</a>
<button class="navbar-toggler" type="button"
data-bs-toggle="collapse" data-bs-target="#navbarNav"
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="navbar-nav" th:with="activeLink=${#request.requestURI}">
<a class="nav-link" href="/levels"
th:classappend="${#strings.equals(activeLink, '/levels')} ? 'active' : ''">Обзор уровней
</a>
<a class="nav-link" href="/tanks"
th:classappend="${#strings.equals(activeLink, '/tanks')} ? 'active' : ''">Обзор танков
</a>
<a class="nav-link" href="/nations"
th:classappend="${#strings.equals(activeLink, '/nations')} ? 'active' : ''">Обзор наций
</a>
<a class="nav-link" href="/clients"
th:classappend="${#strings.equals(activeLink, '/clients')} ? 'active' : ''">Обзор клиентов
</a>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="container container-padding" layout:fragment="content"></div>
</div>
</body>
<th:block layout:fragment="scripts">
</th:block>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>