Browse Source

Proyecto Tienda

master
Ivan 1 year ago
parent
commit
d4b6eab809
62 changed files with 13729 additions and 317 deletions
  1. +97
    -7
      pom.xml
  2. +0
    -3
      src/main/java/com/ims/rallyModels/RallyModelsApplication.java
  3. +25
    -0
      src/main/java/com/ims/rallyModels/controlador/FilesController.java
  4. +52
    -0
      src/main/java/com/ims/rallyModels/controlador/LoginControlador.java
  5. +222
    -22
      src/main/java/com/ims/rallyModels/controlador/MaquetaControlador.java
  6. +72
    -0
      src/main/java/com/ims/rallyModels/controlador/RegistroControlador.java
  7. +32
    -0
      src/main/java/com/ims/rallyModels/controlador/UploadController.java
  8. +0
    -20
      src/main/java/com/ims/rallyModels/controlador/UsuarioControlador.java
  9. +61
    -0
      src/main/java/com/ims/rallyModels/dtu/UsuarioRegistroDTU.java
  10. +5
    -0
      src/main/java/com/ims/rallyModels/modelo/CocheEntity.java
  11. +35
    -0
      src/main/java/com/ims/rallyModels/modelo/CompraEntity.java
  12. +84
    -12
      src/main/java/com/ims/rallyModels/modelo/MaquetaEntity.java
  13. +97
    -0
      src/main/java/com/ims/rallyModels/modelo/UserModel.java
  14. +36
    -6
      src/main/java/com/ims/rallyModels/modelo/UsuarioEntity.java
  15. +104
    -0
      src/main/java/com/ims/rallyModels/reportes/FacturaExporterExcel.java
  16. +87
    -0
      src/main/java/com/ims/rallyModels/reportes/FacturaExporterPDF.java
  17. +9
    -0
      src/main/java/com/ims/rallyModels/repositorio/ICocheRepositorio.java
  18. +9
    -0
      src/main/java/com/ims/rallyModels/repositorio/ICompeticionRepositorio.java
  19. +4
    -3
      src/main/java/com/ims/rallyModels/repositorio/ICompraRepositorio.java
  20. +9
    -1
      src/main/java/com/ims/rallyModels/repositorio/IMaquetasRepositorio.java
  21. +12
    -0
      src/main/java/com/ims/rallyModels/repositorio/IUserRepository.java
  22. +55
    -0
      src/main/java/com/ims/rallyModels/security/SecurityConfig.java
  23. +0
    -11
      src/main/java/com/ims/rallyModels/servicio/IUsuarioServicio.java
  24. +58
    -0
      src/main/java/com/ims/rallyModels/servicio/UserDetailsImpl.java
  25. +41
    -10
      src/main/java/com/ims/rallyModels/servicio/UsuarioServicioImpl.java
  26. +42
    -0
      src/main/java/com/ims/rallyModels/servicio/coche/CocheServicioImpl.java
  27. +20
    -0
      src/main/java/com/ims/rallyModels/servicio/coche/ICocheServicio.java
  28. +40
    -0
      src/main/java/com/ims/rallyModels/servicio/competicion/CompeticionServicioImpl.java
  29. +19
    -0
      src/main/java/com/ims/rallyModels/servicio/competicion/ICompeticionService.java
  30. +71
    -0
      src/main/java/com/ims/rallyModels/servicio/compra/CompraServicioImpl.java
  31. +30
    -0
      src/main/java/com/ims/rallyModels/servicio/compra/ICompraServicio.java
  32. +168
    -0
      src/main/java/com/ims/rallyModels/servicio/img/FileSystemStorageService.java
  33. +20
    -0
      src/main/java/com/ims/rallyModels/servicio/img/StorageProperties.java
  34. +27
    -0
      src/main/java/com/ims/rallyModels/servicio/img/StorageService.java
  35. +6
    -3
      src/main/java/com/ims/rallyModels/servicio/maqueta/IMaquetasServicio.java
  36. +13
    -1
      src/main/java/com/ims/rallyModels/servicio/maqueta/MaquetasServicioImpl.java
  37. +11
    -0
      src/main/java/com/ims/rallyModels/servicio/userMng/IUsuarioServicio.java
  38. +24
    -0
      src/main/java/com/ims/rallyModels/servicio/userMng/UserServImpl.java
  39. +6
    -2
      src/main/resources/application.properties
  40. +43
    -0
      src/main/resources/static/css/shoppingCart.css
  41. +11233
    -74
      src/main/resources/static/css/styles.css
  42. BIN
      src/main/resources/static/raw/HyundaiI20.jpg
  43. BIN
      src/main/resources/static/raw/ToyotaYarisWRC.jpg
  44. BIN
      src/main/resources/static/raw/circLogo.png
  45. BIN
      src/main/resources/static/raw/fordPuma.jpg
  46. BIN
      src/main/resources/static/raw/logo.png
  47. +0
    -56
      src/main/resources/templates/crear_maqueta.html
  48. +31
    -7
      src/main/resources/templates/index.html
  49. +95
    -0
      src/main/resources/templates/login.html
  50. +0
    -76
      src/main/resources/templates/maqueta.html
  51. +57
    -0
      src/main/resources/templates/public/carrito.html
  52. +89
    -0
      src/main/resources/templates/public/crear_maqueta.html
  53. +3
    -3
      src/main/resources/templates/public/editar_maqueta.html
  54. +79
    -0
      src/main/resources/templates/public/factura.html
  55. +7
    -0
      src/main/resources/templates/public/js/scripts.js
  56. +125
    -0
      src/main/resources/templates/public/maqueta.html
  57. +47
    -0
      src/main/resources/templates/public/maqueta_detalle.html
  58. +25
    -0
      src/main/resources/templates/public/register.html
  59. +72
    -0
      src/main/resources/templates/public/usuarios.html
  60. BIN
      src/main/resources/templates/raw/images.jfif
  61. +111
    -0
      src/main/resources/templates/register.html
  62. +9
    -0
      src/main/resources/templates/utils/nav.html

+ 97
- 7
pom.xml View File

@ -17,7 +17,16 @@
<java.version>17</java.version> <java.version>17</java.version>
</properties> </properties>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>3.0.0</version>
</dependency>
<!--https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client-->
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
@ -31,22 +40,37 @@
<version>6.0.0.Final</version> <version>6.0.0.Final</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
<!-- Temporary explicit version to fix Thymeleaf bug -->
<version>3.1.1.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> </dependency>
<!---->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@ -60,11 +84,77 @@
<artifactId>mysql-connector-j</artifactId> <artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.librepdf/openpdf -->
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>1.3.26</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity5
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>-->
<!--
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>6.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>-->
<!---->
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>-->
<!--
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency>
</dependency>-->
</dependencies> </dependencies>
<build> <build>


+ 0
- 3
src/main/java/com/ims/rallyModels/RallyModelsApplication.java View File

@ -14,9 +14,6 @@ public class RallyModelsApplication implements CommandLineRunner {
SpringApplication.run(RallyModelsApplication.class, args); SpringApplication.run(RallyModelsApplication.class, args);
} }
@Autowired
private IMaquetasRepositorio repositorio;
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
/* /*


+ 25
- 0
src/main/java/com/ims/rallyModels/controlador/FilesController.java View File

@ -0,0 +1,25 @@
package com.ims.rallyModels.controlador;
import com.ims.rallyModels.servicio.img.StorageService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class FilesController {
@Autowired
StorageService storageService;
@GetMapping("/files/{filename:.+}")
@ResponseBody
public ResponseEntity<Resource> serveFile(@PathVariable String filename) {
Resource file = (Resource) storageService.loadAsResource(filename);
return ResponseEntity.ok().body(file);
}
}

+ 52
- 0
src/main/java/com/ims/rallyModels/controlador/LoginControlador.java View File

@ -0,0 +1,52 @@
package com.ims.rallyModels.controlador;
import com.ims.rallyModels.modelo.UsuarioEntity;
import com.ims.rallyModels.repositorio.IUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class LoginControlador {
@Autowired
private IUserRepository iUserRepository;
@GetMapping({"/login"})
public String goToLogin(Model model){
return "login";
}
/*
@Autowired
private IUsuarioRepositorio iUserRepository;
@GetMapping({"/login"})
public String goToLogin(Model model){
return "login";
}
*/
/*
@Autowired
private IUsuarioRepositorio iUsuarioRepositorio;
@GetMapping({"/login"})
public String goToLogin(Model model) {
return "login";
}
@GetMapping({"/"})
public String verPaginaInicio(Model model) {
return "index";
}
@GetMapping("/login/valid")
public String loginValidation(String username) {
UsuarioEntity user = iUsuarioRepositorio.findByName(username);
return "login";
}
*/
}

+ 222
- 22
src/main/java/com/ims/rallyModels/controlador/MaquetaControlador.java View File

@ -1,34 +1,220 @@
package com.ims.rallyModels.controlador; package com.ims.rallyModels.controlador;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity; import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.servicio.IMaquetasServicio;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.reportes.FacturaExporterExcel;
import com.ims.rallyModels.reportes.FacturaExporterPDF;
import com.ims.rallyModels.servicio.coche.ICocheServicio;
import com.ims.rallyModels.servicio.competicion.ICompeticionService;
import com.ims.rallyModels.servicio.compra.ICompraServicio;
import com.ims.rallyModels.servicio.img.StorageService;
import com.ims.rallyModels.servicio.maqueta.IMaquetasServicio;
import com.ims.rallyModels.servicio.userMng.IUsuarioServicio;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Controller @Controller
@RequestMapping("/public")
public class MaquetaControlador { public class MaquetaControlador {
/*
@GetMapping({"/","maquetas"})
public String index(){
return "public/maqueta";
}
/*
HTTP GET /users returns all the users in the system. HTTP GET /users returns all the users in the system.
HTTP GET /users/{id} returns a user by specified id. HTTP GET /users/{id} returns a user by specified id.
HTTP POST /users creates a new user in the system. HTTP POST /users creates a new user in the system.
@ para path @ para path
$ para objetos $ para objetos
? para mensajes
~ para href/frg
*/ */
@Autowired
private IMaquetasServicio maquetasServicio;
@Autowired
private ICocheServicio cocheServicio;
@Autowired
private ICompeticionService competicionService;
@Autowired
private IUsuarioServicio usuarioServicio;
@Autowired
private ICompraServicio compraServicio;
@Autowired @Autowired
private IMaquetasServicio servicio;
private StorageService storageService;
@Autowired
private HttpSession session;
private UserModel usuario;
private List<MaquetaEntity> maquetas;
/*
@GetMapping({"/index","/","/maquetas",""})//url path
public String listarMaquetas(Model model) {
return "index";//html path
}*/
@ModelAttribute("carrito")
public List<MaquetaEntity> productosCarrito() {
List<Integer> contenido = (List<Integer>) session.getAttribute("carrito");
return (contenido == null) ? null : maquetasServicio.variosPorId(contenido);
}
@ModelAttribute("total_carrito")
public Double totalCarrito() {
List<MaquetaEntity> productosCarrito = productosCarrito();
if (productosCarrito != null) {
return productosCarrito.stream()
.mapToDouble(p -> p.getPrecio())
.sum();
}
return 0.0;
}
@GetMapping("/carrito")
public String verCarrito(Model model) {
return "public/carrito";
}
@GetMapping("/carrito/add/{id}")
public String addCarrito(Model model, @PathVariable Integer id) {
List<Integer> contenido = (List<Integer>) session.getAttribute("carrito");
if (contenido == null)
contenido = new ArrayList<>();
if (!contenido.contains(id))
contenido.add(id);
session.setAttribute("carrito",contenido);
return "redirect:/public/carrito";
}
@GetMapping({"/maquetas",""})//url path
@GetMapping("/carrito/eliminar/{id}")
public String borrarDelCarrito(Model model, @PathVariable Integer id) {
List<Integer> contenido = (List<Integer>) session.getAttribute("carrito");
if (contenido == null)
return "redirect:/maquetas";
contenido.remove(id);
if (contenido.isEmpty())
session.removeAttribute("carrito");
else
session.setAttribute("carrito",contenido);
return "redirect:/public/carrito";
}
@GetMapping("/carrito/finalizar")
public String finalizarCompra() {
List<Integer> contenido = (List<Integer>) session.getAttribute("carrito");
if (contenido == null)
return "redirect:/maquetas";
List<MaquetaEntity> productos = productosCarrito();
CompraEntity c = compraServicio.insertar(new CompraEntity(),usuario);
productos.forEach(p -> compraServicio.addMaquetaCompra(p,c));
session.removeAttribute("carrito");
return "redirect:/public/compra/factura/"+c.getIdCompra();
}
@GetMapping("/miscompras")
public String verMisCompras(Model model) {
return "/compra/listado";
}
@GetMapping("/compra/factura/{id}")
public String factura(Model model, @PathVariable Integer id, HttpServletResponse response) throws IOException {
/*response.setContentType("application/pdf");
DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
String fechaActual = dateFormatter.format(new Date());
String cabecera = "Content-Disposition";
String valor = "attachment; filename=Compra_"+fechaActual+".pdf";
response.setHeader(cabecera,valor);*/
CompraEntity c = compraServicio.obtenerCompraPorId(id);
List<MaquetaEntity> productos = maquetasServicio.productosDeUnaCompra(c);
maquetas = productos;
//FacturaExporterPDF exporter = new FacturaExporterPDF(productos);
//exporter.exportar(response);
model.addAttribute("productos",productos);
model.addAttribute("compra",c);
model.addAttribute("total_compra", productos.stream()
.mapToDouble(p -> p.getPrecio())
.sum());
return "public/factura";
}
@GetMapping("/exportarPDF/{id}")
public void exportarCompraPDF(HttpServletResponse response, @PathVariable Integer id) throws IOException {
response.setContentType("application/pdf");
DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
String fechaActual = dateFormatter.format(new Date());
String cabecera = "Content-Disposition";
String valor = "attachment; filename=Compra_"+fechaActual+".pdf";
response.setHeader(cabecera,valor);
CompraEntity compra = compraServicio.obtenerCompraPorId(id);
FacturaExporterPDF exporter = new FacturaExporterPDF(maquetas);
exporter.exportar(response);
}
@GetMapping("/exportarExcel/{id}")
public void exportarCompraExcel(HttpServletResponse response, @PathVariable Integer id) throws IOException {
response.setContentType("application/octet-stream");
DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
String fechaActual = dateFormatter.format(new Date());
String cabecera = "Content-Disposition";
String valor = "attachment; filename=Compra_"+fechaActual+".xlsx";
response.setHeader(cabecera,valor);
CompraEntity compra = compraServicio.obtenerCompraPorId(id);
FacturaExporterExcel exporter = new FacturaExporterExcel(maquetas);
exporter.exportar(response);
}
/* @GetMapping("/maquetas/{id}")
public String mostrarMaqueta(Model model, @PathVariable Integer id) {
MaquetaEntity producto = maquetasServicio.obtenerMaquetaPorId(id);
if (producto != null) {
model.addAttribute("producto",producto);
return "/public/maqueta_detalle";//redirect si falla. Pd: se tendrá que cambiar
}
return "redirect:/public/maquetas";
}*/
@GetMapping({"/models","/","/maquetas",""})//url path
public String listarMaquetas(Model model) { public String listarMaquetas(Model model) {
model.addAttribute("maquetas",servicio.listAll());
return "maqueta";//html path
model.addAttribute("maquetas", maquetasServicio.listAll());
return "public/maqueta";//html path
} }
@GetMapping({"/maquetas/nuevo"}) @GetMapping({"/maquetas/nuevo"})
@ -36,39 +222,53 @@ public class MaquetaControlador {
//maqueta que le pasaremos al formulario //maqueta que le pasaremos al formulario
MaquetaEntity maqueta = new MaquetaEntity(); MaquetaEntity maqueta = new MaquetaEntity();
model.addAttribute("maqueta",maqueta); model.addAttribute("maqueta",maqueta);
return "crear_maqueta";
return "public/crear_maqueta";
} }
@PostMapping("/maquetas") @PostMapping("/maquetas")
public String guardarMaqueta(@ModelAttribute("maqueta")MaquetaEntity maqueta) {
public String guardarMaqueta(@ModelAttribute("maqueta")MaquetaEntity maqueta/*, @RequestParam("file")MultipartFile file*/) {
/*if (!file.isEmpty()) {
String imagen = storageService.store(file);
maqueta.setImage(MvcUriComponentsBuilder
.fromMethodName(FilesController.class,"serveFile",imagen).build().toUriString());
}*/
//recibimos el objeto que creamos para el formulario //recibimos el objeto que creamos para el formulario
//agregamos métodos útiles a la Interfaz de servicio //agregamos métodos útiles a la Interfaz de servicio
servicio.guardarMaqueta(maqueta);
return "redirect:/maquetas";//volvemos a la página inicial
maquetasServicio.guardarMaqueta(maqueta);
return "redirect:/public/maquetas";//volvemos a la página inicial
}
@GetMapping("/maquetas/mostrar/{id}")
public String mostrarMaqueta(@PathVariable Integer id, Model modelo) {
modelo.addAttribute("maqueta", maquetasServicio.obtenerMaquetaPorId(id));
return "/public/maqueta_detalle";
} }
@GetMapping("/maquetas/editar/{id}") @GetMapping("/maquetas/editar/{id}")
public String mostrarFormularioEditar(@PathVariable Integer id, Model modelo) { public String mostrarFormularioEditar(@PathVariable Integer id, Model modelo) {
modelo.addAttribute("maqueta",servicio.obtenerMaquetaPorId(id));
return "editar_maqueta";
modelo.addAttribute("maqueta", maquetasServicio.obtenerMaquetaPorId(id));
return "public/editar_maqueta";
} }
@PostMapping("/maquetas/{id}") @PostMapping("/maquetas/{id}")
public String actualizarMaqueta(@PathVariable Integer id, public String actualizarMaqueta(@PathVariable Integer id,
@ModelAttribute("maqueta") MaquetaEntity maqueta, @ModelAttribute("maqueta") MaquetaEntity maqueta,
Model modelo) { Model modelo) {
MaquetaEntity maquetaExistente = servicio.obtenerMaquetaPorId(id);
MaquetaEntity maquetaExistente = maquetasServicio.obtenerMaquetaPorId(id);
maquetaExistente.setIdMaqueta(maqueta.getIdMaqueta()); maquetaExistente.setIdMaqueta(maqueta.getIdMaqueta());
//System.out.println(maquetaExistente.getIdMaqueta()); == 4
maquetaExistente.setDescripcion(maqueta.getDescripcion()); maquetaExistente.setDescripcion(maqueta.getDescripcion());
servicio.actualizarMaqueta(maquetaExistente);
maquetasServicio.actualizarMaqueta(maquetaExistente);
return "redirect:/maquetas";
return "redirect:/public/maquetas";
} }
@GetMapping("/maquetas/{id}")
@GetMapping("/maquetas/eliminar/{id}")
public String eliminarMaqueta(@PathVariable Integer id) { public String eliminarMaqueta(@PathVariable Integer id) {
servicio.eliminarMaquetas(id);
return "redirect:/maquetas";
maquetasServicio.eliminarMaquetas(id);
return "redirect:/public/maquetas";
} }
} }

+ 72
- 0
src/main/java/com/ims/rallyModels/controlador/RegistroControlador.java View File

@ -0,0 +1,72 @@
package com.ims.rallyModels.controlador;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.repositorio.IUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@Controller
public class RegistroControlador {
@Autowired
private IUserRepository iUserRepository;
@GetMapping({"/register"})
public String goToregister(Model model){
model.addAttribute("user", new UserModel());
return "register";
}
@PostMapping("/process_register")
public String processRegister(UserModel user) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(user.getPassword());
user.setPassword(encodedPassword);
iUserRepository.save(user);
return "login";
}
/*@Autowired
private IUsuarioRepositorio iUsuarioRepositorio;
//@GetMapping
//public String mostrarFormularioRegistro() {
//return "login";
//}
/*
@PostMapping
public String registrarCuentaDeUsuario(@ModelAttribute("usuario") UsuarioRegistroDTU usuario) {
usuarioServicio.guardar(usuario);
//si logramos registrar correctamente se mandará el
//mensaje de éxito al html del registro (l.35)
return "redirect:/register?exito";
}
@GetMapping("security/user")
public String getUser( Model model) {
CustomUserDetails currentUser = (CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UsuarioEntity user = iUsuarioRepositorio.findByNombre(currentUser.getUsername());
model.addAttribute("user", user);
return "security/user";
}
@GetMapping({"/register"})
public String goToregister(Model model){
model.addAttribute("user", new UsuarioEntity());
return "register";
}
@PostMapping("/process_register")
public String processRegister(UsuarioEntity user) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String encodedPassword = passwordEncoder.encode(user.getContrasena());
user.setContrasena(encodedPassword);
iUsuarioRepositorio.save(user);
return "index";
}*/
}

