faltan que no se reseteen los acabados de la cubierta

This commit is contained in:
Jaime Jiménez
2025-09-01 14:50:42 +02:00
parent ea1c485c80
commit 3d9444c3d6
7 changed files with 284 additions and 49 deletions

View File

@ -13,6 +13,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -88,6 +89,7 @@ public class PresupuestoController {
@PostMapping("/public/validar/cubierta")
public ResponseEntity<?> validarCubierta(
@Validated(PresupuestoValidationGroups.Cubierta.class) Presupuesto presupuesto,
@RequestParam(name = "calcular", defaultValue = "true") boolean calcular,
BindingResult result, Locale locale) {
Map<String, String> errores = new HashMap<>();
@ -102,20 +104,25 @@ public class PresupuestoController {
return ResponseEntity.badRequest().body(errores);
}
HashMap<String, Object> price = new HashMap<>();
String priceStr = apiClient.getPrice(presupuestoService.toSkApiRequest(presupuesto));
if (calcular) {
try {
price = new ObjectMapper().readValue(priceStr, new TypeReference<>() {
});
} catch (JsonProcessingException e) {
price = new HashMap<>();
price.put("error", messageSource.getMessage("presupuesto.error-obtener-precio", null, locale));
HashMap<String, Object> price = new HashMap<>();
String priceStr = apiClient.getPrice(presupuestoService.toSkApiRequest(presupuesto));
try {
price = new ObjectMapper().readValue(priceStr, new TypeReference<>() {
});
} catch (JsonProcessingException e) {
price = new HashMap<>();
price.put("error", messageSource.getMessage("presupuesto.error-obtener-precio", null, locale));
}
if (!price.containsKey("data")) {
return ResponseEntity.badRequest()
.body(messageSource.getMessage("presupuesto.error-obtener-precio", null, locale));
}
return ResponseEntity.ok(price.get("data"));
}
if (!price.containsKey("data")) {
return ResponseEntity.badRequest().body(messageSource.getMessage("presupuesto.error-obtener-precio", null, locale));
}
return ResponseEntity.ok(price.get("data"));
return ResponseEntity.ok().build();
}
@PostMapping("/public/validar/seleccion-tirada")