0004797: Empleado - Criar CRUD na Adm
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@33034 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
ec034b59c9
commit
7c02cb3c52
|
@ -13,4 +13,5 @@ import com.rjconsultores.ventaboletos.entidad.Conductor;
|
||||||
public interface ConductorDAO extends GenericDAO<Conductor, Integer> {
|
public interface ConductorDAO extends GenericDAO<Conductor, Integer> {
|
||||||
|
|
||||||
public Conductor buscar(String claveConductor, String contraSenha);
|
public Conductor buscar(String claveConductor, String contraSenha);
|
||||||
|
public Conductor buscarPorEmpleado(int empleadoId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.ConductorDAO;
|
import com.rjconsultores.ventaboletos.dao.ConductorDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Conductor;
|
import com.rjconsultores.ventaboletos.entidad.Conductor;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
|
@ -42,4 +43,12 @@ public class ConductorHibernateDAO extends GenericHibernateDAO<Conductor, Intege
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Conductor buscarPorEmpleado(int empleadoId){
|
||||||
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||||
|
c.add(Restrictions.eq("empleado.empleadoId", empleadoId));
|
||||||
|
|
||||||
|
return (Conductor) c.uniqueResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ import org.springframework.stereotype.Repository;
|
||||||
*
|
*
|
||||||
* @author Shiro
|
* @author Shiro
|
||||||
*/
|
*/
|
||||||
@Repository("empladoDAO")
|
@Repository("empleadoDAO")
|
||||||
public class EmpladoHibernateDAO extends GenericHibernateDAO<Empleado, Integer>
|
public class EmpleadoHibernateDAO extends GenericHibernateDAO<Empleado, Integer>
|
||||||
implements EmpleadoDAO {
|
implements EmpleadoDAO {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public EmpladoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
public EmpleadoHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
|
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO;
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.TipoEmpleado;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
@ -16,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.TipoEmpleado;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Shiro
|
* @author Shiro
|
||||||
|
|
|
@ -55,8 +55,18 @@ public class Conductor implements Serializable {
|
||||||
private Empleado empleado;
|
private Empleado empleado;
|
||||||
@Column(name = "NOMBPATERNO")
|
@Column(name = "NOMBPATERNO")
|
||||||
private String nomPaterno;
|
private String nomPaterno;
|
||||||
|
@Column(name = "NOMBMATERNO")
|
||||||
|
private String nomMaterno;
|
||||||
|
|
||||||
public String getNomPaterno() {
|
public String getNomMaterno() {
|
||||||
|
return nomMaterno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNomMaterno(String nomMaterno) {
|
||||||
|
this.nomMaterno = nomMaterno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNomPaterno() {
|
||||||
return nomPaterno;
|
return nomPaterno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,12 @@ public class Empleado implements Serializable {
|
||||||
private Date fecmodif;
|
private Date fecmodif;
|
||||||
@Column(name = "USUARIO_ID")
|
@Column(name = "USUARIO_ID")
|
||||||
private Integer usuarioId;
|
private Integer usuarioId;
|
||||||
|
@Column(name = "DESCCALLE")
|
||||||
|
private String descCalle;
|
||||||
|
@Column(name = "NUMEXTINT")
|
||||||
|
private String numExtInt;
|
||||||
|
@Column(name = "CODPOSTAL")
|
||||||
|
private String codPostal;
|
||||||
|
|
||||||
@JoinColumn(name = "TIPOEMPLEADO_ID", referencedColumnName = "TIPOEMPLEADO_ID")
|
@JoinColumn(name = "TIPOEMPLEADO_ID", referencedColumnName = "TIPOEMPLEADO_ID")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
@ -170,7 +176,31 @@ public class Empleado implements Serializable {
|
||||||
this.usuarioId = usuarioId;
|
this.usuarioId = usuarioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getDescCalle() {
|
||||||
|
return descCalle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescCalle(String descCalle) {
|
||||||
|
this.descCalle = descCalle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumExtInt() {
|
||||||
|
return numExtInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumExtInt(String numExtInt) {
|
||||||
|
this.numExtInt = numExtInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCodPostal() {
|
||||||
|
return codPostal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCodPostal(String codPostal) {
|
||||||
|
this.codPostal = codPostal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
hash += (empleadoId != null ? empleadoId.hashCode() : 0);
|
hash += (empleadoId != null ? empleadoId.hashCode() : 0);
|
||||||
|
|
|
@ -48,4 +48,8 @@ public class ConductorServiceImpl implements ConductorService {
|
||||||
public Conductor buscar(String claveConductor, String contraSenha) {
|
public Conductor buscar(String claveConductor, String contraSenha) {
|
||||||
return conductorDAO.buscar(claveConductor, contraSenha);
|
return conductorDAO.buscar(claveConductor, contraSenha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Conductor buscarPorEmpleado(int empleadoId){
|
||||||
|
return conductorDAO.buscarPorEmpleado(empleadoId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.service.impl;
|
package com.rjconsultores.ventaboletos.service.impl;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.dao.ConductorDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.EmpleadoDAO;
|
import com.rjconsultores.ventaboletos.dao.EmpleadoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.Conductor;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Empleado;
|
import com.rjconsultores.ventaboletos.entidad.Empleado;
|
||||||
import com.rjconsultores.ventaboletos.service.EmpleadoService;
|
import com.rjconsultores.ventaboletos.service.EmpleadoService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
@ -12,6 +14,7 @@ import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -20,8 +23,12 @@ import org.springframework.stereotype.Service;
|
||||||
@Service("empleadoService")
|
@Service("empleadoService")
|
||||||
public class EmpleadoServiceImpl implements EmpleadoService {
|
public class EmpleadoServiceImpl implements EmpleadoService {
|
||||||
|
|
||||||
|
private static int CONDUCTOR = 1;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmpleadoDAO empleadoDAO;
|
private EmpleadoDAO empleadoDAO;
|
||||||
|
@Autowired
|
||||||
|
private ConductorDAO conductorDAO;
|
||||||
|
|
||||||
public List<Empleado> obtenerTodos() {
|
public List<Empleado> obtenerTodos() {
|
||||||
return empleadoDAO.obtenerTodos();
|
return empleadoDAO.obtenerTodos();
|
||||||
|
@ -31,27 +38,66 @@ public class EmpleadoServiceImpl implements EmpleadoService {
|
||||||
return empleadoDAO.obtenerID(id);
|
return empleadoDAO.obtenerID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public Empleado suscribir(Empleado entidad) {
|
public Empleado suscribir(Empleado entidad) {
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.TRUE);
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
return empleadoDAO.suscribir(entidad);
|
Empleado result = empleadoDAO.suscribir(entidad);
|
||||||
|
|
||||||
|
if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){
|
||||||
|
Conductor cond = new Conductor();
|
||||||
|
cond.setActivo(Boolean.TRUE);
|
||||||
|
cond.setEmpleado(result);
|
||||||
|
cond.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
cond.setNombconductor(entidad.getNombEmpleado());
|
||||||
|
cond.setNomPaterno(entidad.getNombPaterno());
|
||||||
|
cond.setNomMaterno(entidad.getNombMaterno());
|
||||||
|
cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
|
||||||
|
conductorDAO.suscribir(cond);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public Empleado actualizacion(Empleado entidad) {
|
public Empleado actualizacion(Empleado entidad) {
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.TRUE);
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){
|
||||||
|
Conductor cond = conductorDAO.buscarPorEmpleado(entidad.getEmpleadoId());
|
||||||
|
cond.setActivo(Boolean.TRUE);
|
||||||
|
cond.setEmpleado(entidad);
|
||||||
|
cond.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
cond.setNombconductor(entidad.getNombEmpleado());
|
||||||
|
cond.setNomPaterno(entidad.getNombPaterno());
|
||||||
|
cond.setNomMaterno(entidad.getNombMaterno());
|
||||||
|
cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
|
||||||
|
conductorDAO.actualizacion(cond);
|
||||||
|
}
|
||||||
|
|
||||||
return empleadoDAO.actualizacion(entidad);
|
return empleadoDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void borrar(Empleado entidad) {
|
public void borrar(Empleado entidad) {
|
||||||
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
entidad.setFecmodif(Calendar.getInstance().getTime());
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
entidad.setActivo(Boolean.FALSE);
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
|
if (entidad.getTipoEmpleado().getTipoEmpleadoId() == CONDUCTOR){
|
||||||
|
Conductor cond = conductorDAO.buscarPorEmpleado(entidad.getEmpleadoId());
|
||||||
|
cond.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
cond.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
cond.setActivo(Boolean.FALSE);
|
||||||
|
conductorDAO.actualizacion(cond);
|
||||||
|
}
|
||||||
|
|
||||||
empleadoDAO.actualizacion(entidad);
|
empleadoDAO.actualizacion(entidad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
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 com.rjconsultores.ventaboletos.dao.TipoEmpleadoDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.TipoEmpleado;
|
||||||
|
import com.rjconsultores.ventaboletos.service.TipoEmpleadoService;
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
|
|
||||||
|
@Service("tipoEmpleadoService")
|
||||||
|
public class TipoEmpleadoServiceImpl implements TipoEmpleadoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TipoEmpleadoDAO tipoEmpleadoDAO;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TipoEmpleado> obtenerTodos() {
|
||||||
|
return tipoEmpleadoDAO.obtenerTodos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TipoEmpleado obtenerID(Integer id) {
|
||||||
|
return tipoEmpleadoDAO.obtenerID(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TipoEmpleado suscribir(TipoEmpleado entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
return tipoEmpleadoDAO.suscribir(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TipoEmpleado actualizacion(TipoEmpleado entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.TRUE);
|
||||||
|
|
||||||
|
return tipoEmpleadoDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void borrar(TipoEmpleado entidad) {
|
||||||
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||||
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
||||||
|
entidad.setActivo(Boolean.FALSE);
|
||||||
|
|
||||||
|
tipoEmpleadoDAO.actualizacion(entidad);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue