2 Commits

Author SHA1 Message Date
  Juanjo b05e023a62 CRUD inicio 1 year ago
  Juanjo 7f83d0d34e CRUD inicio 1 year ago
8 changed files with 128 additions and 26 deletions
Unified View
  1. +18
    -9
      src/main/java/es/fp/edu/conecta2/controladores/WebControlador.java
  2. +1
    -0
      src/main/resources/application.properties
  3. +1
    -1
      src/main/resources/data.sql
  4. +9
    -0
      src/main/resources/static/css/footer.css
  5. +5
    -3
      src/main/resources/templates/foot/javascript.html
  6. +0
    -10
      src/main/resources/templates/head/head.html
  7. +59
    -0
      src/main/resources/templates/menu/m1.html
  8. +35
    -3
      src/main/resources/templates/usuarios.html

+ 18
- 9
src/main/java/es/fp/edu/conecta2/controladores/WebControlador.java View File

@ -14,12 +14,28 @@ import org.springframework.web.bind.annotation.RequestMapping;
@Controller @Controller
public class WebControlador { public class WebControlador {
@Autowired
private UserService servicioUser;
@GetMapping ("/") @GetMapping ("/")
public String inicio() {
public String listarUser(Model modelo){
modelo.addAttribute("user",servicioUser.listarUser());
return "usuarios";
}
@GetMapping ("/nuevo")
public String nuevoUser(Model modelo){
modelo.addAttribute("user",servicioUser.listarUser());
return "usuarios";
}
return "inicio";
@GetMapping ("/borrar")
public String borrarUser(Model modelo){
modelo.addAttribute("user",servicioUser.listarUser());
return "usuarios";
} }
@RequestMapping("parametros/{a}/{b}/{c}") @RequestMapping("parametros/{a}/{b}/{c}")
public String parametros( @PathVariable int a, public String parametros( @PathVariable int a,
@PathVariable int b, @PathVariable int b,
@ -54,12 +70,5 @@ public class WebControlador {
return "opcionales"; return "opcionales";
} }
@Autowired
private UserService servicioUser;
@GetMapping ("/user")
public String listarUser(Model modelo){
modelo.addAttribute("user",servicioUser.listarUser());
return "usuarios";
}
} }

+ 1
- 0
src/main/resources/application.properties View File

@ -16,6 +16,7 @@ persistente.jpa.show-sql=true
persistente.jpa.hibernate.ddl-auto=update persistente.jpa.hibernate.ddl-auto=update
persistente.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect persistente.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
#persistente.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl #persistente.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
#persistente.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy #persistente.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy


+ 1
- 1
src/main/resources/data.sql View File

@ -1 +1 @@
insert into bolsa.tbl_user values (1,"Juan"), (2,"Perico"), (3,"Andrés");
insert into bolsa.tbl_user values (10,"Juan"), (11,"Perico"), (12,"Andrés");

+ 9
- 0
src/main/resources/static/css/footer.css View File

@ -0,0 +1,9 @@
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
.container {
width: auto;
max-width: 680px;
padding: 0 15px;
}

+ 5
- 3
src/main/resources/templates/foot/javascript.html View File

@ -1,6 +1,8 @@
<div th:fragment="javascript">
Pie de página
<footer th:fragment="javascript" class="footer navbar-fixed-bottom mt-auto py-3 bg-light">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
<script src="webjars/jsquery/jquery.min.js"></script> <script src="webjars/jsquery/jquery.min.js"></script>
<script src="webjars/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="webjars/bootstrap/js/bootstrap.bundle.min.js"></script>
</footer>
</div>

+ 0
- 10
src/main/resources/templates/head/head.html View File

@ -7,13 +7,3 @@
<link href="/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/webjars/font-awesome/css/all.css" rel="stylesheet"> <link href="/webjars/font-awesome/css/all.css" rel="stylesheet">
</head> </head>
<head th:fragment="otrohead">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title th:text="${titulo}">Título de la página</title>
<meta name="description" content="">
<link href="/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/webjars/font-awesome/css/all.css" rel="stylesheet">
</head>

+ 59
- 0
src/main/resources/templates/menu/m1.html View File

@ -0,0 +1,59 @@
<!DOCTYPE html>
<html lang="es"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
<meta charset="UTF-8">
</head>
<body>
<nav th:fragment="usuarios" class="navbar navbar-expand-lg bg-light navbar-light" style="--bs-bg-opacity: .8;">
<div class="container-fluid">
<a class="navbar-brand" href="#"><i class="fa-solid fa-skull-crossbones fa-fade"></i>CRUD Usuario</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="user">Listado</a>
</li>
<li class="nav-item">
<a class="nav-link" href="buscar">Buscar</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
CRUD
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Crear</a></li>
<li><a class="dropdown-item" href="#">Actualiazar</a></li>
<li><a class="dropdown-item" href="#">Borrar</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
Formularios
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/formulario">Formulario básico</a></li>
<li><a class="dropdown-item" href="/formulario-avanzado">Formulario avanzado</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Registros del formulario</a></li>
<li><a class="dropdown-item" href="#">Envío por email</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
</body>
</html>

+ 35
- 3
src/main/resources/templates/usuarios.html View File

@ -2,11 +2,43 @@
<html lang="es" <html lang="es"
xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"> xmlns:th="http://www.thymeleaf.org">
<head th:replace="head/head :: mihead"></head>
<head th:replace="~{head/head :: mihead}"></head>
<body class="d-flex flex-column h-100">
<header th:replace="menu/m1 :: usuarios"></header>
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">Listado de usuarios.</h1>
<p class="col-md-8 fs-4">Ejemplo de CRUD</p>
<a class="btn btn-lg btn-primary" href="https://2dam.fp.edu.es/gitea/conecta2">Código fuente</a>
</div>
</div>
<main>
<div class="container">
<table class="table table-sm">
<thead>
<tr>
<th scope="col">#idUsuario</th>
<th scope="col">nombres</th>
<th scope="col">Operaciones</th>
</thead>
<tbody>
<tr th:each="usuario :${user} ">
<th scope="row" th:text="${usuario.idUsuario}">1</th>
<td th:text="${usuario.nombres}">Mark</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</main>
<body>
Listado de usuarios.
<footer th:replace="foot/javascript :: javascript"></footer> <footer th:replace="foot/javascript :: javascript"></footer>
</body> </body>
</html> </html>

Loading…
Cancel
Save