diff --git a/src/com/rjconsultores/ventaboletos/dao/UsuarioDAO.java b/src/com/rjconsultores/ventaboletos/dao/UsuarioDAO.java index 93296a3f2..b8e4467fc 100644 --- a/src/com/rjconsultores/ventaboletos/dao/UsuarioDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/UsuarioDAO.java @@ -4,11 +4,12 @@ */ package com.rjconsultores.ventaboletos.dao; +import java.util.List; + import com.rjconsultores.ventaboletos.entidad.Empleado; import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.vo.caja.UsuarioActivoVO; - -import java.util.List; +import com.rjconsultores.ventaboletos.vo.embarcada.UsuarioEmbarcadaVO; /** * @@ -30,4 +31,6 @@ public interface UsuarioDAO extends GenericDAO { public Usuario buscarPeloId(Integer usuarioId); + public List buscarPorFuncionSistema(Long funcionSistemaId); + } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioHibernateDAO.java index 5aad4213d..1a266f7a1 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/UsuarioHibernateDAO.java @@ -14,7 +14,9 @@ import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.hibernate.transform.AliasToBeanResultTransformer; +import org.hibernate.transform.Transformers; import org.hibernate.type.IntegerType; +import org.hibernate.type.LongType; import org.hibernate.type.StringType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -22,10 +24,10 @@ import org.springframework.stereotype.Repository; import com.rjconsultores.ventaboletos.dao.UsuarioDAO; import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder; -import com.rjconsultores.ventaboletos.entidad.ContaMD; import com.rjconsultores.ventaboletos.entidad.Empleado; import com.rjconsultores.ventaboletos.entidad.Usuario; import com.rjconsultores.ventaboletos.vo.caja.UsuarioActivoVO; +import com.rjconsultores.ventaboletos.vo.embarcada.UsuarioEmbarcadaVO; /** * @@ -117,4 +119,29 @@ public class UsuarioHibernateDAO extends GenericHibernateDAO i return (Usuario) c.uniqueResult(); } + + @Override + public List buscarPorFuncionSistema(Long funcionSistemaId){ + StringBuilder sQuery = new StringBuilder(); + sQuery.append("select u.usuario_Id as usuarioId, null as nome, u.cveusuario as cveusuario, u.desccontrasena as senha, null as email from usuario u "); + sQuery.append("where "); + sQuery.append(" u.activo = 1 "); + sQuery.append(" and u.usuario_id in ( "); + sQuery.append(" select up.usuario_id "); + sQuery.append(" from usuario_perfil up "); + sQuery.append(" join perfil_funcion pf on pf.perfil_id = up.perfil_id "); + sQuery.append(" where pf.funcionsistema_id = :funcionSistemaId AND pf.activo = 1 and up.activo = 1 "); + sQuery.append(" ) "); + + Query qr = getSession().createSQLQuery(sQuery.toString()) + .addScalar("usuarioId", new LongType()) + .addScalar("nome", new StringType()) + .addScalar("cveusuario", new StringType()) + .addScalar("senha", new StringType()) + .addScalar("email", new StringType()) + .setResultTransformer(Transformers.aliasToBean(UsuarioEmbarcadaVO.class)); + + qr.setLong("funcionSistemaId", funcionSistemaId); + return (List)qr.list(); + } } diff --git a/src/com/rjconsultores/ventaboletos/vo/embarcada/UsuarioEmbarcadaVO.java b/src/com/rjconsultores/ventaboletos/vo/embarcada/UsuarioEmbarcadaVO.java index 3fd1f33fe..37942e82f 100644 --- a/src/com/rjconsultores/ventaboletos/vo/embarcada/UsuarioEmbarcadaVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/embarcada/UsuarioEmbarcadaVO.java @@ -7,6 +7,8 @@ public class UsuarioEmbarcadaVO { private String senha; private String email; + public UsuarioEmbarcadaVO(){} + public UsuarioEmbarcadaVO(Long usuarioId, String nome, String cveusuario, String senha, String email) { super(); this.usuarioId = usuarioId;