From fe74130562fd3046b34001a78bed55bc59504da5 Mon Sep 17 00:00:00 2001 From: freddyheredia4 Date: Thu, 29 Jun 2023 18:56:14 -0500 Subject: [PATCH] Corrige mapeo de tipo de dato --- src/main/java/erp/pedidos/producto/ProductoController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/erp/pedidos/producto/ProductoController.java b/src/main/java/erp/pedidos/producto/ProductoController.java index c50814b..f581e97 100644 --- a/src/main/java/erp/pedidos/producto/ProductoController.java +++ b/src/main/java/erp/pedidos/producto/ProductoController.java @@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + @RestController @RequestMapping("/api/producto") @CrossOrigin({"*"}) @@ -65,7 +68,9 @@ public class ProductoController { try { Field campoEntidad = Producto.class.getDeclaredField(fieldName); campoEntidad.setAccessible(true); - campoEntidad.set(producto, fieldValue); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new JavaTimeModule()); + campoEntidad.set(producto, mapper.convertValue(fieldValue, campoEntidad.getType())); } catch (NoSuchFieldException | IllegalAccessException ex) { // maneja la excepción si ocurre algún error al acceder al campo }