瀏覽代碼

Commodities and layouts
Removendo thymeleaf-layout-dialect
versao no lombok

Ranghetti 6 月之前
父節點
當前提交
f2b4e72c2d

+ 1 - 6
pom.xml

@@ -90,12 +90,6 @@
             <artifactId>java-jwt</artifactId>
             <version>4.4.0</version>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
-        <dependency>
-            <groupId>nz.net.ultraq.thymeleaf</groupId>
-            <artifactId>thymeleaf-layout-dialect</artifactId>
-            <version>3.4.0</version>
-        </dependency>
     </dependencies>
 
     <build>
@@ -108,6 +102,7 @@
                         <path>
                             <groupId>org.projectlombok</groupId>
                             <artifactId>lombok</artifactId>
+                            <version>${lombok.version}</version>
                         </path>
                     </annotationProcessorPaths>
                 </configuration>

+ 1 - 1
src/main/java/com/platform2easy/genesis/security/config/SecurityConfiguration.java

@@ -33,7 +33,7 @@ public class SecurityConfiguration {
                 .exceptionHandling(Customizer.withDefaults())
                 //.sessionManagement(sessionManagementConfigurer -> sessionManagementConfigurer.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
                 .authorizeHttpRequests(authorizationRegistry -> authorizationRegistry
-                        .requestMatchers("/login", "/images/**", "/css/**").permitAll()
+                        .requestMatchers("/login", "/images/**", "/css/**","/error/**").permitAll()
                         .requestMatchers(HttpMethod.POST, "/authentication/login").permitAll()
                         .requestMatchers("/compra", "/compra/**").hasRole(UserRole.ADMIN.toString())
                         .anyRequest().authenticated())

+ 32 - 30
src/main/resources/templates/Index.html

@@ -1,44 +1,46 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
-<body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <div class="row">
-            <div class="col-md-4 mb-4">
-                <div class="card shadow-sm">
-                    <div class="card-body">
-                        <h5 class="card-title">Total de Usuários</h5>
-                        <p class="card-text fs-4">1.245</p>
+<body >
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <div class="row">
+                    <div class="col-md-4 mb-4">
+                        <div class="card shadow-sm">
+                            <div class="card-body">
+                                <h5 class="card-title">Total de Usuários</h5>
+                                <p class="card-text fs-4">1.245</p>
+                            </div>
+                        </div>
                     </div>
-                </div>
-            </div>
 
-            <div class="col-md-4 mb-4">
-                <div class="card shadow-sm bg-success text-white">
-                    <div class="card-body">
-                        <h5 class="card-title">Vendas do Mês</h5>
-                        <p class="card-text fs-4">R$ 87.000,00</p>
+                    <div class="col-md-4 mb-4">
+                        <div class="card shadow-sm bg-success text-white">
+                            <div class="card-body">
+                                <h5 class="card-title">Vendas do Mês</h5>
+                                <p class="card-text fs-4">R$ 87.000,00</p>
+                            </div>
+                        </div>
                     </div>
-                </div>
-            </div>
 
-            <div class="col-md-4 mb-4">
-                <div class="card shadow-sm bg-warning text-dark">
-                    <div class="card-body">
-                        <h5 class="card-title">Pendências</h5>
-                        <p class="card-text fs-4">32 tickets abertos</p>
+                    <div class="col-md-4 mb-4">
+                        <div class="card shadow-sm bg-warning text-dark">
+                            <div class="card-body">
+                                <h5 class="card-title">Pendências</h5>
+                                <p class="card-text fs-4">32 tickets abertos</p>
+                            </div>
+                        </div>
                     </div>
                 </div>
             </div>
-        </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 48 - 43
src/main/resources/templates/commodity/form.html

@@ -1,52 +1,57 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <form>
-            <div class="mb-3">
-                <input hidden="true" name="id" th:value="${commodity.id}" type="text">
-
-                <label class="form-label" for="tipoCommodity">Tipo</label>
-                <select class="form-select" id="tipoCommodity" th:field="${commodity.tipoCommodity}">
-                    <option value="" selected="selected">Selecione...</option>
-                    <option value="SACA_GRAOS">Grãos em sacas de 60kg</option>
-                </select>
-
-                <label class="form-label" for="descricao">Descricao</label>
-                <input class="form-control" id="descricao" name="descricao" th:value="${commodity.descricao}" type="text">
-
-                <label class="form-label" for="quantidade">Quantidade</label>
-                <input class="form-control autonumeric" id="quantidade" name="quantidade" th:value="${commodity.quantidade}" type="text">
-
-                <label class="form-label" for="preco">Preço</label>
-                <div class="input-group">
-                    <span class="input-group-text">R$</span>
-                    <input class="form-control autodecimal" id="preco" name="preco" th:value="${commodity.preco}" type="text" placeholder="0,00">
-                </div>
-
-                <label class="form-label" for="vencimentoPagamento">Vencimento do Pagamento</label>
-                <input class="form-control" id="vencimentoPagamento" name="vencimentoPagamento" th:value="${commodity.vencimentoPagamento}"
-                       type="date">
-
-                <label class="form-label" for="dataLimiteEntrega">Data Limite da Entrega</label>
-                <input class="form-control" id="dataLimiteEntrega" name="dataLimiteEntrega" th:value="${commodity.dataLimiteEntrega}" type="date">
-
-                <label class="form-label" for="cedulaProdutoRural">CPR</label>
-                <input class="form-control" id="cedulaProdutoRural" name="dataLimiteEntrega" th:value="${commodity.cedulaProdutoRural}" type="file">
-
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <form>
+                    <div class="mb-3">
+                        <input hidden="true" name="id" th:value="${commodity.id}" type="text">
+
+                        <label class="form-label" for="tipoCommodity">Tipo</label>
+                        <select class="form-select" id="tipoCommodity" th:field="${commodity.tipoCommodity}">
+                            <option value="" selected="selected">Selecione...</option>
+                            <option value="SACA_GRAOS">Grãos em sacas de 60kg</option>
+                        </select>
+
+                        <label class="form-label" for="descricao">Descricao</label>
+                        <input class="form-control" id="descricao" name="descricao" th:value="${commodity.descricao}" type="text">
+
+                        <label class="form-label" for="quantidade">Quantidade</label>
+                        <input class="form-control autonumeric" id="quantidade" name="quantidade" th:value="${commodity.quantidade}" type="text">
+
+                        <label class="form-label" for="preco">Preço</label>
+                        <div class="input-group">
+                            <span class="input-group-text">R$</span>
+                            <input class="form-control autodecimal" id="preco" name="preco" th:value="${commodity.preco}" type="text"
+                                   placeholder="0,00">
+                        </div>
+
+                        <label class="form-label" for="vencimentoPagamento">Vencimento do Pagamento</label>
+                        <input class="form-control" id="vencimentoPagamento" name="vencimentoPagamento" th:value="${commodity.vencimentoPagamento}"
+                               type="date">
+
+                        <label class="form-label" for="dataLimiteEntrega">Data Limite da Entrega</label>
+                        <input class="form-control" id="dataLimiteEntrega" name="dataLimiteEntrega" th:value="${commodity.dataLimiteEntrega}"
+                               type="date">
+
+                        <label class="form-label" for="cedulaProdutoRural">CPR</label>
+                        <input class="form-control" id="cedulaProdutoRural" name="dataLimiteEntrega" th:value="${commodity.cedulaProdutoRural}"
+                               type="file">
+
+                    </div>
+                    <button class="btn btn-dark" formmethod="post" th:formaction="@{/commodity}" type="submit">Salvar
+                    </button>
+                </form>
             </div>
-            <button class="btn btn-dark" formmethod="post" th:formaction="@{/commodity}" type="submit">Salvar
-            </button>
-        </form>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 35 - 33
src/main/resources/templates/commodity/list.html

@@ -1,41 +1,43 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <table class="table table-hover">
-            <thead>
-            <tr>
-                <th>Código</th>
-                <th>Descrição</th>
-                <th>Ações</th>
-            </tr>
-            </thead>
-            <tbody>
-            <tr th:each="comodity : ${commodities}">
-                <td th:text="${comodity.id}">0</td>
-                <td th:text="${comodity.descricao}">0</td>
-                <td>
-                    <a th:href="@{'/commodity/edit/' + ${comodity.id}}" type="button" class="btn btn-outline-dark"
-                       title="Editar">
-                        <i class="bi bi-pencil-square"></i>
-                    </a>
-                    <a th:href="@{'/commodity/remove/' + ${comodity.id}}" type="button" class="btn btn-outline-dark"
-                       title="Remover">
-                        <i class="bi bi-dash-square"></i>
-                    </a>
-                </td>
-            </tr>
-            </tbody>
-        </table>
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <table class="table table-hover">
+                    <thead>
+                    <tr>
+                        <th>Código</th>
+                        <th>Descrição</th>
+                        <th>Ações</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="comodity : ${commodities}">
+                        <td th:text="${comodity.id}">0</td>
+                        <td th:text="${comodity.descricao}">0</td>
+                        <td>
+                            <a th:href="@{'/commodity/edit/' + ${comodity.id}}" type="button" class="btn btn-outline-dark"
+                               title="Editar">
+                                <i class="bi bi-pencil-square"></i>
+                            </a>
+                            <a th:href="@{'/commodity/remove/' + ${comodity.id}}" type="button" class="btn btn-outline-dark"
+                               title="Remover">
+                                <i class="bi bi-dash-square"></i>
+                            </a>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 64 - 62
src/main/resources/templates/compra/formulario.html

@@ -1,73 +1,75 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <form>
-            <div class="mb-3">
-                <input hidden="true" name="id" th:value="${compra.id}" type="text">
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <form>
+                    <div class="mb-3">
+                        <input hidden="true" name="id" th:value="${compra.id}" type="text">
 
-                <label class="form-label" for="fornecedor">Fornecedor</label>
-                <input class="form-control" id="fornecedor" name="fornecedor" th:value="${compra.fornecedor}"
-                       type="text">
-            </div>
+                        <label class="form-label" for="fornecedor">Fornecedor</label>
+                        <input class="form-control" id="fornecedor" name="fornecedor" th:value="${compra.fornecedor}"
+                               type="text">
+                    </div>
 
-            <br/>
-            <div class="mb-3">
-                <table class="table">
-                    <thead>
-                    <tr>
-                        <th>Código</th>
-                        <th>Item</th>
-                        <th>Valor</th>
-                        <th></th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr th:each="item, stat : ${compra.itens}">
-                        <td>
-                            <input th:value="${item.id}" th:name="|itens[${stat.index}].id|" type="text" hidden="true">
-                            <input th:value="${item.id}" class="form-control" type="text" disabled>
-                        </td>
-                        <td>
-                            <input th:value="${item.descricao}" class="form-control"
-                                   th:name="|itens[${stat.index}].descricao|" type="text" required>
-                        </td>
-                        <td><input th:value="${item.valor}" class="form-control" th:name="|itens[${stat.index}].valor|"
-                                   type="text" required></td>
-                        <td>
-                            <button class="btn btn-outline-dark" formmethod="post"
-                                    th:formaction="@{'/compra/' + ${stat.index}}"
-                                    type="submit">
-                                <i class="bi bi-dash-square"></i>
-                            </button>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td><input class="form-control" type="text" disabled></td>
-                        <td><input class="form-control" th:name="descricao" type="text"></td>
-                        <td><input class="form-control" th:name="valor" type="text"></td>
-                        <td>
-                            <button class="btn btn-outline-dark" formmethod="post" th:formaction="@{/compra}"
-                                    type="submit">
-                                <i class="bi bi-plus-square"></i>
-                            </button>
-                    </tr>
-                    </tbody>
-                </table>
-            </div>
+                    <br/>
+                    <div class="mb-3">
+                        <table class="table">
+                            <thead>
+                            <tr>
+                                <th>Código</th>
+                                <th>Item</th>
+                                <th>Valor</th>
+                                <th></th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            <tr th:each="item, stat : ${compra.itens}">
+                                <td>
+                                    <input th:value="${item.id}" th:name="|itens[${stat.index}].id|" type="text" hidden="true">
+                                    <input th:value="${item.id}" class="form-control" type="text" disabled>
+                                </td>
+                                <td>
+                                    <input th:value="${item.descricao}" class="form-control"
+                                           th:name="|itens[${stat.index}].descricao|" type="text" required>
+                                </td>
+                                <td><input th:value="${item.valor}" class="form-control" th:name="|itens[${stat.index}].valor|"
+                                           type="text" required></td>
+                                <td>
+                                    <button class="btn btn-outline-dark" formmethod="post"
+                                            th:formaction="@{'/compra/' + ${stat.index}}"
+                                            type="submit">
+                                        <i class="bi bi-dash-square"></i>
+                                    </button>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td><input class="form-control" type="text" disabled></td>
+                                <td><input class="form-control" th:name="descricao" type="text"></td>
+                                <td><input class="form-control" th:name="valor" type="text"></td>
+                                <td>
+                                    <button class="btn btn-outline-dark" formmethod="post" th:formaction="@{/compra}"
+                                            type="submit">
+                                        <i class="bi bi-plus-square"></i>
+                                    </button>
+                            </tr>
+                            </tbody>
+                        </table>
+                    </div>
 
-            <button class="btn btn-dark" formmethod="post" th:formaction="@{/compra/salvar}" type="submit">Salvar
-            </button>
-        </form>
+                    <button class="btn btn-dark" formmethod="post" th:formaction="@{/compra/salvar}" type="submit">Salvar
+                    </button>
+                </form>
+            </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 35 - 33
src/main/resources/templates/compra/lista.html

@@ -1,41 +1,43 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <table class="table table-hover">
-            <thead>
-            <tr>
-                <th>Código</th>
-                <th>Fornecedor</th>
-                <th>Ações</th>
-            </tr>
-            </thead>
-            <tbody>
-            <tr th:each="compra : ${compras}">
-                <td th:text="${compra.id}">0</td>
-                <td th:text="${compra.fornecedor}">0</td>
-                <td>
-                    <a th:href="@{'/compra/editar/' + ${compra.id}}" type="button" class="btn btn-outline-dark"
-                       title="Editar">
-                        <i class="bi bi-pencil-square"></i>
-                    </a>
-                    <a th:href="@{'/compra/remover/' + ${compra.id}}" type="button" class="btn btn-outline-dark"
-                       title="Remover">
-                        <i class="bi bi-dash-square"></i>
-                    </a>
-                </td>
-            </tr>
-            </tbody>
-        </table>
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <table class="table table-hover">
+                    <thead>
+                    <tr>
+                        <th>Código</th>
+                        <th>Fornecedor</th>
+                        <th>Ações</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="compra : ${compras}">
+                        <td th:text="${compra.id}">0</td>
+                        <td th:text="${compra.fornecedor}">0</td>
+                        <td>
+                            <a th:href="@{'/compra/editar/' + ${compra.id}}" type="button" class="btn btn-outline-dark"
+                               title="Editar">
+                                <i class="bi bi-pencil-square"></i>
+                            </a>
+                            <a th:href="@{'/compra/remover/' + ${compra.id}}" type="button" class="btn btn-outline-dark"
+                               title="Remover">
+                                <i class="bi bi-dash-square"></i>
+                            </a>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 4 - 4
src/main/resources/templates/error/400.html

@@ -3,14 +3,14 @@
 <head th:insert="~{layout :: head}">
     <meta charset="UTF-8">
 </head>
-<body class="d-flex flex-column min-vh-100">
-<nav th:insert="~{layout :: nav-top}"></nav>
+<body>
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
 <main class="container text-center my-auto">
     <h1 class="display-4">400</h1>
     <p class="lead">Houve uma situação inesperada em nossa Página.</p>
     <a th:href="@{/}" class="btn btn-dark">Voltar para o início</a>
 </main>
-<footer th:insert="~{layout :: footer}"></footer>
-<div th:insert="~{layout :: script}"></div>
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+<div th:insert="~{fragments/scripts :: div-scripts}"></div>
 </body>
 </html>

+ 4 - 4
src/main/resources/templates/error/403.html

@@ -3,14 +3,14 @@
 <head th:insert="~{layout :: head}">
     <meta charset="UTF-8">
 </head>
-<body class="d-flex flex-column min-vh-100">
-<nav th:insert="~{layout :: nav-top}"></nav>
+<body>
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
 <main class="container text-center my-auto">
     <h1 class="display-4">403</h1>
     <p class="lead">Você não tem acesso a essa página.</p>
     <a th:href="@{/}" class="btn btn-dark">Voltar para o início</a>
 </main>
-<footer th:insert="~{layout :: footer}"></footer>
-<div th:insert="~{layout :: script}"></div>
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+<div th:insert="~{fragments/scripts :: div-scripts}"></div>
 </body>
 </html>

+ 4 - 4
src/main/resources/templates/error/404.html

@@ -3,14 +3,14 @@
 <head th:insert="~{layout :: head}">
     <meta charset="UTF-8">
 </head>
-<body class="d-flex flex-column min-vh-100">
-<nav th:insert="~{layout :: nav-top}"></nav>
+<body>
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
 <main class="container text-center my-auto">
     <h1 class="display-4">404</h1>
     <p class="lead">A página que você está procurando não foi encontrada.</p>
     <a th:href="@{/}" class="btn btn-dark">Voltar para o início</a>
 </main>
-<footer th:insert="~{layout :: footer}"></footer>
-<div th:insert="~{layout :: script}"></div>
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+<div th:insert="~{fragments/scripts :: div-scripts}"></div>
 </body>
 </html>

+ 4 - 4
src/main/resources/templates/error/500.html

@@ -3,14 +3,14 @@
 <head th:insert="~{layout :: head}">
     <meta charset="UTF-8">
 </head>
-<body class="d-flex flex-column min-vh-100">
-<nav th:insert="~{layout :: nav-top}"></nav>
+<body>
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
 <main class="container text-center my-auto">
     <h1 class="display-4">500</h1>
     <p class="lead">Houve uma situação inesperada em nossa Página.</p>
     <a th:href="@{/}" class="btn btn-dark">Voltar para o início</a>
 </main>
-<footer th:insert="~{layout :: footer}"></footer>
-<div th:insert="~{layout :: script}"></div>
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+<div th:insert="~{fragments/scripts :: div-scripts}"></div>
 </body>
 </html>

+ 14 - 0
src/main/resources/templates/fragments/footer.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<footer th:fragment="footer" class="bg-dark text-white text-center">
+    <div class="container">
+        <small>&copy; 2025 TooEasy. Todos os direitos reservados.</small>
+    </div>
+</footer>
+</body>
+</html>

+ 13 - 0
src/main/resources/templates/fragments/head.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:fragment="head">
+    <meta charset="UTF-8">
+    <title>Too Easy</title>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" th:href="@{/css/estilo.css}">
+    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/css/bootstrap.min.css" rel="stylesheet"
+          integrity="sha384-4Q6Gf2aSP4eDXB8Miphtr37CMZZQ5oXLH2yaXMJ2w8e2ZtHTl7GptT4jmndRuHDT" crossorigin="anonymous">
+    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
+</head>
+<body></body>
+</html>

+ 0 - 67
src/main/resources/templates/fragments/layout.html

@@ -1,67 +0,0 @@
-<!DOCTYPE html>
-<html lang="en"
-      xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:sec="http://www.w3.org/1999/xhtml">
-<head th:fragment="head">
-    <meta charset="UTF-8">
-    <title>Too Easy</title>
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <link rel="stylesheet" th:href="@{/css/estilo.css}">
-    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/css/bootstrap.min.css" rel="stylesheet"
-          integrity="sha384-4Q6Gf2aSP4eDXB8Miphtr37CMZZQ5oXLH2yaXMJ2w8e2ZtHTl7GptT4jmndRuHDT" crossorigin="anonymous">
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
-</head>
-<body class="d-flex flex-column min-vh-100">
-
-<nav th:fragment="nav-top" class="navbar navbar-expand-md navbar-dark bg-dark sticky-top">
-    <div class="container-fluid">
-        <div class="navbar-brand">
-            <img th:src="@{/images/too-easy-trade.png}" class="img-fluid" style="max-width: 100px;">
-        </div>
-        <button sec:authorize="isAuthenticated()" class="navbar-toggler" type="button" data-bs-toggle="collapse"
-                data-bs-target="#mobileMenu">
-            <span class="navbar-toggler-icon"></span>
-        </button>
-    </div>
-</nav>
-
-<div class="flex-grow-1 container-fluid">
-    <div class="row h-100">
-        <nav th:replace="~{fragments/menu :: nav-mobileMenu}">
-        </nav>
-        <main class="col-md-10 ms-sm-auto col-12 content-area" layout:fragment="main-content">
-        </main>
-    </div>
-</div>
-
-<footer th:fragment="footer" class="bg-dark text-white text-center">
-    <div class="container">
-        <small>&copy; 2025 TooEasy. Todos os direitos reservados.</small>
-    </div>
-</footer>
-
-<div th:fragment="script">
-    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
-            integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
-            crossorigin="anonymous"></script>
-    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/js/bootstrap.min.js"
-            integrity="sha384-RuyvpeZCxMJCqVUGFI0Do1mQrods/hhxYlcVfGPOfQtPJh0JCw12tUAZ/Mv10S7D"
-            crossorigin="anonymous"></script>
-    <script src="https://cdn.jsdelivr.net/npm/autonumeric@4.5.4/dist/autoNumeric.min.js"></script>
-    <script>
-        AutoNumeric.multiple('.autodecimal', {
-          digitGroupSeparator: '.',
-          decimalCharacter: ',',
-          decimalPlaces: 2,
-          unformatOnSubmit: true
-        });
-        AutoNumeric.multiple('.autonumeric', {
-          digitGroupSeparator: '.',
-          decimalCharacter: ',',
-          decimalPlaces: 0,
-          unformatOnSubmit: true
-        });
-    </script>
-</div>
-</body>
-</html>

+ 12 - 0
src/main/resources/templates/fragments/menu.html

@@ -5,6 +5,18 @@
     <title>Title</title>
 </head>
 <body>
+<nav th:fragment="nav-top" class="navbar navbar-expand-md navbar-dark bg-dark sticky-top">
+    <div class="container-fluid">
+        <div class="navbar-brand">
+            <img th:src="@{/images/too-easy-trade.png}" class="img-fluid" style="max-width: 100px;">
+        </div>
+        <button sec:authorize="isAuthenticated()" class="navbar-toggler" type="button" data-bs-toggle="collapse"
+                data-bs-target="#mobileMenu">
+            <span class="navbar-toggler-icon"></span>
+        </button>
+    </div>
+</nav>
+
 <nav th:fragment="nav-mobileMenu" class="col-md-2 bg-dark sidebar collapse d-md-block" id="mobileMenu">
     <a th:href="@{/}">🏠 Início</a>
 

+ 32 - 0
src/main/resources/templates/fragments/scripts.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<div th:fragment="div-scripts">
+    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
+            integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
+            crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.6/dist/js/bootstrap.min.js"
+            integrity="sha384-RuyvpeZCxMJCqVUGFI0Do1mQrods/hhxYlcVfGPOfQtPJh0JCw12tUAZ/Mv10S7D"
+            crossorigin="anonymous"></script>
+    <script src="https://cdn.jsdelivr.net/npm/autonumeric@4.5.4/dist/autoNumeric.min.js"></script>
+    <script>
+        AutoNumeric.multiple('.autodecimal', {
+          digitGroupSeparator: '.',
+          decimalCharacter: ',',
+          decimalPlaces: 2,
+          unformatOnSubmit: true
+        });
+        AutoNumeric.multiple('.autonumeric', {
+          digitGroupSeparator: '.',
+          decimalCharacter: ',',
+          decimalPlaces: 0,
+          unformatOnSubmit: true
+        });
+    </script>
+</div>
+</body>
+</html>

+ 25 - 0
src/main/resources/templates/layout.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en"
+      xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
+    <meta charset="UTF-8">
+</head>
+<body class="d-flex flex-column min-vh-100">
+
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
+
+<div class="flex-grow-1 container-fluid">
+    <div class="row h-100">
+        <nav th:replace="~{fragments/menu :: nav-mobileMenu}"></nav>
+        <main class="col-md-10 ms-sm-auto col-12 content-area">
+            <div th:insert="~{::content}"></div>
+        </main>
+    </div>
+</div>
+
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+
+<div th:replace="~{fragments/scripts :: div-scripts}"></div>
+
+</body>
+</html>

+ 5 - 4
src/main/resources/templates/login.html

@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html lang="pt-br" xmlns:th="http://www.thymeleaf.org">
-<head th:insert="~{fragments/layout :: head}">
+<head th:insert="~{layout :: head}">
     <meta charset="UTF-8">
 </head>
 <body class="bg-light">
 
-<nav th:insert="~{fragments/layout :: nav-top}"></nav>
+<nav th:replace="~{fragments/menu :: nav-top}"></nav>
 
 <div class="container d-flex justify-content-center align-items-center" style="height: 100vh;">
     <form class="p-5 shadow bg-white rounded w-100" style="max-width: 400px;" method="post" th:action="@{/login}">
@@ -22,7 +22,8 @@
     </form>
 </div>
 
-<footer th:insert="~{fragments/layout :: footer}"></footer>
-<div th:insert="~{fragments/layout :: script}"></div>
+<footer th:replace="~{fragments/footer :: footer}"></footer>
+<div th:replace="~{fragments/scripts :: div-scripts}"></div>
+
 </body>
 </html>

+ 64 - 62
src/main/resources/templates/users/form.html

@@ -1,73 +1,75 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <form>
-            <div class="mb-3">
-                <input hidden="true" name="id" th:value="${compra.id}" type="text">
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <form>
+                    <div class="mb-3">
+                        <input hidden="true" name="id" th:value="${compra.id}" type="text">
 
-                <label class="form-label" for="fornecedor">Fornecedor</label>
-                <input class="form-control" id="fornecedor" name="fornecedor" th:value="${compra.fornecedor}"
-                       type="text">
-            </div>
+                        <label class="form-label" for="fornecedor">Fornecedor</label>
+                        <input class="form-control" id="fornecedor" name="fornecedor" th:value="${compra.fornecedor}"
+                               type="text">
+                    </div>
 
-            <br/>
-            <div class="mb-3">
-                <table class="table">
-                    <thead>
-                    <tr>
-                        <th>Código</th>
-                        <th>Item</th>
-                        <th>Valor</th>
-                        <th></th>
-                    </tr>
-                    </thead>
-                    <tbody>
-                    <tr th:each="item, stat : ${compra.itens}">
-                        <td>
-                            <input th:value="${item.id}" th:name="|itens[${stat.index}].id|" type="text" hidden="true">
-                            <input th:value="${item.id}" class="form-control" type="text" disabled>
-                        </td>
-                        <td>
-                            <input th:value="${item.descricao}" class="form-control"
-                                   th:name="|itens[${stat.index}].descricao|" type="text" required>
-                        </td>
-                        <td><input th:value="${item.valor}" class="form-control" th:name="|itens[${stat.index}].valor|"
-                                   type="text" required></td>
-                        <td>
-                            <button class="btn btn-outline-dark" formmethod="post"
-                                    th:formaction="@{'/compra/' + ${stat.index}}"
-                                    type="submit">
-                                <i class="bi bi-dash-square"></i>
-                            </button>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td><input class="form-control" type="text" disabled></td>
-                        <td><input class="form-control" th:name="descricao" type="text"></td>
-                        <td><input class="form-control" th:name="valor" type="text"></td>
-                        <td>
-                            <button class="btn btn-outline-dark" formmethod="post" th:formaction="@{/compra}"
-                                    type="submit">
-                                <i class="bi bi-plus-square"></i>
-                            </button>
-                    </tr>
-                    </tbody>
-                </table>
-            </div>
+                    <br/>
+                    <div class="mb-3">
+                        <table class="table">
+                            <thead>
+                            <tr>
+                                <th>Código</th>
+                                <th>Item</th>
+                                <th>Valor</th>
+                                <th></th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            <tr th:each="item, stat : ${compra.itens}">
+                                <td>
+                                    <input th:value="${item.id}" th:name="|itens[${stat.index}].id|" type="text" hidden="true">
+                                    <input th:value="${item.id}" class="form-control" type="text" disabled>
+                                </td>
+                                <td>
+                                    <input th:value="${item.descricao}" class="form-control"
+                                           th:name="|itens[${stat.index}].descricao|" type="text" required>
+                                </td>
+                                <td><input th:value="${item.valor}" class="form-control" th:name="|itens[${stat.index}].valor|"
+                                           type="text" required></td>
+                                <td>
+                                    <button class="btn btn-outline-dark" formmethod="post"
+                                            th:formaction="@{'/compra/' + ${stat.index}}"
+                                            type="submit">
+                                        <i class="bi bi-dash-square"></i>
+                                    </button>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td><input class="form-control" type="text" disabled></td>
+                                <td><input class="form-control" th:name="descricao" type="text"></td>
+                                <td><input class="form-control" th:name="valor" type="text"></td>
+                                <td>
+                                    <button class="btn btn-outline-dark" formmethod="post" th:formaction="@{/compra}"
+                                            type="submit">
+                                        <i class="bi bi-plus-square"></i>
+                                    </button>
+                            </tr>
+                            </tbody>
+                        </table>
+                    </div>
 
-            <button class="btn btn-dark" formmethod="post" th:formaction="@{/compra/salvar}" type="submit">Salvar
-            </button>
-        </form>
+                    <button class="btn btn-dark" formmethod="post" th:formaction="@{/compra/salvar}" type="submit">Salvar
+                    </button>
+                </form>
+            </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>

+ 39 - 37
src/main/resources/templates/users/list.html

@@ -1,45 +1,47 @@
 <!DOCTYPE html>
-<html lang="en" xmlns:th="http://www.thymeleaf.org"
-      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
-      layout:decorate="~{fragments/layout}">
-<head>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head th:replace="~{fragments/head :: head}">
     <meta charset="UTF-8">
     <title>Too Easy</title>
 </head>
 <body>
-<section layout:fragment="main-content">
-    <div class="container p-4 shadow bg-white rounded">
-        <h1 class="mb-4" th:text="${titulo}"></h1>
-        <table class="table table-hover">
-            <thead>
-            <tr>
-                <th>Código</th>
-                <th>Nome</th>
-                <th>Previlégio</th>
-                <th>Ações</th>
-            </tr>
-            </thead>
-            <tbody>
-            <tr th:each="user : ${users}">
-                <td th:text="${user.id}"></td>
-                <td th:text="${user.nome}"></td>
-                <td th:text="${user.role}">
-                    sel
-                </td>
-                <td>
-                    <a th:href="@{'/user/editar/' + ${user.id}}" type="button" class="btn btn-outline-dark"
-                       title="Editar">
-                        <i class="bi bi-pencil-square"></i>
-                    </a>
-                    <a th:href="@{'/user/remover/' + ${user.id}}" type="button" class="btn btn-outline-dark"
-                       title="Remover">
-                        <i class="bi bi-dash-square"></i>
-                    </a>
-                </td>
-            </tr>
-            </tbody>
-        </table>
+<div th:replace="~{layout}">
+    <div th:fragment="content">
+        <section>
+            <div class="container p-4 shadow bg-white rounded">
+                <h1 class="mb-4" th:text="${titulo}"></h1>
+                <table class="table table-hover">
+                    <thead>
+                    <tr>
+                        <th>Código</th>
+                        <th>Nome</th>
+                        <th>Previlégio</th>
+                        <th>Ações</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="user : ${users}">
+                        <td th:text="${user.id}"></td>
+                        <td th:text="${user.nome}"></td>
+                        <td th:text="${user.role}">
+                            sel
+                        </td>
+                        <td>
+                            <a th:href="@{'/user/editar/' + ${user.id}}" type="button" class="btn btn-outline-dark"
+                               title="Editar">
+                                <i class="bi bi-pencil-square"></i>
+                            </a>
+                            <a th:href="@{'/user/remover/' + ${user.id}}" type="button" class="btn btn-outline-dark"
+                               title="Remover">
+                                <i class="bi bi-dash-square"></i>
+                            </a>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </section>
     </div>
-</section>
+</div>
 </body>
 </html>