diff --git a/pom.xml b/pom.xml index 72eafdd8f..6d9df200d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 br.com.rjconsultores ModelWeb - 1.92.3 + 1.93.0 diff --git a/src/com/rjconsultores/ventaboletos/dao/EmpresaIziPayDAO.java b/src/com/rjconsultores/ventaboletos/dao/EmpresaIziPayDAO.java new file mode 100644 index 000000000..128fab475 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/EmpresaIziPayDAO.java @@ -0,0 +1,14 @@ +package com.rjconsultores.ventaboletos.dao; + +import java.util.List; +import java.util.Optional; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaIziPayConfig; + +public interface EmpresaIziPayDAO extends GenericDAO { + + public List obtenerTodos(); + public Optional buscarPorEmpresa(Empresa empresa); + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaIziPayHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaIziPayHibernateDAO.java new file mode 100644 index 000000000..4cd2b90d4 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/EmpresaIziPayHibernateDAO.java @@ -0,0 +1,43 @@ +package com.rjconsultores.ventaboletos.dao.hibernate; + +import java.util.List; +import java.util.Optional; + +import org.hibernate.Criteria; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Repository; + +import com.rjconsultores.ventaboletos.dao.EmpresaIziPayDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaIziPayConfig; + +@Repository("empresaIziPayDAO") +public class EmpresaIziPayHibernateDAO extends GenericHibernateDAO + implements EmpresaIziPayDAO { + + @Autowired + public EmpresaIziPayHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @SuppressWarnings("unchecked") + @Override + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + + return c.list(); + } + + @Override + public Optional buscarPorEmpresa(Empresa empresa) { + Criteria c = getSession().createCriteria(getPersistentClass()); + c.add(Restrictions.eq("activo", Boolean.TRUE)); + c.add(Restrictions.eq("empresa.empresaId", empresa.getEmpresaId())); + + return Optional.ofNullable((EmpresaIziPayConfig) c.uniqueResult()); + } +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/EmpresaIziPayConfig.java b/src/com/rjconsultores/ventaboletos/entidad/EmpresaIziPayConfig.java new file mode 100644 index 000000000..fcb61f272 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/entidad/EmpresaIziPayConfig.java @@ -0,0 +1,93 @@ +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.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +@SequenceGenerator(name = "EMP_IZIPAY_CONFIG_SEQ", sequenceName = "EMP_IZIPAY_CONFIG_SEQ", allocationSize = 1) +@Table(name = "EMPRESA_IZIPAY_CONFIG") +public class EmpresaIziPayConfig implements Serializable { + + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "EMP_IZIPAY_CONFIG_SEQ") + @Column(name = "EMPRESAIZIPAY_ID") + private Integer empresaIziPayId; + + @Column(name = "CLIENT_ID") + private String clientId; + + @Column(name = "SECRET") + private String secret; + + @Column(name = "URL") + private String url; + + @OneToOne + @JoinColumn(name = "EMPRESA_ID") + private Empresa empresa; + + @Column(name = "ACTIVO") + private Boolean activo; + + @Column(name = "FECMODIF") + @Temporal(TemporalType.TIMESTAMP) + private Date fecmodif; + + @Column(name = "USUARIO_ID") + private Integer usuarioId; + + @Column(name = "DIAS_CANCELA") + private Integer diasCancela; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((empresaIziPayId == null) ? 0 : empresaIziPayId.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; + EmpresaIziPayConfig other = (EmpresaIziPayConfig) obj; + if (empresaIziPayId == null) { + if (other.empresaIziPayId != null) + return false; + } else if (!empresaIziPayId.equals(other.empresaIziPayId)) + return false; + return true; + } + + @Override + public String toString() { + return String.valueOf(this.getEmpresaIziPayId()); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/enums/TipoCarteiraDigital.java b/src/com/rjconsultores/ventaboletos/enums/TipoCarteiraDigital.java index 1f75378bd..7bf1e27c7 100644 --- a/src/com/rjconsultores/ventaboletos/enums/TipoCarteiraDigital.java +++ b/src/com/rjconsultores/ventaboletos/enums/TipoCarteiraDigital.java @@ -7,7 +7,8 @@ public enum TipoCarteiraDigital { TROCO_SIMPLES(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTrocoSimples.label")), TEF(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTef.label")), TPI(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTpi.label")), - CIELO_LINK(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalCielo.label")); + CIELO_LINK(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalCielo.label")), + IZIPAY(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalIziPay.label")); private String descricao; diff --git a/src/com/rjconsultores/ventaboletos/service/EmpresaIziPayService.java b/src/com/rjconsultores/ventaboletos/service/EmpresaIziPayService.java new file mode 100644 index 000000000..c0ab56723 --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/EmpresaIziPayService.java @@ -0,0 +1,12 @@ +package com.rjconsultores.ventaboletos.service; + +import java.util.Optional; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaIziPayConfig; + +public interface EmpresaIziPayService extends GenericService { + + public Optional buscarPorEmpresa(Empresa empresa); + +} diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EmpresaIziPayServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaIziPayServiceImpl.java new file mode 100644 index 000000000..1915a01ec --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/service/impl/EmpresaIziPayServiceImpl.java @@ -0,0 +1,69 @@ +package com.rjconsultores.ventaboletos.service.impl; + +import java.util.Calendar; +import java.util.List; +import java.util.Optional; + +import com.rjconsultores.ventaboletos.dao.EmpresaIziPayDAO; +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.EmpresaIziPayConfig; +import com.rjconsultores.ventaboletos.service.EmpresaIziPayService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service("empresaIziPayService") +public class EmpresaIziPayServiceImpl implements EmpresaIziPayService { + + @Autowired + private EmpresaIziPayDAO empresaIziPayService; + + @Override + public List obtenerTodos() { + return empresaIziPayService.obtenerTodos(); + } + + @Override + public EmpresaIziPayConfig obtenerID(Integer id) { + return empresaIziPayService.obtenerID(id); + } + + @Override + @Transactional + public EmpresaIziPayConfig suscribir(EmpresaIziPayConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaIziPayService.suscribir(entidad); + } + + @Override + @Transactional + public EmpresaIziPayConfig actualizacion(EmpresaIziPayConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.TRUE); + + return empresaIziPayService.actualizacion(entidad); + } + + @Override + @Transactional + public void borrar(EmpresaIziPayConfig entidad) { + entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + entidad.setFecmodif(Calendar.getInstance().getTime()); + entidad.setActivo(Boolean.FALSE); + + empresaIziPayService.actualizacion(entidad); + + } + + @Override + public Optional buscarPorEmpresa(Empresa empresa) { + return empresaIziPayService.buscarPorEmpresa(empresa); + } + +}