+ 32
- 0
src/main/java/com/ims/rallyModels/controlador/UploadController.java View File

@ -0,0 +1,32 @@
package com.ims.rallyModels.controlador;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Controller
public class UploadController {
public static String UPLOAD_DIRECTORY = System.getProperty("user.dir") + "/uploads";
@GetMapping("/uploadimage") public String displayUploadForm() {
return "redirect:/public/maquetas";
}
@PostMapping("/upload") public String uploadImage(Model model, @RequestParam("image") MultipartFile file) throws IOException {
StringBuilder fileNames = new StringBuilder();
Path fileNameAndPath = Paths.get(UPLOAD_DIRECTORY, file.getOriginalFilename());
fileNames.append(file.getName());
Files.write(fileNameAndPath, file.getBytes());
model.addAttribute("msg", "Uploaded images: " + fileNames.toString());
return "redirect:/public/maquetas";
}
}

+ 0
- 20
src/main/java/com/ims/rallyModels/controlador/UsuarioControlador.java View File

@ -1,20 +0,0 @@
package com.ims.rallyModels.controlador;
import com.ims.rallyModels.servicio.IMaquetasServicio;
import com.ims.rallyModels.servicio.IUsuarioServicio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
public class UsuarioControlador {
@Autowired
private IUsuarioServicio servicio;
@GetMapping({"/usuarios",""})
public String listarMaquetas(Model model) {
model.addAttribute("usuarios",servicio.listAll());
return "usuarios";
}
}

+ 61
- 0
src/main/java/com/ims/rallyModels/dtu/UsuarioRegistroDTU.java View File

