cadastro de transportadora feat bug#AL-4277
parent
70f6a259eb
commit
6f628db33a
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ModelWeb</artifactId>
|
||||
<version>1.76.2</version>
|
||||
<version>1.77.0</version>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.rjconsultores.ventaboletos.anotacao;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Renderizado{
|
||||
Class<? extends Enum<?>> conversor() default DefaultEnum.class;
|
||||
|
||||
String metodoConversor() default "buscarPeloValor";
|
||||
|
||||
enum DefaultEnum{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Transportadora;
|
||||
|
||||
public interface TransportadoraDAO extends GenericDAO<Transportadora, Long> {
|
||||
|
||||
public boolean existe(String nit);
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.TransportadoraDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Transportadora;
|
||||
|
||||
@Repository("transportadoraDAO")
|
||||
public class TransportadoraHibernateDAO extends GenericHibernateDAO<Transportadora, Long> implements TransportadoraDAO {
|
||||
|
||||
@Autowired
|
||||
public TransportadoraHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Transportadora> obtenerTodos() {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existe(String nit) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("nit", nit.trim()));
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
return !c.list().isEmpty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.rjconsultores.ventaboletos.entidad;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import com.rjconsultores.ventaboletos.anotacao.Renderizado;
|
||||
import com.rjconsultores.ventaboletos.enums.CustomTipo;
|
||||
import com.rjconsultores.ventaboletos.enums.EnumStatus;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "TRANSPORTADORA")
|
||||
@SequenceGenerator(name = "TRANSPORTADORA_SEQ", sequenceName = "TRANSPORTADORA_SEQ", allocationSize = 1)
|
||||
public class Transportadora implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = -8441764653321195183L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TRANSPORTADORA_SEQ")
|
||||
@Column(name = "TRANSPORTADORA_ID")
|
||||
private Long transportadoraId;
|
||||
|
||||
@Renderizado( conversor = CustomTipo.class)
|
||||
@Column(name = "NIT")
|
||||
private String nit;
|
||||
|
||||
@Renderizado
|
||||
@Column(name = "NOME_TRANSPORTADORA")
|
||||
private String nomeTransportadora;
|
||||
|
||||
@Column(name = "CLASSE_PAGAMENTO")
|
||||
private Integer classePagamento;
|
||||
|
||||
@Column(name = "FORMA_PAGAMENTO")
|
||||
private Integer formaPagamento;
|
||||
|
||||
@Column(name = "USUARIO_ID")
|
||||
private Integer usuarioId;
|
||||
|
||||
@Renderizado( conversor = EnumStatus.class)
|
||||
@Column(name = "ACTIVO")
|
||||
private boolean activo;
|
||||
|
||||
@Column(name = "FECMODIF")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date fecModif;
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.rjconsultores.ventaboletos.enums;
|
||||
|
||||
public enum EnumStatus {
|
||||
|
||||
INATIVO("false", "Inativo"),
|
||||
ATIVO("true", "Ativo");
|
||||
|
||||
private String valor;
|
||||
private String descricao;
|
||||
|
||||
private EnumStatus(String valor, String descricao) {
|
||||
this.valor = valor;
|
||||
this.descricao = descricao;
|
||||
}
|
||||
|
||||
public String getValor() {
|
||||
return valor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.descricao;
|
||||
}
|
||||
|
||||
public static EnumStatus buscarPeloValor(String tValor) {
|
||||
for (EnumStatus valor : EnumStatus.values()) {
|
||||
if (valor.getValor().equalsIgnoreCase(tValor)) {
|
||||
return valor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Transportadora;
|
||||
|
||||
public interface TransportadoraService extends GenericService<Transportadora, Long> {
|
||||
|
||||
public boolean existe(String nit);
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.util.Calendar;
|
||||
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.TransportadoraDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Transportadora;
|
||||
import com.rjconsultores.ventaboletos.service.TransportadoraService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("transportadoraService")
|
||||
public class TransportadoraServiceImpl implements TransportadoraService {
|
||||
|
||||
@Autowired
|
||||
private TransportadoraDAO transportadoraDAO;
|
||||
|
||||
public List<Transportadora> obtenerTodos() {
|
||||
return transportadoraDAO.obtenerTodos();
|
||||
}
|
||||
|
||||
public Transportadora obtenerID(Long id) {
|
||||
return transportadoraDAO.obtenerID(id);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Transportadora suscribir(Transportadora entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecModif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.TRUE);
|
||||
|
||||
return transportadoraDAO.suscribir(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Transportadora actualizacion(Transportadora entidad) {
|
||||
return transportadoraDAO.actualizacion(entidad);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void borrar(Transportadora entidad) {
|
||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
entidad.setFecModif(Calendar.getInstance().getTime());
|
||||
entidad.setActivo(Boolean.FALSE);
|
||||
|
||||
transportadoraDAO.borrar(entidad);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existe(String nit) {
|
||||
return transportadoraDAO.existe(nit);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue