mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
102 lines
2.4 KiB
Java
102 lines
2.4 KiB
Java
package com.imprimelibros.erp.cart;
|
|
|
|
import java.util.Locale;
|
|
|
|
import org.springframework.context.MessageSource;
|
|
import com.imprimelibros.erp.cart.dto.DireccionCardDTO;
|
|
import com.imprimelibros.erp.direcciones.Direccion;
|
|
import com.imprimelibros.erp.presupuesto.dto.Presupuesto;
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
@Entity
|
|
@Table(name = "cart_direcciones")
|
|
public class CartDireccion {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "cart_id", nullable = false)
|
|
private Cart cart;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "direccion_id", nullable = false)
|
|
private Direccion direccion;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "presupuesto_id")
|
|
private Presupuesto presupuesto;
|
|
|
|
@Column(name = "unidades")
|
|
private Integer unidades;
|
|
|
|
@Column(name = "isPalets", nullable = false)
|
|
private Boolean isPalets;
|
|
|
|
// --- Getters & Setters ---
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public Cart getCart() {
|
|
return cart;
|
|
}
|
|
|
|
public void setCart(Cart cart) {
|
|
this.cart = cart;
|
|
}
|
|
|
|
public Direccion getDireccion() {
|
|
return direccion;
|
|
}
|
|
|
|
public void setDireccion(Direccion direccion) {
|
|
this.direccion = direccion;
|
|
}
|
|
|
|
public Presupuesto getPresupuesto() {
|
|
return presupuesto;
|
|
}
|
|
|
|
public void setPresupuesto(Presupuesto presupuesto) {
|
|
this.presupuesto = presupuesto;
|
|
}
|
|
|
|
public Integer getUnidades() {
|
|
return unidades;
|
|
}
|
|
|
|
public void setUnidades(Integer unidades) {
|
|
this.unidades = unidades;
|
|
}
|
|
|
|
public Boolean getIsPalets() {
|
|
return isPalets;
|
|
}
|
|
|
|
public void setIsPalets(Boolean isPalets) {
|
|
this.isPalets = isPalets;
|
|
}
|
|
|
|
public DireccionCardDTO toDireccionCard(MessageSource messageSource, Locale locale) {
|
|
|
|
String pais = messageSource.getMessage("paises." + this.direccion.getPais().getKeyword(), null,
|
|
this.direccion.getPais().getKeyword(), locale);
|
|
|
|
return new DireccionCardDTO(
|
|
this.direccion,
|
|
this.presupuesto != null ? this.presupuesto.getId() : null,
|
|
this.unidades,
|
|
this.isPalets,
|
|
pais
|
|
);
|
|
}
|
|
|
|
}
|