Merge pull request 'Integração Izypay feat bug#AL-4379' (!247) from AL-4397 into master

Reviewed-on: adm/ModelWeb#247
Reviewed-by: Valdir Cordeiro <valdir.cordeiro@totvs.com.br>
master
fabio 2024-08-12 17:35:53 +00:00
commit bb32a7f590
7 changed files with 234 additions and 2 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>br.com.rjconsultores</groupId> <groupId>br.com.rjconsultores</groupId>
<artifactId>ModelWeb</artifactId> <artifactId>ModelWeb</artifactId>
<version>1.92.3</version> <version>1.93.0</version>
<distributionManagement> <distributionManagement>
<repository> <repository>

View File

@ -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<EmpresaIziPayConfig, Integer> {
public List<EmpresaIziPayConfig> obtenerTodos();
public Optional<EmpresaIziPayConfig> buscarPorEmpresa(Empresa empresa);
}

View File

@ -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<EmpresaIziPayConfig, Integer>
implements EmpresaIziPayDAO {
@Autowired
public EmpresaIziPayHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@SuppressWarnings("unchecked")
@Override
public List<EmpresaIziPayConfig> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
@Override
public Optional<EmpresaIziPayConfig> 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());
}
}

View File

@ -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());
}
}

View File

@ -7,7 +7,8 @@ public enum TipoCarteiraDigital {
TROCO_SIMPLES(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTrocoSimples.label")), TROCO_SIMPLES(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTrocoSimples.label")),
TEF(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTef.label")), TEF(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTef.label")),
TPI(Labels.getLabel("editarFormaPagoController.lblCateiraDigitalTpi.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; private String descricao;

View File

@ -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<EmpresaIziPayConfig, Integer> {
public Optional<EmpresaIziPayConfig> buscarPorEmpresa(Empresa empresa);
}

View File

@ -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<EmpresaIziPayConfig> 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<EmpresaIziPayConfig> buscarPorEmpresa(Empresa empresa) {
return empresaIziPayService.buscarPorEmpresa(empresa);
}
}