trabajando en modificar para obtener los servicios

This commit is contained in:
Jaime Jiménez
2025-09-23 15:09:08 +02:00
parent 85681b4d6e
commit c1df92b840
4 changed files with 39 additions and 24 deletions

View File

@ -21,9 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.http.MediaType;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.imprimelibros.erp.externalApi.skApiClient;
import com.imprimelibros.erp.presupuesto.classes.ImagenPresupuesto;
import com.imprimelibros.erp.presupuesto.classes.PresupuestoMaquetacion;
@ -116,21 +113,14 @@ public class PresupuestoController {
if (calcular) {
HashMap<String, Object> price = new HashMap<>();
String priceStr = apiClient.getPrice(presupuestoService.toSkApiRequest(presupuesto));
HashMap<String, Object> price = presupuestoService.calcularPresupuesto(presupuesto, locale);
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"));
}
return ResponseEntity.ok().build();
}
@ -154,7 +144,7 @@ public class PresupuestoController {
Map<String, Object> resultado = new HashMap<>();
// servicios extra
resultado.putAll(presupuestoService.obtenerServiciosExtras(presupuesto, locale, apiClient));
resultado.putAll(presupuestoService.obtenerServiciosExtras(presupuesto, locale));
Map<String, String> language = new HashMap<>();
language.put("calcular", messageSource.getMessage("presupuesto.calcular", null, locale));
resultado.put("language", language);