mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
falta procesar el resultado
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user