bug#AL-1786

master
Fabio Faria 2022-12-22 18:22:12 -03:00
parent aefa7a5488
commit 3e0227fcc2
5 changed files with 301 additions and 0 deletions

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.EmpresaCieloLinkConfig;
public interface EmpresaCieloLinkDAO extends GenericDAO<EmpresaCieloLinkConfig, Integer> {
public List<EmpresaCieloLinkConfig> obtenerTodos();
public Optional<EmpresaCieloLinkConfig> 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.EmpresaCieloLinkDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaCieloLinkConfig;
@Repository("empresaCieloLinkDAO")
public class EmpresaCieloLinkHibernateDAO extends GenericHibernateDAO<EmpresaCieloLinkConfig, Integer>
implements EmpresaCieloLinkDAO {
@Autowired
public EmpresaCieloLinkHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@SuppressWarnings("unchecked")
@Override
public List<EmpresaCieloLinkConfig> obtenerTodos() {
Criteria c = getSession().createCriteria(getPersistentClass());
c.add(Restrictions.eq("activo", Boolean.TRUE));
return c.list();
}
@Override
public Optional<EmpresaCieloLinkConfig> 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((EmpresaCieloLinkConfig) c.uniqueResult());
}
}

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.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;
@Entity
@SequenceGenerator(name = "EMP_CIELOLINK_CONFIG_SEQ", sequenceName = "EMP_CIELOLINK_CONFIG_SEQ", allocationSize = 1)
@Table(name = "EMPRESA_CIELOLINK_CONFIG")
public class EmpresaCieloLinkConfig implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@GeneratedValue(strategy = GenerationType.AUTO, generator = "EMP_CIELOLINK_CONFIG_SEQ")
@Column(name = "EMPRESACIELOLINK_ID")
private Integer empresaCieloLinkId;
@Column(name = "CLIENT_ID")
private String clientId;
@Column(name = "MERCHANT_ID")
private String merchantId;
@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 = "MINUTOS_CANCELA")
private Integer minutosCancela;
public EmpresaCieloLinkConfig() {
}
public Integer getEmpresaCieloLinkId() {
return empresaCieloLinkId;
}
public void setEmpresaCieloLinkId(Integer empresaCieloLinkId) {
this.empresaCieloLinkId = empresaCieloLinkId;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Integer getMinutosCancela() {
return minutosCancela;
}
public void setMinutosCancela(Integer minutosCancela) {
this.minutosCancela = minutosCancela;
}
public Empresa getEmpresa() {
return empresa;
}
public void setEmpresa(Empresa empresa) {
this.empresa = empresa;
}
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 Integer getUsuarioId() {
return usuarioId;
}
public void setUsuarioId(Integer usuarioId) {
this.usuarioId = usuarioId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((empresaCieloLinkId == null) ? 0 : empresaCieloLinkId.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;
EmpresaCieloLinkConfig other = (EmpresaCieloLinkConfig) obj;
if (empresaCieloLinkId == null) {
if (other.empresaCieloLinkId != null)
return false;
} else if (!empresaCieloLinkId.equals(other.empresaCieloLinkId))
return false;
return true;
}
@Override
public String toString() {
return String.valueOf(this.getEmpresaCieloLinkId());
}
}

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.EmpresaCieloLinkConfig;
public interface EmpresaCieloLinkService extends GenericService<EmpresaCieloLinkConfig, Integer> {
public Optional<EmpresaCieloLinkConfig> 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.EmpresaCieloLinkDAO;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.EmpresaCieloLinkConfig;
import com.rjconsultores.ventaboletos.service.EmpresaCieloLinkService;
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("empresaCieloLinkService")
public class EmpresaCieloLinkServiceImpl implements EmpresaCieloLinkService {
@Autowired
private EmpresaCieloLinkDAO empresaCieloLinkService;
@Override
public List<EmpresaCieloLinkConfig> obtenerTodos() {
return empresaCieloLinkService.obtenerTodos();
}
@Override
public EmpresaCieloLinkConfig obtenerID(Integer id) {
return empresaCieloLinkService.obtenerID(id);
}
@Override
@Transactional
public EmpresaCieloLinkConfig suscribir(EmpresaCieloLinkConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return empresaCieloLinkService.suscribir(entidad);
}
@Override
@Transactional
public EmpresaCieloLinkConfig actualizacion(EmpresaCieloLinkConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
return empresaCieloLinkService.actualizacion(entidad);
}
@Override
@Transactional
public void borrar(EmpresaCieloLinkConfig entidad) {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.FALSE);
empresaCieloLinkService.actualizacion(entidad);
}
@Override
public Optional<EmpresaCieloLinkConfig> buscarPorEmpresa(Empresa empresa) {
return empresaCieloLinkService.buscarPorEmpresa(empresa);
}
}