falta procesar el resultado

This commit is contained in:
Jaime Jiménez
2025-09-10 22:44:00 +02:00
parent 030e8af3d3
commit 6a9c197a02
12 changed files with 259 additions and 93 deletions

View File

@ -1,6 +1,7 @@
package com.imprimelibros.erp.presupuesto;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import java.util.HashMap;
import java.util.Locale;
@ -14,16 +15,19 @@ 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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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;
import com.imprimelibros.erp.presupuesto.validation.PresupuestoValidationGroups;
@RestController
@Controller
@RequestMapping("/presupuesto")
public class PresupuestoController {
@ -89,8 +93,9 @@ public class PresupuestoController {
@PostMapping("/public/validar/cubierta")
public ResponseEntity<?> validarCubierta(
@Validated(PresupuestoValidationGroups.Cubierta.class) Presupuesto presupuesto,
BindingResult result,
@RequestParam(name = "calcular", defaultValue = "true") boolean calcular,
BindingResult result, Locale locale) {
Locale locale) {
Map<String, String> errores = new HashMap<>();
@ -301,4 +306,24 @@ public class PresupuestoController {
return ResponseEntity.ok(price);
}
@GetMapping(value="/public/maquetacion/form", produces = MediaType.TEXT_HTML_VALUE)
public String getMaquetacionForm(Model model) {
model.addAttribute("presupuestoMaquetacion", new PresupuestoMaquetacion());
return "imprimelibros/presupuestos/presupuesto-maquetacion-form :: maquetacionForm";
}
@GetMapping("/public/maquetacion")
public ResponseEntity<?> getPresupuestoMaquetacion(
PresupuestoMaquetacion presupuestoMaquetacion,
Model model, Locale locale) {
Map<String, Object> resultado = presupuestoService.getPrecioMaquetacion(presupuestoMaquetacion);
if((Double)resultado.get("precio") == 0.0 && (Integer)resultado.get("numPaginasEstimadas") == 0
&& (Double)resultado.get("precioPaginaEstimado") == 0.0){
return ResponseEntity.badRequest().body(messageSource.getMessage("presupuesto.errores.presupuesto-maquetacion", null, locale));
}
return ResponseEntity.ok(resultado);
}
}