corrige controler en provincia y cliente

main
Freddy Heredia 2 years ago
parent fe74130562
commit 27d461fc36

@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.PutMapping;
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/cliente")
@ -69,7 +71,9 @@ public class ClienteController {
try {
Field campoEntidad = Cliente.class.getDeclaredField(fieldName);
campoEntidad.setAccessible(true);
campoEntidad.set(entity, fieldValue);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
campoEntidad.set(entity, mapper.convertValue(fieldValue, campoEntidad.getType()));
} catch (NoSuchFieldException | IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo
}

@ -15,6 +15,8 @@ import org.springframework.web.bind.annotation.PutMapping;
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/provincia")
@ -65,7 +67,9 @@ public class ProvinciaController {
try {
Field campoEntidad = Provincia.class.getDeclaredField(fieldName);
campoEntidad.setAccessible(true);
campoEntidad.set(entity, fieldValue);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
campoEntidad.set(entity, mapper.convertValue(fieldValue, campoEntidad.getType()));
} catch (NoSuchFieldException | IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo
}

Loading…
Cancel
Save