@ -0,0 +1,61 @@
package com.ims.rallyModels.dtu;
public class UsuarioRegistroDTU {
private int idUsuario;
private String nombre;
private String password;
private String sudo;
public UsuarioRegistroDTU(int idUsuario, String nombre, String password, String sudo) {
this.idUsuario = idUsuario;
this.nombre = nombre;
this.password = password;
this.sudo = sudo;
}
public UsuarioRegistroDTU(String nombre, String password, String sudo) {
this.nombre = nombre;
this.password = password;
this.sudo = sudo;
}
public UsuarioRegistroDTU(String nombre) {
this.nombre = nombre;
}
public UsuarioRegistroDTU() {
}
public int getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(int idUsuario) {
this.idUsuario = idUsuario;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getContrasena() {
return password;
}
public void setContrasena(String contrasena) {
this.password = contrasena;
}
public String getSudo() {
return sudo;
}
public void setSudo(String sudo) {
this.sudo = sudo;
}
}

+ 5
- 0
src/main/java/com/ims/rallyModels/modelo/CocheEntity.java View File

@ -19,6 +19,8 @@ public class CocheEntity {
@Column(name = "piloto", nullable = true, length = 45) @Column(name = "piloto", nullable = true, length = 45)
private String piloto; private String piloto;
private String image;
public int getIdCoche() { public int getIdCoche() {
return idCoche; return idCoche;
} }
@ -51,6 +53,9 @@ public class CocheEntity {
this.piloto = piloto; this.piloto = piloto;
} }
public String getImage() {
return image;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;


+ 35
- 0
src/main/java/com/ims/rallyModels/modelo/CompraEntity.java View File

@ -1,10 +1,16 @@
package com.ims.rallyModels.modelo; package com.ims.rallyModels.modelo;
import com.ims.rallyModels.servicio.UserDetailsImpl;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Date; import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
@Entity @Entity
@EntityListeners(AuditingEntityListener.class)//para la auto fecha
@Table(name = "compra", schema = "proyecto", catalog = "") @Table(name = "compra", schema = "proyecto", catalog = "")
public class CompraEntity { public class CompraEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -24,10 +30,39 @@ public class CompraEntity {
@Column(name = "fk_idMetodos_Pago", nullable = false) @Column(name = "fk_idMetodos_Pago", nullable = false)
private int fkIdMetodosPago; private int fkIdMetodosPago;
@OneToMany
private List<MaquetaEntity> productos;
@ManyToOne
private UserModel usuario;
@ManyToOne
private MetodosPagoEntity metodoPago;
public List<MaquetaEntity> getProductos() {
return productos;
}
public MetodosPagoEntity getMetodoPago() {
return metodoPago;
}
public CompraEntity() {
productos = new ArrayList<>();
usuario = new UserDetailsImpl(usuario).getUser();
}
public UserModel getUsuario() {
return usuario;
}
public int getIdCompra() { public int getIdCompra() {
return idCompra; return idCompra;
} }
public void setUsuario(UserModel usuario) {
this.usuario = usuario;
}
public void setIdCompra(int idCompra) { public void setIdCompra(int idCompra) {
this.idCompra = idCompra; this.idCompra = idCompra;
} }


+ 84
- 12
src/main/java/com/ims/rallyModels/modelo/MaquetaEntity.java View File

@ -12,20 +12,74 @@ public class MaquetaEntity {
@Basic @Basic
@Column(name = "descripcion", nullable = true, length = 45) @Column(name = "descripcion", nullable = true, length = 45)
private String descripcion; private String descripcion;
@Basic
@Column(name = "precio", nullable = true, precision = 0)
private Double precio;
private String marca;
private String modelo;
private String piloto;
private String image;
@ManyToOne
private CompraEntity compra;
@Basic @Basic
@Column(name = "fk_idCompeticion", nullable = false) @Column(name = "fk_idCompeticion", nullable = false)
private int fkIdCompeticion; private int fkIdCompeticion;
@Basic
@Column(name = "fk_idCoche", nullable = false)
private int fkIdCoche;
@Basic
@Column(name = "precio", nullable = true, precision = 0)
private Double precio;
@ManyToOne
private CompeticionEntity competicion;
public MaquetaEntity() { public MaquetaEntity() {
} }
public MaquetaEntity(String descripcion, Double precio) {
this.descripcion = descripcion;
this.precio = precio;
}
public MaquetaEntity(String descripcion, CompraEntity compra, Double precio) {
this.descripcion = descripcion;
this.compra = compra;
this.precio = precio;
}
public String getMarca() {
return marca;
}
public void setMarca(String marca) {
this.marca = marca;
}
public String getModelo() {
return modelo;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public String getPiloto() {
return piloto;
}
public void setPiloto(String piloto) {
this.piloto = piloto;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public void setCompeticion(CompeticionEntity competicion) {
this.competicion = competicion;
}
public int getIdMaqueta() { public int getIdMaqueta() {
return idMaqueta; return idMaqueta;
} }
@ -58,12 +112,32 @@ public class MaquetaEntity {
this.fkIdCompeticion = fkIdCompeticion; this.fkIdCompeticion = fkIdCompeticion;
} }
public int getFkIdCoche() {
return fkIdCoche;
public CompeticionEntity getCompeticion() {
return competicion;
} }
public void setFkIdCoche(int fkIdCoche) {
this.fkIdCoche = fkIdCoche;
public CompraEntity getCompra() {
return compra;
}
public void setCompra(CompraEntity compra) {
this.compra = compra;
}
@Override
public String toString() {
return "MaquetaEntity{" +
"idMaqueta=" + idMaqueta +
", descripcion='" + descripcion + '\'' +
", marca='" + marca + '\'' +
", modelo='" + modelo + '\'' +
", piloto='" + piloto + '\'' +
", image='" + image + '\'' +
", compra=" + compra +
", fkIdCompeticion=" + fkIdCompeticion +
", precio=" + precio +
", competicion=" + competicion +
'}';
} }
@Override @Override
@ -75,7 +149,6 @@ public class MaquetaEntity {
if (idMaqueta != that.idMaqueta) return false; if (idMaqueta != that.idMaqueta) return false;
if (fkIdCompeticion != that.fkIdCompeticion) return false; if (fkIdCompeticion != that.fkIdCompeticion) return false;
if (fkIdCoche != that.fkIdCoche) return false;
if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false; if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false;
if (precio != null ? !precio.equals(that.precio) : that.precio != null) return false; if (precio != null ? !precio.equals(that.precio) : that.precio != null) return false;
@ -88,7 +161,6 @@ public class MaquetaEntity {
result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0); result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0);
result = 31 * result + (precio != null ? precio.hashCode() : 0); result = 31 * result + (precio != null ? precio.hashCode() : 0);
result = 31 * result + fkIdCompeticion; result = 31 * result + fkIdCompeticion;
result = 31 * result + fkIdCoche;
return result; return result;
} }
} }

+ 97
- 0
src/main/java/com/ims/rallyModels/modelo/UserModel.java View File

@ -0,0 +1,97 @@
package com.ims.rallyModels.modelo;
import jakarta.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.util.Date;
import java.util.Objects;
@Entity
@EntityListeners(AuditingEntityListener.class)
public class UserModel {
@Id
@GeneratedValue
private long id;
private String email;
private String password;
private String name;
private String surname;
@CreatedDate
@Temporal(TemporalType.TIMESTAMP)
private Date createdDate;
public UserModel() { }
public UserModel(String name, String surname, String email, String password) {
this.name = name;
this.surname = surname;
this.email = email;
this.password = password;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
public Date getCreatedDate() {
return createdDate;
}
public String getEmail() {
return email;
}
public String getPassword() {
return password;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
UserModel user = (UserModel) o;
return id == user.id && email.equals(user.email);
}
@Override
public int hashCode() {
return Objects.hash(id, email);
}
public void setPassword(String password) {
this.password = password;
}
public void setId(long id) {
this.id = id;
}
public void setEmail(String email) {
this.email = email;
}
public void setName(String name) {
this.name = name;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}

+ 36
- 6
src/main/java/com/ims/rallyModels/modelo/UsuarioEntity.java View File

@ -1,8 +1,10 @@
package com.ims.rallyModels.modelo; package com.ims.rallyModels.modelo;
import jakarta.persistence.*; import jakarta.persistence.*;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@Entity @Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "usuario", schema = "proyecto", catalog = "") @Table(name = "usuario", schema = "proyecto", catalog = "")
public class UsuarioEntity { public class UsuarioEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@ -13,8 +15,30 @@ public class UsuarioEntity {
@Column(name = "nombre", nullable = true, length = 45) @Column(name = "nombre", nullable = true, length = 45)
private String nombre; private String nombre;
@Basic @Basic
@Column(name = "contrasena", nullable = true, length = 45)
private String contrasena;
@Column(name = "password", nullable = true, length = 150)
private String password;
@Basic
@Column(name = "sudo", nullable = true, length = 45)
private String sudo;
public UsuarioEntity(int idUsuario, String nombre, String password) {
this.idUsuario = idUsuario;
this.nombre = nombre;
this.password = password;
this.sudo = "USER";
}
public UsuarioEntity(String nombre, String password) {
this.nombre = nombre;
this.password = password;
this.sudo = "USER";
}
public UsuarioEntity() {
super();//anyways
}
public int getIdUsuario() { public int getIdUsuario() {
return idUsuario; return idUsuario;
@ -33,11 +57,17 @@ public class UsuarioEntity {
} }
public String getContrasena() { public String getContrasena() {
return contrasena;
return password;
} }
public void setContrasena(String contrasena) { public void setContrasena(String contrasena) {
this.contrasena = contrasena;
this.password = contrasena;
}
public String getSudo() {
return sudo;
}
public void setSudo(String sudo) {
this.sudo = sudo;
} }
@Override @Override
@ -49,7 +79,7 @@ public class UsuarioEntity {
if (idUsuario != that.idUsuario) return false; if (idUsuario != that.idUsuario) return false;
if (nombre != null ? !nombre.equals(that.nombre) : that.nombre != null) return false; if (nombre != null ? !nombre.equals(that.nombre) : that.nombre != null) return false;
if (contrasena != null ? !contrasena.equals(that.contrasena) : that.contrasena != null) return false;
if (password != null ? !password.equals(that.password) : that.password != null) return false;
return true; return true;
} }
@ -58,7 +88,7 @@ public class UsuarioEntity {
public int hashCode() { public int hashCode() {
int result = idUsuario; int result = idUsuario;
result = 31 * result + (nombre != null ? nombre.hashCode() : 0); result = 31 * result + (nombre != null ? nombre.hashCode() : 0);
result = 31 * result + (contrasena != null ? contrasena.hashCode() : 0);
result = 31 * result + (password != null ? password.hashCode() : 0);
return result; return result;
} }
} }

+ 104
- 0
src/main/java/com/ims/rallyModels/reportes/FacturaExporterExcel.java View File

@ -0,0 +1,104 @@
package com.ims.rallyModels.reportes;
import com.ims.rallyModels.modelo.MaquetaEntity;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class FacturaExporterExcel {
private XSSFWorkbook libro;
private XSSFSheet hoja;
private List<MaquetaEntity> maquetas;
public FacturaExporterExcel(List<MaquetaEntity> maquetas) {
this.maquetas = maquetas;
libro = new XSSFWorkbook();
hoja = libro.createSheet("Maquetas");
}
private void escribirCabeceraTabla() {
Row fila = hoja.createRow(0);
CellStyle estilo = libro.createCellStyle();
XSSFFont fuente = libro.createFont();
fuente.setBold(true);
fuente.setFontHeight(16);
estilo.setFont(fuente);
Cell celda = fila.createCell(0);
celda.setCellValue("Id");
celda.setCellStyle(estilo);
celda = fila.createCell(1);
celda.setCellValue("Coche");
celda.setCellStyle(estilo);
celda = fila.createCell(2);
celda.setCellValue("Piloto");
celda.setCellStyle(estilo);
celda = fila.createCell(3);
celda.setCellValue("Precio");
celda.setCellStyle(estilo);
}
public void escribirDatosDeTabla() {
int numeroFilas = 1;
CellStyle estilo = libro.createCellStyle();
XSSFFont fuente = libro.createFont();
fuente.setFontHeight(14);
estilo.setFont(fuente);
for (MaquetaEntity m : maquetas) {
Row fila = hoja.createRow(numeroFilas++);
Cell celda = fila.createCell(0);
celda.setCellValue(m.getIdMaqueta());
hoja.autoSizeColumn(0);
celda.setCellStyle(estilo);
celda = fila.createCell(1);
celda.setCellValue(m.getMarca()+" "+m.getModelo());
hoja.autoSizeColumn(1);
celda.setCellStyle(estilo);
celda = fila.createCell(2);
celda.setCellValue(m.getPiloto());
hoja.autoSizeColumn(2);
celda.setCellStyle(estilo);
celda = fila.createCell(3);
celda.setCellValue(m.getPrecio());
hoja.autoSizeColumn(3);
celda.setCellStyle(estilo);
}
}
public void exportar(HttpServletResponse response) throws IOException {
escribirCabeceraTabla();
escribirDatosDeTabla();
ServletOutputStream outputStream = response.getOutputStream();
libro.write(outputStream);
libro.close();
outputStream.close();
}
}

+ 87
- 0
src/main/java/com/ims/rallyModels/reportes/FacturaExporterPDF.java View File

@ -0,0 +1,87 @@
package com.ims.rallyModels.reportes;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity;
import com.lowagie.text.*;
import com.lowagie.text.Font;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import jakarta.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.IOException;
import java.util.List;
public class FacturaExporterPDF {
private List<MaquetaEntity> compra;
public FacturaExporterPDF(List<MaquetaEntity> compra) {
super();
this.compra = compra;
}
private void escribirCabeceraDeLaTabla(PdfPTable tabla) {
PdfPCell cell = new PdfPCell();
cell.setBackgroundColor(Color.LIGHT_GRAY);
cell.setPadding(5);
Font fuente = FontFactory.getFont(FontFactory.HELVETICA);
fuente.setColor(Color.WHITE);
cell.setPhrase(new Phrase("Id",fuente));
tabla.addCell(cell);
cell.setPhrase(new Phrase("Coche",fuente));
tabla.addCell(cell);
cell.setPhrase(new Phrase("Piloto",fuente));
tabla.addCell(cell);
cell.setPhrase(new Phrase("Precio",fuente));
tabla.addCell(cell);
}
private void escribirDatosDeLaTable(PdfPTable table) {
for (MaquetaEntity m : compra) {
table.addCell(String.valueOf(m.getIdMaqueta()));
table.addCell(m.getMarca()+" "+m.getModelo());
table.addCell(m.getPiloto());
table.addCell(m.getPrecio().toString());
}
}
public void exportar(HttpServletResponse response) throws IOException {
Document documento = new Document(PageSize.A4);
PdfWriter.getInstance(documento,response.getOutputStream());
documento.open();
Font fuente = FontFactory.getFont(FontFactory.HELVETICA);
fuente.setColor(Color.RED);
fuente.setSize(18);
Paragraph titulo = new Paragraph("Factura de maquetas", fuente);
titulo.setAlignment(Paragraph.ALIGN_CENTER);
documento.add(titulo);
PdfPTable tabla = new PdfPTable(4);
tabla.setWidthPercentage(100);
tabla.setSpacingBefore(15);
tabla.setWidths(new float[] {1f,2.3f,2.3f,2.3f});
tabla.setWidthPercentage(110);
escribirCabeceraDeLaTabla(tabla);
escribirDatosDeLaTable(tabla);
documento.add(tabla);
documento.close();
}
}

+ 9
- 0
src/main/java/com/ims/rallyModels/repositorio/ICocheRepositorio.java View File

@ -0,0 +1,9 @@
package com.ims.rallyModels.repositorio;
import com.ims.rallyModels.modelo.CocheEntity;
import jdk.jfr.Registered;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ICocheRepositorio extends JpaRepository<CocheEntity,Integer> {}

+ 9
- 0
src/main/java/com/ims/rallyModels/repositorio/ICompeticionRepositorio.java View File

@ -0,0 +1,9 @@
package com.ims.rallyModels.repositorio;
import com.ims.rallyModels.modelo.CompeticionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ICompeticionRepositorio extends JpaRepository<CompeticionEntity, Integer> {
}

src/main/java/com/ims/rallyModels/repositorio/IUsuarioRepositorio.java → src/main/java/com/ims/rallyModels/repositorio/ICompraRepositorio.java View File

@ -1,10 +1,11 @@
package com.ims.rallyModels.repositorio; package com.ims.rallyModels.repositorio;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity; import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UsuarioEntity; import com.ims.rallyModels.modelo.UsuarioEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface IUsuarioRepositorio extends JpaRepository<UsuarioEntity, Integer> {
import java.util.List;
public interface ICompraRepositorio extends JpaRepository<CompraEntity,Integer> {
} }

+ 9
- 1
src/main/java/com/ims/rallyModels/repositorio/IMaquetasRepositorio.java View File

@ -1,8 +1,16 @@
package com.ims.rallyModels.repositorio; package com.ims.rallyModels.repositorio;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity; import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UserModel;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface IMaquetasRepositorio extends JpaRepository<MaquetaEntity, Integer> { }
public interface IMaquetasRepositorio extends JpaRepository<MaquetaEntity, Integer> {
List<MaquetaEntity> findByCompra(CompraEntity c);
}

+ 12
- 0
src/main/java/com/ims/rallyModels/repositorio/IUserRepository.java View File

@ -0,0 +1,12 @@
package com.ims.rallyModels.repositorio;
import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.modelo.UsuarioEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
public interface IUserRepository extends JpaRepository<UserModel, Integer> {
UserModel findByEmail(String email);
}

+ 55
- 0
src/main/java/com/ims/rallyModels/security/SecurityConfig.java View File

@ -0,0 +1,55 @@
package com.ims.rallyModels.security;
import com.ims.rallyModels.servicio.UsuarioServicioImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
public UsuarioServicioImpl userDetailsService(){
return new UsuarioServicioImpl();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService());
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests()
.requestMatchers("/user").authenticated()
.anyRequest().permitAll()
.and()
.formLogin()
.usernameParameter("email")
.loginPage("/login")
.defaultSuccessUrl("/public/maquetas")
.permitAll()
.and()
.logout().logoutSuccessUrl("/login").permitAll();
return http.build();
}
}

+ 0
- 11
src/main/java/com/ims/rallyModels/servicio/IUsuarioServicio.java View File

@ -1,11 +0,0 @@
package com.ims.rallyModels.servicio;
import com.ims.rallyModels.modelo.UsuarioEntity;
import java.util.List;
public interface IUsuarioServicio {
public List<UsuarioEntity> listAll();
}

+ 58
- 0
src/main/java/com/ims/rallyModels/servicio/UserDetailsImpl.java View File

@ -0,0 +1,58 @@
package com.ims.rallyModels.servicio;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.modelo.UsuarioEntity;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.List;
public class UserDetailsImpl implements UserDetails {
private UserModel user;
public UserDetailsImpl(UserModel user) {
this.user = user;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return null;
}
@Override
public String getPassword() {
return user.getPassword();
}
public UserModel getUser() {
return user;
}
@Override
public String getUsername() {
return user.getEmail();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
}

+ 41
- 10
src/main/java/com/ims/rallyModels/servicio/UsuarioServicioImpl.java View File

@ -1,20 +1,51 @@
package com.ims.rallyModels.servicio; package com.ims.rallyModels.servicio;
import com.ims.rallyModels.modelo.UsuarioEntity;
import com.ims.rallyModels.repositorio.IMaquetasRepositorio;
import com.ims.rallyModels.repositorio.IUsuarioRepositorio;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.repositorio.IUserRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import java.util.List;
public class UsuarioServicioImpl implements IUsuarioServicio{
import java.util.Collection;
import java.util.stream.Collectors;
@Service
public class UsuarioServicioImpl implements UserDetailsService {
//may cons
@Autowired @Autowired
private IUsuarioRepositorio repositorio;
private IUserRepository userRepo;
@Override @Override
public List<UsuarioEntity> listAll() {
return repositorio.findAll();
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserModel user = userRepo.findByEmail(username);
if (user == null) {
throw new UsernameNotFoundException("User not found");
}
return new UserDetailsImpl(user);
} }
/*@Override
public UsuarioEntity buscarPorNombre(String nombre) {
return repositorio.findByName(nombre);
}*/
/*
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UsuarioEntity usuario = repositorio.findByNombre(username);
if (usuario == null) {
throw new UsernameNotFoundException("Usuario o password inválidos");;
}
return new UsuarioEntity(usuario.getNombre(), usuario.getContrasena(), mapearAutoridadesRoles(usuario.getSudo()));
}*/
/*@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UsuarioEntity user = repositorio.findByNombre(username);
if (user == null) {
throw new UsernameNotFoundException("User not found");
}
return new UserDetailsImpl(user);
}*/
} }

+ 42
- 0
src/main/java/com/ims/rallyModels/servicio/coche/CocheServicioImpl.java View File

@ -0,0 +1,42 @@
package com.ims.rallyModels.servicio.coche;
import com.ims.rallyModels.modelo.CocheEntity;
import com.ims.rallyModels.repositorio.ICocheRepositorio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CocheServicioImpl implements ICocheServicio {
@Autowired
private ICocheRepositorio repositorio;
@Override
public List<CocheEntity> listAll() {
return repositorio.findAll();
}
@Override
public CocheEntity guardarCoche(CocheEntity maqueta) {
return repositorio.save(maqueta);
}
@Override
public CocheEntity obtenerCochePorId(Integer id) {
return repositorio.findById(id).get();
}
@Override
public CocheEntity actualizarCoche(CocheEntity maqueta) {
//primero se busca y luego se edita y guarda
return repositorio.save(maqueta);
}
@Override
public void eliminarCoches(Integer id) {
repositorio.deleteById(id);
}
}

+ 20
- 0
src/main/java/com/ims/rallyModels/servicio/coche/ICocheServicio.java View File

@ -0,0 +1,20 @@
package com.ims.rallyModels.servicio.coche;
import com.ims.rallyModels.modelo.CocheEntity;
import com.ims.rallyModels.modelo.MaquetaEntity;
import java.util.List;
public interface ICocheServicio {
public List<CocheEntity> listAll();
public CocheEntity guardarCoche(CocheEntity maqueta);
public CocheEntity obtenerCochePorId(Integer id);
public CocheEntity actualizarCoche(CocheEntity maqueta);
public void eliminarCoches(Integer id);
}

+ 40
- 0
src/main/java/com/ims/rallyModels/servicio/competicion/CompeticionServicioImpl.java View File

@ -0,0 +1,40 @@
package com.ims.rallyModels.servicio.competicion;
import com.ims.rallyModels.modelo.CompeticionEntity;
import com.ims.rallyModels.repositorio.ICompeticionRepositorio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CompeticionServicioImpl implements ICompeticionService {
@Autowired
private ICompeticionRepositorio repositorio;
@Override
public List<CompeticionEntity> listAll() {
return repositorio.findAll();
}
@Override
public CompeticionEntity guardarCompeticion(CompeticionEntity competicion) {
return repositorio.save(competicion);
}
@Override
public CompeticionEntity obtenerCompeticionPorId(Integer id) {
return repositorio.findById(id).get();
}
@Override
public CompeticionEntity actualizarCompeticion(CompeticionEntity competicion) {
return repositorio.save(competicion);
}
@Override
public void eliminarCompeticion(Integer id) {
repositorio.deleteById(id);
}
}

+ 19
- 0
src/main/java/com/ims/rallyModels/servicio/competicion/ICompeticionService.java View File

@ -0,0 +1,19 @@
package com.ims.rallyModels.servicio.competicion;
import com.ims.rallyModels.modelo.CompeticionEntity;
import java.util.List;
public interface ICompeticionService {
public List<CompeticionEntity> listAll();
public CompeticionEntity guardarCompeticion(CompeticionEntity competicion);
public CompeticionEntity obtenerCompeticionPorId(Integer id);
public CompeticionEntity actualizarCompeticion(CompeticionEntity competicion);
public void eliminarCompeticion(Integer id);
}

+ 71
- 0
src/main/java/com/ims/rallyModels/servicio/compra/CompraServicioImpl.java View File

@ -0,0 +1,71 @@
package com.ims.rallyModels.servicio.compra;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.modelo.UsuarioEntity;
import com.ims.rallyModels.repositorio.ICompraRepositorio;
import com.ims.rallyModels.servicio.maqueta.IMaquetasServicio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CompraServicioImpl implements ICompraServicio {
@Autowired
private ICompraRepositorio repositorio;
@Autowired
IMaquetasServicio maquetasServicio;
@Override
public List<CompraEntity> listAll() {
return repositorio.findAll();
}
@Override
public CompraEntity guardarCompra(CompraEntity compra) {
return repositorio.save(compra);
}
@Override
public CompraEntity insertar(CompraEntity c, UserModel u) {
c.setUsuario(u);
return repositorio.save(c);
}
@Override
public CompraEntity obtenerCompraPorId(Integer id) {
return repositorio.findById(id).get();
}
@Override
public CompraEntity actualizarCompra(CompraEntity compra) {
return repositorio.save(compra);
}
@Override
public void eliminarCompra(Integer id) {
repositorio.deleteById(id);
}
@Override
public List<CompraEntity> findByPropietario(UsuarioEntity propietario) {
return null;
}
@Override
public MaquetaEntity addMaquetaCompra(MaquetaEntity p, CompraEntity c) {
p.setCompra(c);
return maquetasServicio.actualizarMaqueta(p);
}
@Override
public void addMaquetaCompraTest(MaquetaEntity p, CompraEntity c) {
c.getProductos().add(p);
}
}

+ 30
- 0
src/main/java/com/ims/rallyModels/servicio/compra/ICompraServicio.java View File

@ -0,0 +1,30 @@
package com.ims.rallyModels.servicio.compra;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.modelo.UsuarioEntity;
import java.util.List;
public interface ICompraServicio {
public List<CompraEntity> listAll();
public CompraEntity guardarCompra(CompraEntity compra);
public CompraEntity insertar(CompraEntity c, UserModel u);
public CompraEntity obtenerCompraPorId(Integer id);
public CompraEntity actualizarCompra(CompraEntity compra);
public void eliminarCompra(Integer id);
public List<CompraEntity> findByPropietario(UsuarioEntity propietario);
public MaquetaEntity addMaquetaCompra(MaquetaEntity p, CompraEntity c);
public void addMaquetaCompraTest(MaquetaEntity p, CompraEntity c);
}

+ 168
- 0
src/main/java/com/ims/rallyModels/servicio/img/FileSystemStorageService.java View File

@ -0,0 +1,168 @@
package com.ims.rallyModels.servicio.img;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Service;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
/**
* Implementación de un {@link StorageService} que almacena
* los ficheros subidos dentro del servidor donde se ha desplegado
* la apliacación.
*
* ESTO SE REALIZA ASÍ PARA NO HACER MÁS COMPLEJO EL EJEMPLO.
* EN UNA APLICACIÓN EN PRODUCCIÓN POSIBLEMENTE SE UTILICE
* UN ALMACÉN REMOTO.
*
*
* @author Equipo de desarrollo de Spring
*
*/
@Service
public class FileSystemStorageService implements StorageService{
// Directorio raiz de nuestro almacén de ficheros
private final Path rootLocation;
@Autowired
public FileSystemStorageService(StorageProperties properties) {
this.rootLocation = Paths.get(properties.getLocation());
}
/**
* Método que almacena un fichero en el almacenamiento secundario
* desde un objeto de tipo {@link org.springframework.web.multipart#} MultipartFile
*
* Modificamos el original del ejemplo de Spring para cambiar el nombre
* del fichero a almacenar. Como lo asociamos al Empleado que se ha
* dado de alta, usaremos el ID de empleado como nombre de fichero.
*
*/
@Override
public String store(MultipartFile file) {
String filename = null;
try {
filename = StringUtils.cleanPath(file.getResource().getURL().toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
String extension = StringUtils.getFilenameExtension(filename);
String justFilename = filename.replace("."+extension, "");
String storedFilename = System.currentTimeMillis() + "_" + justFilename + "." + extension;
try {
try (InputStream inputStream = file.getInputStream()) {
Files.copy(inputStream, this.rootLocation.resolve(storedFilename),
StandardCopyOption.REPLACE_EXISTING);
return storedFilename;
} catch (IOException e) {
throw new RuntimeException(e);
}
} finally {
}
}
/**
* Método que devuelve la ruta de todos los ficheros que hay
* en el almacenamiento secundario del proyecto.
*/
@Override
public Stream<Path> loadAll() {
try {
return Files.walk(this.rootLocation, 1)
.filter(path -> !path.equals(this.rootLocation))
.map(this.rootLocation::relativize);
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
/**
* Método que es capaz de cargar un fichero a partir de su nombre
* Devuelve un objeto de tipo Path
*/
@Override
public Path load(String filename) {
return rootLocation.resolve(filename);
}
/**
* Método que es capaz de cargar un fichero a partir de su nombre
* Devuelve un objeto de tipo Resource
*/
@Override
public Resource loadAsResource(String filename) {
try {
Path file = load(filename);
Resource resource = new UrlResource(file.toUri());
if (resource.exists() || resource.isReadable()) {
return resource;
}
}
catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
/**
* Método que elimina todos los ficheros del almacenamiento
* secundario del proyecto.
*/
@Override
public void deleteAll() {
FileSystemUtils.deleteRecursively(rootLocation.toFile());
}
/**
* Método que inicializa el almacenamiento secundario del proyecto
*/
@Override
public void init() {
try {
Files.createDirectories(rootLocation);
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void delete(String filename) {
String justFilename = StringUtils.getFilename(filename);
try {
Path file = load(justFilename);
Files.deleteIfExists(file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

+ 20
- 0
src/main/java/com/ims/rallyModels/servicio/img/StorageProperties.java View File

@ -0,0 +1,20 @@
package com.ims.rallyModels.servicio.img;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;
@Service
public class StorageProperties {
private String location = "upload-dir";
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}

+ 27
- 0
src/main/java/com/ims/rallyModels/servicio/img/StorageService.java View File

@ -0,0 +1,27 @@
package com.ims.rallyModels.servicio.img;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.nio.file.Path;
import java.util.stream.Stream;
@Service
public interface StorageService {
void init();
String store(MultipartFile file);
Stream<Path> loadAll();
Path load(String filename);
Resource loadAsResource(String filename);
void delete(String filename);
void deleteAll();
}

src/main/java/com/ims/rallyModels/servicio/IMaquetasServicio.java → src/main/java/com/ims/rallyModels/servicio/maqueta/IMaquetasServicio.java View File

@ -1,7 +1,6 @@
package com.ims.rallyModels.servicio;
package com.ims.rallyModels.servicio.maqueta;
import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.modelo.UsuarioEntity;
import com.ims.rallyModels.modelo.*;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List; import java.util.List;
@ -18,4 +17,8 @@ public interface IMaquetasServicio {
public void eliminarMaquetas(Integer id); public void eliminarMaquetas(Integer id);
public List<MaquetaEntity> variosPorId(List<Integer> ids);
public List<MaquetaEntity> productosDeUnaCompra(CompraEntity c);
} }

src/main/java/com/ims/rallyModels/servicio/MaquetasServicioImpl.java → src/main/java/com/ims/rallyModels/servicio/maqueta/MaquetasServicioImpl.java View File

@ -1,5 +1,7 @@
package com.ims.rallyModels.servicio;
package com.ims.rallyModels.servicio.maqueta;
import com.ims.rallyModels.modelo.CocheEntity;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.MaquetaEntity; import com.ims.rallyModels.modelo.MaquetaEntity;
import com.ims.rallyModels.repositorio.IMaquetasRepositorio; import com.ims.rallyModels.repositorio.IMaquetasRepositorio;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,4 +41,14 @@ public class MaquetasServicioImpl implements IMaquetasServicio {
repositorio.deleteById(id); repositorio.deleteById(id);
} }
@Override
public List<MaquetaEntity> variosPorId(List<Integer> ids) {
return repositorio.findAllById(ids);
}
@Override
public List<MaquetaEntity> productosDeUnaCompra(CompraEntity c) {
return repositorio.findByCompra(c);
}
} }

+ 11
- 0
src/main/java/com/ims/rallyModels/servicio/userMng/IUsuarioServicio.java View File

@ -0,0 +1,11 @@
package com.ims.rallyModels.servicio.userMng;
import com.ims.rallyModels.modelo.CompraEntity;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.modelo.UsuarioEntity;
import java.util.List;
public interface IUsuarioServicio {
public UserModel findByNombre(String nombre);
}

+ 24
- 0
src/main/java/com/ims/rallyModels/servicio/userMng/UserServImpl.java View File

@ -0,0 +1,24 @@
package com.ims.rallyModels.servicio.userMng;
import com.ims.rallyModels.modelo.UserModel;
import com.ims.rallyModels.repositorio.IUserRepository;
import com.ims.rallyModels.servicio.userMng.IUsuarioServicio;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserServImpl implements IUsuarioServicio {
@Autowired
IUserRepository repositorio;
@Override
public UserModel findByNombre(String nombre) {
return null;
}
public UserModel findById(int id) {
return repositorio.findById(id).get();
}
}

+ 6
- 2
src/main/resources/application.properties View File

@ -3,10 +3,14 @@ spring.datasource.username=proyecto
spring.datasource.password=1234 spring.datasource.password=1234
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# none, validate, update, create-drop may be created # none, validate, update, create-drop may be created
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.ddl-auto=update
server.port=2614 server.port=2614
#spring.jpa.hibernate.ddl-auto=none #spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.format_sql=true
#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect
#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect
#Security
logging.level.org.sql=debug
logging.level.org.type=trace

+ 43
- 0
src/main/resources/static/css/shoppingCart.css View File

@ -0,0 +1,43 @@
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200&display=swap');
body {
font-family: 'Manrope', sans-serif;
background:#eee;
}
.size span {
font-size: 11px;
}
.color span {
font-size: 11px;
}
.product-deta {
margin-right: 70px;
}
.gift-card:focus {
box-shadow: none;
}
.pay-button {
color: #fff;
}
.pay-button:hover {
color: #fff;
}
.pay-button:focus {
color: #fff;
box-shadow: none;
}
.text-grey {
color: #a39f9f;
}
.qty i {
font-size: 11px;
}

+ 11233
- 74
src/main/resources/static/css/styles.css
File diff suppressed because it is too large
View File


BIN
src/main/resources/static/raw/HyundaiI20.jpg View File

Before After
Width: 166  |  Height: 111  |  Size: 5.4 KiB

BIN
src/main/resources/static/raw/ToyotaYarisWRC.jpg View File

Before After
Width: 290  |  Height: 174  |  Size: 9.4 KiB

BIN
src/main/resources/static/raw/circLogo.png View File

Before After
Width: 250  |  Height: 150  |  Size: 35 KiB

BIN
src/main/resources/static/raw/fordPuma.jpg View File

Before After
Width: 225  |  Height: 225  |  Size: 8.5 KiB

BIN
src/main/resources/static/raw/logo.png View File

Before After
Width: 500  |  Height: 500  |  Size: 118 KiB

+ 0
- 56
src/main/resources/templates/crear_maqueta.html View File

@ -1,56 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>
<br/>
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 container justify-content-center card">
<h1 class="text-center">Nueva Maqueta</h1>
<div class="card-body">
<form th:action="@{/maquetas}" th:object="${maqueta}" method="post">
<!-- la maqueta de th:object es la que le pasamos al controlador OJO LAS "s" -->
<div class="form-group">
<label>Descripcion: </label>
<input type="text" name="descripcion" th:field="*{descripcion}"
class="form-control" placeholder="Descripción de la maqueta: " required>
</div>
<br/>
<div class="form-group">
<label>Precio: </label>
<input type="number" name="precio" th:field="*{precio}"
class="form-control" placeholder="Precio de la maqueta: " required>
</div>
<br/>
<div class="box-footer">
<button class="btn btn-success">Guardar</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

+ 31
- 7
src/main/resources/templates/index.html View File

@ -1,13 +1,37 @@
<!DOCTYPE html> <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org" >
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<head> <!--th:replace="~{/fragments/head/head}">-->
</head> </head>
<body>
<header th:replace="~{utils/nav}"> <!--th:replace="~{/fragments/header/headerOne}"--></header>
<body class="topspace">
<div class="imgBoxs">
<a href="/login">login</a>
<br>
<a href="/register">register</a>
<div class="container">
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
<a type="button" class="btn btn-success" href="/login">Inicio de sesión</a>
<a type="button" class="btn btn-danger" href="/register">Registro</a>
</div>
</div>
<p>INDEX HTML!</p>
<h1>Lista de maquetas</h1>
<a href="maqueta.html">Añadir Maqueta</a>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
</body> </body>
<!--<footer th:replace="~{/fragments/footer/footerOne}" ></footer>-->
</html> </html>

+ 95
- 0
src/main/resources/templates/login.html View File

@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en" style="background: aqua">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<body style="height: 50%; width: 100%; background: aqua">
<div class="container">
<img src="../static/raw/circLogo.png" style="display: block;
margin-top: 5%;
margin-left: auto;
margin-right: auto;
width: 25%;" alt="logo">
</div>
<main style="height: 100%; width: 100%">
<!--
<article>
<section class="vh-100 gradient-custom">
<div class="container py-5 h-100">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-12 col-md-8 col-lg-6 col-xl-5">
<div class="card bg-dark text-white" style="border-radius: 1rem;">
<div class="card-body p-5 text-center">
<div class="mb-md-5 mt-md-4 pb-5">
<h2 class="fw-bold mb-2 text-uppercase">Inicio de sesión</h2>
<p class="text-white-50 mb-5">Introduce tu nombre y contraseña</p>
<div class="form-outline form-white mb-4">
<input type="email" id="typeEmailX" class="form-control form-control-lg" />
<label class="form-label" for="loginform">Nombre</label>
</div>
<div class="form-outline form-white mb-4">
<input type="password" id="typePasswordX" class="form-control form-control-lg" />
<label class="form-label" for="typePasswordX">Contraseña</label>
</div>
<button class="btn btn-outline-light btn-lg px-5" type="submit">Iniciar Sesión</button>
<div class="d-flex justify-content-center text-center mt-4 pt-1">
<a href="#" class="text-white"><i class="fab fa-facebook-f fa-lg"></i></a>
<a href="#" class="text-white"><i class="fab fa-twitter fa-lg mx-4 px-2"></i></a>
<a href="#" class="text-white"><i class="fab fa-google fa-lg"></i></a>
</div>
</div>
<div>
<p class="mb-0">Don't have an account? <a href="#!" class="text-white-50 fw-bold">Sign Up</a>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</article>
-->
<div class="container" style="margin-top: 5%; border-radius: 3%; height: 20%;
background: linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%);">
<form id="loginform" th:action="@{/login}" method="post" role="form">
<div class="form-group">
<h2 for="email" style="color: #f2f2f2">Nombre Usuario</h2>
<input type="text" name="email" id="email"
class="form-control" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted"></small>
</div>
<div class="form-group">
<h2 for="password" style="color: #f2f2f2">Contraseña</h2>
<input style="margin-bottom: 1%" type="password" name="password" class="form-control" id="password" placeholder="Password">
</div>
<small class="text-muted"><a href="/register">No estas registrado?</a></small>
<button type="submit" class="btn btn-primary" style="color: #f2f2f2">Submit</button>
</form>
</div>
<!--
<form id="loginform" th:action="@{/login}" method="POST" role="form" >
<h1>Login</h1>
<input type="text" name="email" id="email" placeholder="Email">
<br>
<input type="password" name="password" id="password" placeholder="Password">
<hr>
<button type="submit">Continue</button>
<small class="text-muted"><a href="/auth/register">Register here!</a></small>
</form>-->
</main>
</body>
</html>

+ 0
- 76
src/main/resources/templates/maqueta.html View File

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>
<div class="container">
<div class="row">
<h1>Lista Maquetas</h1>
</div>
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>Descripcion</th>
<th>Coche</th>
<th>Competicion</th>
<th>Precio</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tr th:each="maqueta : ${maquetas}">.
<td th:text="${maqueta.descripcion}">Descripcion</td>
<td th:text="${maqueta.fkIdCoche}">Coche</td>
<td th:text="${maqueta.fkIdCompeticion}">Competicion</td>
<td th:text="${maqueta.precio}">Precio</td>
<td>
<a th:href="@{/maquetas/editar/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-info">Editar</a>
<a th:href="@{/maquetas/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-danger">Eliminar</a>
</td>
</tr>
</tbody>
</table>
</div>
<div class="container">
<div class="card" style="width: 18rem;">
<img src="raw/images.jfif" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</body>
</html>

+ 57
- 0
src/main/resources/templates/public/carrito.html View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="/static/css/shoppingCart.css" rel="stylesheet" />
</head>
<header th:replace="~{utils/nav}"></header>
<body>
<div class="container mt-5 mb-5">
<div class="d-flex justify-content-center row">
<div class="col-md-8">
<div class="p-2">
<h4>Carrito de la Compra</h4>
</div>
<div th:if="${carrito == null}">
<div class="col-md-offset-1 col-md-10">
<div class="jumbotron">
<div class="container">
<h2 class="text-center">Aún no ha seleccionado ningún producto para comprar</h2>
</div>
</div>
</div>
</div>
<th:block th:each="producto : ${carrito}">
<div class="d-flex flex-row justify-content-between align-items-center p-2 bg-white mt-4 px-3 rounded">
<div class="mr-1"><img class="rounded" th:src="@{${producto.image}}" width="70" alt="Imagen de la maqueta" /></div>
<div class="d-flex flex-column align-items-center product-details"><span class="font-weight-bold" th:text="${producto.piloto}">Maqueta</span>
<div class="d-flex flex-row product-desc">
<div class="size mr-1"><span class="text-grey" th:text="${producto.marca+' '}">Marca del Coche:</span>
<span class="font-weight-bold"></span>
</div>
<div class="color"><span class="text-grey" th:text="${producto.modelo}">Modelo del Coche:</span>
<span class="font-weight-bold"></span>
</div>
</div>
</div>
<div>
<h5 class="text-grey" th:text="${producto.precio}">$20.00</h5>
</div>
<a type="button" class="btn btn-danger" th:href="@{/public/carrito/eliminar/{id}(id=${producto.idMaqueta})}">Eliminar</a>
<div class="d-flex align-items-center"><i class="fa fa-trash mb-1 text-danger"></i></div>
</div>
</th:block>
<h5>Precio Total: <a th:text="${#numbers.formatCurrency(total_carrito)}"></a></h5>
<div class="d-flex flex-row align-items-center mt-3 p-2 bg-white rounded">
<a th:href="@{/public/carrito/finalizar}" class="btn btn-warning btn-block btn-lg ml-2 pay-button" type="button">Procesar Compra</a>
</div>
</div>
</div>
</div>
</body>
</html>

+ 89
- 0
src/main/resources/templates/public/crear_maqueta.html View File

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/public/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>
<br/>
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 container justify-content-center card">
<h1 class="text-center">Nueva Maqueta</h1>
<div class="card-body">
<form th:action="@{/public/maquetas}" th:object="${maqueta}" method="post">
<!-- la maqueta de th:object es la que le pasamos al controlador OJO LAS "s" -->
<div class="form-group">
<label>Piloto: </label>
<input type="text" name="piloto" th:field="*{piloto}"
class="form-control" placeholder="Piloto: " required>
</div>
<div class="form-group">
<label>Marca: </label>
<input type="text" name="marca" th:field="*{marca}"
class="form-control" placeholder="Marca: " required>
</div>
<div class="form-group">
<label>Modelo del coche: </label>
<input type="text" name="modelo" th:field="*{modelo}"
class="form-control" placeholder="Modelo: " required>
</div>
<div class="form-group">
<label>Competicion: </label>
<input type="number" name="modelo" th:field="*{competicion}"
class="form-control" placeholder="Competicion: " required>
</div>
<div class="form-group">
<label>Precio: </label>
<input type="text" name="precio" th:field="*{precio}"
class="form-control" placeholder="Precio de la maqueta: " required>
</div>
<div class="form-group">
<label>Descripcion: </label>
<input type="text" name="descripcion" th:field="*{descripcion}"
class="form-control" placeholder="Descripción de la maqueta: " required>
</div>
<!--<div class="form-group">
<label>Imagen</label> <input id="filebutton" name="file" class="form-control input-file" type="file">
</div>
<div class="col-md-8 mx-auto">
<h2>Upload Image Example</h2>
<p th:text="${message}" th:if="${message ne null}" class="alert alert-primary"></p>
<form method="post" th:action="@{/upload}" enctype="multipart/form-data">
<div class="form-group">
<input type="file" name="image" accept="image/*" class="form-control-file">
</div>
<button type="submit" class="btn btn-primary">Upload image</button>
</form>
<span th:if="${msg != null}" th:text="${msg}"></span>
</div>
<br/>-->
<div class="box-footer">
<button class="btn btn-success">Guardar</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>

src/main/resources/templates/editar_maqueta.html → src/main/resources/templates/public/editar_maqueta.html View File

@ -13,7 +13,7 @@
<div class="collapse navbar-collapse" id="collapsibleNavbar"> <div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" <li class="nav-item"><a class="nav-link"
th:href="@{/maquetas}">Control de maquetas</a> </li>
th:href="@{/public/maquetas}">Control de maquetas</a> </li>
</ul> </ul>
</div> </div>
@ -27,8 +27,8 @@
<div class="col-lg-6 col-md-6 col-sm-6 container justify-content-center card"> <div class="col-lg-6 col-md-6 col-sm-6 container justify-content-center card">
<h1 class="text-center">Edición de maquetas</h1> <h1 class="text-center">Edición de maquetas</h1>
<div class="card-body"> <div class="card-body">
<form th:action="@{/maquetas/{id}(id=${maqueta.idMaqueta})}" th:object="${maqueta}" method="post">
<!-- la maqueta de th:object es la que le pasamos al controlador OJO LAS "s" -->
<form th:action="@{/public/maquetas/{id}(id=${maqueta.idMaqueta})}" th:object="${maqueta}" method="post">
<input type="hidden" th:field="*{idMaqueta}" th:value="${maqueta.idMaqueta}"/>
<div class="form-group"> <div class="form-group">
<label>Descripcion: </label> <label>Descripcion: </label>
<input type="text" name="descripcion" th:field="*{descripcion}" <input type="text" name="descripcion" th:field="*{descripcion}"

+ 79
- 0
src/main/resources/templates/public/factura.html View File

@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-offset-3 col-xs-6">
<div class="invoice-title">
<h2>Factura</h2>
<h3 class="pull-right">
Compra #<span th:text="${compra.idCompra}">1234</span>
</h3>
</div>
<hr>
<div class="row">
<!--<div class="col-xs-6">
<address>
<strong>Comprado por:</strong><br> <span
th:text="${compra.getUsuario().name + ' ' + compra.getUsuario().surname}"></span><br>
<span th:text="${compra.getUsuario().email}"></span><br>
</address>
</div>
<div class="col-xs-6 text-right">
<address>
<strong>Fecha de compra:</strong><br> <span
th:text="${#dates.format(compra.fecha,'dd/MMM/yyyy HH:mm')}"></span><br>
<br>
</address>
</div>-->
</div>
</div>
</div>
<div class="row">
<div class="col-md-offset-3 col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<strong>Listado de productos</strong>
</h3>
</div>
<div class="panel-body invoice-body">
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<td><strong>Producto</strong></td>
<td class="text-right"><strong>Precio</strong></td>
</tr>
</thead>
<tbody>
<tr th:each="producto : ${productos}">
<td><span th:text="${producto.marca+' '+producto.modelo}">Producto</span></td>
<td class="text-right"><span th:text="${#numbers.formatCurrency(producto.precio)}">123€</span></td>
</tr>
<tr>
<td class="thick-line text-right"><strong>Total</strong></td>
<td class="thick-line text-right"><span
th:text="${#numbers.formatCurrency(total_compra)}"></span></td>
</tr>
</tbody>
</table>
<div class="d-flex flex-row align-items-center mt-3 p-2 bg-white rounded">
<a th:href="@{/public/exportarExcel/{id}(id=${compra.getIdCompra()})}" class="btn btn-warning btn-block btn-lg ml-2 pay-button" type="button">Obtener Factura Excel</a>
</div>
<div class="d-flex flex-row align-items-center mt-3 p-2 bg-white rounded">
<a th:href="@{/public/exportarPDF/{id}(id=${compra.getIdCompra()})}" class="btn btn-warning btn-block btn-lg ml-2 pay-button" type="button">Obtener Factura PDF</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

+ 7
- 0
src/main/resources/templates/public/js/scripts.js View File

@ -0,0 +1,7 @@
/*!
* Start Bootstrap - Shop Item v5.0.5 (https://startbootstrap.com/template/shop-item)
* Copyright 2013-2022 Start Bootstrap
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-shop-item/blob/master/LICENSE)
*/
// This file is intentionally blank
// Use this file to add JavaScript to your project

+ 125
- 0
src/main/resources/templates/public/maqueta.html View File

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg bg-dark navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Rally Models</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" th:href="@{/public/maquetas}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Control de maquetas</a>
</li>
<li class="nav-item">
<a th:href="@{/logout}" method="POST" id="logoutForm">Cerrar Sesion</a>
</li>
</ul>
<a th:href="@{/public/maquetas/nuevo}"
class="btn btn-primary btn-sm mb3">Agregar Maqueta</a>
<a th:href="@{/public/carrito}"
class="btn btn-primary btn-sm mb3">Ver Carrito</a>
</div>
</div>
</nav>
<!--
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>
-->
<div class="container">
<div class="row">
<h1>Lista Maquetas</h1>
</div>
<div class="row">
<div class="col-lg-3">
<a th:href="@{/public/maquetas/nuevo}"
class="btn btn-primary btn-sm mb3">Agregar Maqueta</a>
</div>
</div>
<br />
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>Descripcion</th>
<th>Coche</th>
<th>Competicion</th>
<th>Precio</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tr th:each="maqueta : ${maquetas}">
<td th:text="${maqueta.getPiloto()}">Descripcion</td>
<td th:text="${maqueta.getMarca()+maqueta.getModelo()}">Coche</td>
<td th:text="${maqueta.getCompeticion().getNombre()}">Competicion</td>
<td th:text="${maqueta.getPrecio()}">Precio</td>
<td>
<a th:href="@{/public/maquetas/editar/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-info">Editar</a>
<a th:href="@{/public/maquetas/eliminar/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-danger">Eliminar</a>
</td>
</tr>
</tbody>
</table>
</div>
<th:block th:each="maqueta : ${maquetas}">
<div class="container">
<div class="row">
<div class="card" style="width: 18rem; margin: auto">
<img th:src="@{${maqueta.getImage()}}" class="card-img-top" alt="fordPuma">
<div class="card-body" style="">
<h5 class="card-title" th:text="${maqueta.getMarca()+maqueta.getModelo()}" />
<input type="hidden" name="selectedElementName" th:value="${maqueta.getCompeticion().getNombre()}" />
<p class="card-text" th:text="${maqueta.getPiloto()}" />
<p class="card-text" th:text="${maqueta.getPrecio()}" style="text-align: right"/>
<!--<button class="btn btn-primary form-control" type="submit">Enter</button>-->
</div>
<!--<ul th:each="maqueta : ${maquetas}">
<li th:text="${maqueta.getCoche().getPiloto()}">Piloto</li>
<li th:text="${maqueta.getCoche().getMarca()}">Marca</li>
<li th:text="${maqueta.getCoche().getModelo()}">Modelo</li>
</ul>
<h5 class="card-title" ></h5>
<h5 class="card-title" ></h5>
<h5 class="card-title"></h5>-->
<a th:href="@{/public/maquetas/mostrar/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-primary">Detalles</a>
<a th:href="@{/public/carrito/add/{id}(id=${maqueta.idMaqueta})}" class="btn btn-primary">Añadir al carrito</a>
</div>
</div>
</div>
</th:block>
</body>
</html>

+ 47
- 0
src/main/resources/templates/public/maqueta_detalle.html View File

@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Detalles de la maqueta</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" rel="stylesheet" />
<link href="/static/css/styles.css" rel="stylesheet" />
</head>
<header th:replace="~{utils/nav}"></header>
<body>
<section class="py-5">
<div class="container px-4 px-lg-5 my-5">
<div class="row gx-4 gx-lg-5 align-items-center">
<div class="col-md-6"><img class="card-img-top mb-5 mb-md-0" th:src="@{${maqueta.image}}" alt="Foto de la Maqueta" /></div>
<div class="col-md-6">
<div>
<div class="small mb-1" th:text="${maqueta.piloto}">Piloto</div>
<h1 class="display-5 fw-bolder" th:text="${maqueta.marca+' '+maqueta.modelo}">Maqueta</h1>
<div class="fs-5 mb-5">
<span th:text="${maqueta.precio}+'€'">$40.00</span>
</div>
<p class="lead" th:text="${maqueta.descripcion}">Descripcion</p>
<div class="d-flex">
<input class="form-control text-center me-3" id="inputQuantity" type="num" value="1" style="max-width: 3rem" />
<button th:href="@{/public/carrito/add/{id}(id=${maqueta.idMaqueta})}" class="btn btn-outline-dark flex-shrink-0" type="button"><!-- OJO -->
<i class="bi-cart-fill me-1"></i>
Añadir al carrito
</button>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Footer-->
<footer class="py-5 bg-dark">
<div class="container"><p class="m-0 text-center text-white">Copyright &copy; Rally Models Corp. 2023</p></div>
</footer>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>

+ 25
- 0
src/main/resources/templates/public/register.html View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en"
xmlns:th="http://www.w3.org/1999/xhtml"
xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Register</title>
</head>
<body>
<main>
<!--<form id="registerform" th:action="@{/process_register}" th:object="${user}" method="POST" role="form" >
<h1>Register</h1>
<input type="text" th:field="*{email}" placeholder="Email">
<br>
<input type="text" th:field="*{name}" placeholder="Username">
<br>
<input type="text" th:field="*{surname}" placeholder="Surname">
<br>
<input type="password" th:field="*{password}" placeholder="Password">
<hr>
<button type="submit">Continue</button>
</form>-->
</main>
</body>
</html>

+ 72
- 0
src/main/resources/templates/public/usuarios.html View File

@ -0,0 +1,72 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>RallyModels</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>
<div class="container">
<div class="row">
<h1>Lista Maquetas</h1>
</div>
<div class="row">
<div class="col-lg-3">
<a th:href="@{/maquetas/nuevo}"
class="btn btn-primary btn-sm mb3">Agregar Maqueta</a>
</div>
</div>
<br />
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
<th>Descripcion</th>
<th>Coche</th>
<th>Competicion</th>
<th>Precio</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tr th:each="maqueta : ${maquetas}">.
<td th:text="${maqueta.descripcion}">Descripcion</td>
<td th:text="${maqueta.fkIdCoche}">Coche</td>
<td th:text="${maqueta.fkIdCompeticion}">Competicion</td>
<td th:text="${maqueta.precio}">Precio</td>
<td>
<a th:href="@{/maquetas/editar/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-info">Editar</a>
<a th:href="@{/maquetas/{id}(id=${maqueta.idMaqueta})}"
class="btn btn-danger">Eliminar</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

BIN
src/main/resources/templates/raw/images.jfif View File

Before After
Width: 225  |  Height: 225  |  Size: 8.0 KiB

+ 111
- 0
src/main/resources/templates/register.html View File

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>Registro de usuarios</title>
<!-- Latest compiled and minified CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
</head>
<header th:replace="~{/utils/nav}"></header>
<body>
<div class="container" style="margin-top: 5%; height: 20%;
background: linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%);">
<form id="loginform" th:action="@{/process_register}" th:object="${user}" method="post" role="form">
<h1>Registro</h1>
<div class="form-group">
<h2 for="email" style="color: #f2f2f2">Email</h2>
<input type="email" th:field="*{email}" placeholder="Email">
<small id="emailHelp" class="form-text text-muted"></small>
</div>
<div class="form-group">
<h2 for="name" style="color: #f2f2f2">Nombre</h2>
<input type="text" th:field="*{name}" placeholder="Name">
<small id="name" class="form-text text-muted"></small>
</div>
<div class="form-group">
<h2 for="surname" style="color: #f2f2f2">Apellido</h2>
<input type="text" th:field="*{surname}" placeholder="Surname">
<small id="surname" class="form-text text-muted"></small>
</div>
<div class="form-group">
<h2 for="password" style="color: #f2f2f2">Contraseña</h2>
<input style="margin-bottom: 1%" type="password" th:field="*{password}" placeholder="Password">
</div>
<small class="text-muted"><a href="/register">No estas registrado?</a></small>
<button type="submit" class="btn btn-primary" style="color: #f2f2f2">Submit</button>
</form>
</div>
<!--
<main>
<form id="registerform" th:action="@{/process_register}" th:object="${user}" method="POST" role="form" >
<h1>Register</h1>
<input type="text" th:field="*{email}" placeholder="Username">
<br>
<input type="password" th:field="*{password}" placeholder="Password">
<hr>
<button type="submit">Continue</button>
</form>
</main>
-->
</body>
</html>
<!--
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div th:if="${param.exito}">
<div class="alert alert-info">Se ha registrado exitosamente a
la aplicación
</div>
</div>
<h1>Regístrate</h1>
<form th:action="@{/registro}" method="post" th:object="${usuario}">
<form th:action="@{/process_register}" method="post" th:object="${user}" role=""form>
<div class="form-group">
<label class="control-label" for="nombre">Nombre : </label> <input
id="nombre" type="text" class="form-control" th:field="*{nombre}"
required autofocus="autofocus">
</div>
<div class="form-group">
<label class="control-label" for="password">Password : </label> <input
type="password" id="password" class="form-control" th:field="*{contrasena}"
required autofocus="autofocus">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success">Registrar</button>
<span>Si estas registrado <a th:href="@{/login}">inicia sesión aqui</a></span>
</div>
</form>
</div>
</div>
</div>-->
<!-- Latest compiled and minified JavaScript -->
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
</body>
</html>

+ 9
- 0
src/main/resources/templates/utils/nav.html View File

@ -0,0 +1,9 @@
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="#">Control de Maquetas</a>
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link"
th:href="@{/public/maquetas}">Control de maquetas</a> </li>
</ul>
</div>
</nav>

Loading…
Cancel
Save