mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-19 23:30:20 +00:00
trabajando en interior
This commit is contained in:
@ -0,0 +1,85 @@
|
||||
package com.imprimelibros.erp.config.Presupuestador;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ImagenPresupuesto {
|
||||
|
||||
private String id;
|
||||
private String imagen;
|
||||
private String alt;
|
||||
private String texto;
|
||||
private boolean selected;
|
||||
private Map<String, String> extra_data;
|
||||
|
||||
// Constructores
|
||||
public ImagenPresupuesto() {}
|
||||
|
||||
|
||||
public ImagenPresupuesto(String id, String imagen, String alt, String texto, boolean selected) {
|
||||
this.id = id;
|
||||
this.imagen = imagen;
|
||||
this.alt = alt;
|
||||
this.texto = texto;
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
|
||||
public ImagenPresupuesto(String id, String imagen, String alt, String texto, Map<String, String> extra_data,boolean selected) {
|
||||
this.id = id;
|
||||
this.imagen = imagen;
|
||||
this.alt = alt;
|
||||
this.texto = texto;
|
||||
this.selected = selected;
|
||||
this.extra_data = extra_data;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getImagen() {
|
||||
return imagen;
|
||||
}
|
||||
|
||||
public void setImagen(String imagen) {
|
||||
this.imagen = imagen;
|
||||
}
|
||||
|
||||
public String getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(String alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public String getTexto() {
|
||||
return texto;
|
||||
}
|
||||
|
||||
public void setTexto(String texto) {
|
||||
this.texto = texto;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public Map<String, String> getExtra_data() {
|
||||
return extra_data;
|
||||
}
|
||||
|
||||
public void setExtra_data(Map<String, String> extra_data) {
|
||||
this.extra_data = extra_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
package com.imprimelibros.erp.config.Presupuestador;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class PresupuestadorItems {
|
||||
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
public ImagenPresupuesto getImpresionNegro(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"negroEstandar",
|
||||
"/assets/images/imprimelibros/presupuestador/blancoYnegro.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.blanco-negro", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionNegroPremium(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"negroPremium",
|
||||
"/assets/images/imprimelibros/presupuestador/negroFoto.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.blanco-negro-premium", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionColor(Locale locale) {
|
||||
|
||||
String clave = "presupuesto.color"; // ✅
|
||||
String texto = messageSource.getMessage(clave, null, locale);
|
||||
System.out.println("Clave: " + clave + " => Texto: " + texto);
|
||||
return new ImagenPresupuesto(
|
||||
"colorEstandar",
|
||||
"/assets/images/imprimelibros/presupuestador/color.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.color", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getImpresionColorPremium(Locale locale) {
|
||||
return new ImagenPresupuesto(
|
||||
"colorPremium",
|
||||
"/assets/images/imprimelibros/presupuestador/colorFoto.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.color-premium", null, locale),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetBlanco(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-blanco",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-blanco.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-blanco", null, locale),
|
||||
Map.of("sk-id", "3"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetAhuesado(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-ahuesado",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-ahuesado.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-ahuesado", null, locale),
|
||||
Map.of("sk-id", "4"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelOffsetAhuesadoVolumen(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"offset-ahuesado-volumen",
|
||||
"/assets/images/imprimelibros/presupuestador/offset-ahuesado-volumen.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.offset-ahuesado-volumen", null, locale),
|
||||
Map.of("sk-id", "6"),
|
||||
false);
|
||||
}
|
||||
|
||||
public ImagenPresupuesto getPapelEstucadoMate(Locale locale) {
|
||||
|
||||
return new ImagenPresupuesto(
|
||||
"estucado-mate",
|
||||
"/assets/images/imprimelibros/presupuestador/estucado-mate.png",
|
||||
"",
|
||||
messageSource.getMessage("presupuesto.estucado-mate", null, locale),
|
||||
Map.of("sk-id", "2"),
|
||||
false);
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class ConsistentTiradasValidator implements ConstraintValidator<Consisten
|
||||
continue;
|
||||
if (t <= podValue)
|
||||
allAbove = false;
|
||||
if (t >= podValue)
|
||||
else // (t > podValue)
|
||||
allBelow = false;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Constraint(validatedBy = TamanioValidator.class)
|
||||
@Target({ ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Tamanio {
|
||||
|
||||
String message() default "{presupuesto.errores.tamanio.invalido}";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.imprimelibros.erp.config.validation;
|
||||
|
||||
import com.imprimelibros.erp.entity.Presupuesto;
|
||||
import com.imprimelibros.erp.service.VariableService;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
public class TamanioValidator implements ConstraintValidator<Tamanio, Presupuesto>{
|
||||
|
||||
@Autowired
|
||||
private VariableService variableService;
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
|
||||
@Override
|
||||
public boolean isValid(Presupuesto presupuesto, ConstraintValidatorContext context) {
|
||||
|
||||
if (presupuesto == null)
|
||||
return true;
|
||||
|
||||
Integer min = variableService.getValorEntero("ancho_alto_min");
|
||||
Integer max = variableService.getValorEntero("ancho_alto_max");
|
||||
|
||||
|
||||
if (presupuesto.getAncho() <= min || presupuesto.getAncho() >= max) {
|
||||
|
||||
String mensajeInterpolado = messageSource.getMessage(
|
||||
"presupuesto.errores.ancho.min_max", // clave del mensaje
|
||||
new Object[] { min, max }, // parámetros para {0}
|
||||
LocaleContextHolder.getLocale() // respeta el idioma actual
|
||||
);
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(mensajeInterpolado)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
else if (presupuesto.getAlto() <= min || presupuesto.getAlto() >= max) {
|
||||
|
||||
String mensajeInterpolado = messageSource.getMessage(
|
||||
"presupuesto.errores.alto.min_max", // clave del mensaje
|
||||
new Object[] { min, max }, // parámetros para {0}
|
||||
LocaleContextHolder.getLocale() // respeta el idioma actual
|
||||
);
|
||||
context.disableDefaultConstraintViolation();
|
||||
context.buildConstraintViolationWithTemplate(mensajeInterpolado)
|
||||
.addConstraintViolation();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user