ЛР5 без связей

This commit is contained in:
ityurner02@mail.ru 2023-05-22 20:53:57 +04:00
parent 9fb6531f82
commit 03a0ed7f5d
18 changed files with 356 additions and 7 deletions

Binary file not shown.

View File

@ -24,7 +24,7 @@ public class CollectionMvcController {
@GetMapping @GetMapping
public String getCollections(Model model) { public String getCollections(Model model) {
model.addAttribute("collection", model.addAttribute("collections",
collectionService.findAllCollections().stream() collectionService.findAllCollections().stream()
.map(CollectionDTO::new) .map(CollectionDTO::new)
.toList()); .toList());

View File

@ -25,7 +25,7 @@ public class FilmMvcController {
@GetMapping @GetMapping
public String getFilms(Model model) { public String getFilms(Model model) {
model.addAttribute("film", model.addAttribute("films",
filmService.findAllFilms().stream() filmService.findAllFilms().stream()
.map(FilmDTO::new) .map(FilmDTO::new)
.toList()); .toList());

View File

@ -18,7 +18,7 @@ public class GenreMvcController {
@GetMapping @GetMapping
public String getGenres(Model model) { public String getGenres(Model model) {
model.addAttribute("genre", model.addAttribute("genres",
genreService.findAllGenres().stream() genreService.findAllGenres().stream()
.map(GenreDTO::new) .map(GenreDTO::new)
.toList()); .toList());

View File

@ -0,0 +1,50 @@
header{
font-size: 28px;
}
.logo{
font-size: 64px;
line-height: 76px;
}
footer{
width: 100%;
position: absolute;
bottom: 0;
margin: 0 !important;
}
body {
background: fixed;
background-color: blue !important;
min-height: 100vh;
position: relative;
}
.first_page{
background-image: url(../images/Фон1.jpg);
min-height: 100vh;
width: 100%;
background-size: cover;
background-position: center;
}
.banner-block {
width: 90%;
}
.banner-card {
width: 0;
height: 0;
overflow: hidden;
opacity: 0.2;
transition: 0.5s opacity ease;
}
.banner-card.active {
display: flex;
justify-content: center;
width: 100%;
height: auto;
opacity: 1;
margin: 0 auto;
}
.banner-card.active img {
height: 75vh;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
<form action="#" th:action="@{/collection/{id}(id=${id})}" th:object="${collectionDTO}" method="post">
<div class="mb-3">
<label for="name" class="form-label text-light">Название</label>
<input type="text" class="form-control" id="name" th:field="${collectionDTO.name}" required="true">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-success button-fixed">
<span th:if="${collectionId == null}">Добавить</span>
<span th:if="${collectionId != null}">Обновить</span>
</button>
<a class="btn btn-secondary button-fixed" th:href="@{/collection}">
Назад
</a>
</div>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<h1 class="text-center text-danger mb-4">Коллекции</h1>
<div>
<a class="btn btn-success button-fixed"
th:href="@{/collection/edit}">
<i class="fa-solid fa-plus"></i> Добавить
</a>
</div>
<div class="table-responsive">
<table class="table text-light">
<thead>
<tr>
<th scope="col">Название</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr th:each="collection, iterator: ${collections}">
<td th:text="${collection.name}"></td>
<td>
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-warning button-fixed button-sm"
th:href="@{/collection/edit/{id}(id=${collection.id})}">
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
</a>
<button type="button" class="btn btn-danger button-fixed button-sm"
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${collection.id}').click()|">
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
</button>
</div>
<form th:action="@{/collection/delete/{id}(id=${collection.id})}" method="post">
<button th:id="'remove-' + ${collection.id}" type="submit" style="display: none">
Удалить
</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,45 @@
<!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>VIDEO | FILMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<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="../static/css/style.css" th:href="@{/css/style.css}"/>
</head>
<body>
<header>
<nav class="navbar navbar-dark navbar-expand-lg bg-black">
<div class="container-fluid">
<a class="navbar-brand" href="/"><img src="../static/images/name.png" th:src="@{/images/name.png}"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Переключатель навигации">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<a class="nav-link" href="/" th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Главная</a>
<a class="nav-link" href="/genre" th:classappend="${#strings.equals(activeLink, '/genre')} ? 'active' : ''">Жанры</a>
<a class="nav-link" href="/film" th:classappend="${#strings.equals(activeLink, '/film')} ? 'active' : ''">Фильмы</a>
<a class="nav-link" href="/collection" th:classappend="${#strings.equals(activeLink, '/collection')} ? 'active' : ''">Коллекции</a>
</ul>
</div>
</div>
</nav>
</header>
<div class="container-fluid">
<div class="container container-padding" layout:fragment="content">
</div>
</div>
<footer class="d-flex justify-content-center justify-content-lg-around p-3 bg-success">
<span class="logo text-danger bg-white">VF</span>
<span class="text-white mt-4">более 10 лет только лучшие фильмы</span>
<span class="text-white mt-4">Почта для отзывов и предложений: videofilms@mail.ru</span>
</footer>
</body>
<th:block layout:fragment="scripts">
</th:block>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
<form action="#" th:action="@{/film/{id}(id=${id})}" th:object="${filmDTO}" method="post">
<div class="mb-3">
<label for="name" class="form-label text-light">Название</label>
<input type="text" class="form-control" id="name" th:field="${filmDTO.name}" required="true">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-success button-fixed">
<span th:if="${filmId == null}">Добавить</span>
<span th:if="${filmId != null}">Обновить</span>
</button>
<a class="btn btn-secondary button-fixed" th:href="@{/film}">
Назад
</a>
</div>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<h1 class="text-center text-danger mb-4">Фильмы</h1>
<div>
<a class="btn btn-success button-fixed"
th:href="@{/film/edit}">
<i class="fa-solid fa-plus"></i> Добавить
</a>
</div>
<div class="table-responsive">
<table class="table text-light">
<thead>
<tr>
<th scope="col">Название</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr th:each="film, iterator: ${films}">
<td th:text="${film.name}"></td>
<td>
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-warning button-fixed button-sm"
th:href="@{/film/edit/{id}(id=${film.id})}">
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
</a>
<button type="button" class="btn btn-danger button-fixed button-sm"
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${film.id}').click()|">
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
</button>
</div>
<form th:action="@{/film/delete/{id}(id=${film.id})}" method="post">
<button th:id="'remove-' + ${film.id}" type="submit" style="display: none">
Удалить
</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<div th:text="${errors}" class="margin-bottom alert-danger"></div>
<form action="#" th:action="@{/genre/{id}(id=${id})}" th:object="${genreDTO}" method="post">
<div class="mb-3">
<label for="name" class="form-label text-light">Название</label>
<input type="text" class="form-control" id="name" th:field="${genreDTO.name}" required="true">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-success button-fixed">
<span th:if="${genreId == null}">Добавить</span>
<span th:if="${genreId != null}">Обновить</span>
</button>
<a class="btn btn-secondary button-fixed" th:href="@{/genre}">
Назад
</a>
</div>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div layout:fragment="content">
<h1 class="text-center text-danger mb-4">Жанры</h1>
<div>
<a class="btn btn-success button-fixed"
th:href="@{/genre/edit}">
<i class="fa-solid fa-plus"></i> Добавить
</a>
</div>
<div class="table-responsive">
<table class="table text-light">
<thead>
<tr>
<th scope="col">Название</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr th:each="genre, iterator: ${genres}">
<td th:text="${genre.name}"></td>
<td>
<div class="btn-group" role="group" aria-label="Basic example">
<a class="btn btn-warning button-fixed button-sm"
th:href="@{/genre/edit/{id}(id=${genre.id})}">
<i class="fa fa-pencil" aria-hidden="true"></i> Изменить
</a>
<button type="button" class="btn btn-danger button-fixed button-sm"
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${genre.id}').click()|">
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
</button>
</div>
<form th:action="@{/genre/delete/{id}(id=${genre.id})}" method="post">
<button th:id="'remove-' + ${genre.id}" type="submit" style="display: none">
Удалить
</button>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -1,10 +1,33 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml">
<head> <head>
<meta charset="UTF-8">
<title>VIDEOFILMS</title>
</head> </head>
<body> <body>
<h1>Hello!</h1> <section class="first_page" layout:fragment="content">
<div class="banner-block" id="banner">
<div class="banner-card active">
<img src="/images/banner1.jpg"/>
</div>
<div class="banner-card">
<img src="/images/banner2.jpg"/>
</div>
<div class="banner-card">
<img src="/images/banner3.jpg"/>
</div>
</div>
</section>
<th:block layout:fragment="scripts">
<script>
let active = 0;
let banner = document.getElementById("banner")
setInterval(() => {
active += active == 2 ? -2 : 1;
document.querySelector(".banner-card.active").classList.remove("active");
banner.children[active].classList.add("active");
}, 3000);
</script>
</th:block>
</body> </body>
</html> </html>