bug#12840

dev:valdevir
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@88486 d1611594-4594-4d17-8e1d-87c2c4800839
master
wilian 2019-01-03 17:40:18 +00:00
parent 427ec486bf
commit 2c898de153
7 changed files with 288 additions and 0 deletions

View File

@ -0,0 +1,7 @@
package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude;
public interface PtovtaAntifraudeDAO extends GenericDAO<PtovtaAntifraude, Integer> {
}

View File

@ -0,0 +1,20 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import com.rjconsultores.ventaboletos.dao.PtovtaAntifraudeDAO;
import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude;
@Repository("ptovtaAntifraudeHibernateDAO")
public class PtovtaAntifraudeHibernateDAO extends GenericHibernateDAO<PtovtaAntifraude, Integer> implements PtovtaAntifraudeDAO {
@Autowired
public PtovtaAntifraudeHibernateDAO(
@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
}

View File

@ -0,0 +1,163 @@
package com.rjconsultores.ventaboletos.entidad;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.rjconsultores.ventaboletos.enums.TipoAntifraude;
/**
* @author Wilian
*/
@Entity
@SequenceGenerator(name = "PTOVTA_ANTIFRAUDE_SEQ", sequenceName = "PTOVTA_ANTIFRAUDE_SEQ", allocationSize = 1)
@Table(name = "PTOVTA_ANTIFRAUDE")
public class PtovtaAntifraude implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "PTOVTA_ANTIFRAUDE_SEQ")
@Column(name = "PTOVTAANTIFRAUDE_ID")
private Integer ptovtaAntifraudeId;
@ManyToOne
@JoinColumn(name = "PUNTOVENTA_ID")
private PuntoVenta puntoventa;
@ManyToOne
@JoinColumn(name = "EMPRESA_ID")
private Empresa empresa;
@Enumerated(EnumType.STRING)
@Column(name = "tipo")
private TipoAntifraude tipo;
@Column(name = "CHAVE")
private String chave;
@Column(name = "ACTIVO")
private Boolean activo;
@Column(name = "FECMODIF")
@Temporal(TemporalType.TIMESTAMP)
private Date fecmodif;
@Column(name = "USUARIO_ID")
private int usuarioId;
public PtovtaAntifraude() {
super();
this.activo = true;
this.fecmodif = new Date();
}
public PtovtaAntifraude(Integer ptovtaAntifraudeId) {
this.ptovtaAntifraudeId = ptovtaAntifraudeId;
}
public Integer getPtovtaAntifraudeId() {
return ptovtaAntifraudeId;
}
public void setPtovtaAntifraudeId(Integer ptovtaAntifraudeId) {
this.ptovtaAntifraudeId = ptovtaAntifraudeId;
}
public PuntoVenta getPuntoventa() {
return puntoventa;
}
public void setPuntoventa(PuntoVenta puntoventa) {
this.puntoventa = puntoventa;
}
public Empresa getEmpresa() {
return empresa;
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
public TipoAntifraude getTipo() {
return tipo;
}
public void setTipo(TipoAntifraude tipo) {
this.tipo = tipo;
}
public String getChave() {
return chave;
}
public void setChave(String chave) {
this.chave = chave;
}
public Boolean getActivo() {
return activo;
}
public void setActivo(Boolean activo) {
this.activo = activo;
}
public Date getFecmodif() {
return fecmodif;
}
public void setFecmodif(Date fecmodif) {
this.fecmodif = fecmodif;
}
public int getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(int usuarioId) {
this.usuarioId = usuarioId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((ptovtaAntifraudeId == null) ? 0 : ptovtaAntifraudeId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PtovtaAntifraude other = (PtovtaAntifraude) obj;
if (ptovtaAntifraudeId == null) {
if (other.ptovtaAntifraudeId != null)
return false;
} else if (!ptovtaAntifraudeId.equals(other.ptovtaAntifraudeId))
return false;
return true;
}
}

View File

@ -31,6 +31,7 @@ import javax.persistence.TemporalType;
import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.BooleanUtils;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Where;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@ -234,6 +235,11 @@ public class PuntoVenta implements Serializable {
@Column(name = "INDREPASSAUTR") @Column(name = "INDREPASSAUTR")
private Boolean indRepassaUTR; private Boolean indRepassaUTR;
@OneToMany(mappedBy = "puntoventa", cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@Where(clause = "activo = 1")
private List<PtovtaAntifraude> ptovtaAntifraudes;
public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e) { public PtovtaEmpresaBloqueada addEmpresaBloqueada(Empresa e) {
PtovtaEmpresaBloqueada eb = new PtovtaEmpresaBloqueada(); PtovtaEmpresaBloqueada eb = new PtovtaEmpresaBloqueada();
@ -1068,4 +1074,25 @@ public class PuntoVenta implements Serializable {
public void setIndRepassaUTR(Boolean indRepassaUTR) { public void setIndRepassaUTR(Boolean indRepassaUTR) {
this.indRepassaUTR = indRepassaUTR; this.indRepassaUTR = indRepassaUTR;
} }
public List<PtovtaAntifraude> getPtovtaAntifraudes() {
return ptovtaAntifraudes;
}
public void setPtovtaAntifraudes(List<PtovtaAntifraude> ptovtaAntifraudes) {
this.ptovtaAntifraudes = ptovtaAntifraudes;
}
public void addChaveAntifurto(PtovtaAntifraude cat){
if(this.ptovtaAntifraudes == null) {
this.ptovtaAntifraudes = new ArrayList<PtovtaAntifraude>();
}
this.ptovtaAntifraudes.add(cat);
}
public void removeChaveAntifurto(PtovtaAntifraude cat){
if(this.ptovtaAntifraudes != null) {
this.ptovtaAntifraudes.remove(cat);
}
}
} }

View File

@ -0,0 +1,7 @@
package com.rjconsultores.ventaboletos.enums;
public enum TipoAntifraude {
KONDUTO;
}

View File

@ -0,0 +1,7 @@
package com.rjconsultores.ventaboletos.service;
import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude;
public interface PtovtaAntifraudeService extends GenericService<PtovtaAntifraude, Integer> {
}

View File

@ -0,0 +1,57 @@
package com.rjconsultores.ventaboletos.service.impl;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.PtovtaAntifraudeDAO;
import com.rjconsultores.ventaboletos.entidad.PtovtaAntifraude;
import com.rjconsultores.ventaboletos.service.PtovtaAntifraudeService;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("ptovtaAntifraudeService")
public class PtovtaAntifraudeServiceImpl implements PtovtaAntifraudeService {
@Autowired
PtovtaAntifraudeDAO ptovtaAntifraudeServiceDAO;
@Override
public List<PtovtaAntifraude> obtenerTodos() {
return ptovtaAntifraudeServiceDAO.obtenerTodos();
}
@Override
public PtovtaAntifraude obtenerID(Integer id) {
return ptovtaAntifraudeServiceDAO.obtenerID(id);
}
@Override
@Transactional
public PtovtaAntifraude suscribir(PtovtaAntifraude entidad) {
entidad.setActivo(true);
entidad.setFecmodif(new Date());
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
return ptovtaAntifraudeServiceDAO.suscribir(entidad);
}
@Override
@Transactional
public PtovtaAntifraude actualizacion(PtovtaAntifraude entidad) {
entidad.setFecmodif(new Date());
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
return ptovtaAntifraudeServiceDAO.actualizacion(entidad);
}
@Override
@Transactional
public void borrar(PtovtaAntifraude entidad) {
entidad.setActivo(false);
entidad.setFecmodif(new Date());
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
ptovtaAntifraudeServiceDAO.actualizacion(entidad);
}
}