diff --git a/Desenvolvimento/Codificacao/e-Selo/pom.xml b/Desenvolvimento/Codificacao/e-Selo/pom.xml index 7b7dc37..16b439a 100644 --- a/Desenvolvimento/Codificacao/e-Selo/pom.xml +++ b/Desenvolvimento/Codificacao/e-Selo/pom.xml @@ -162,5 +162,10 @@ jta 1.1 + + javax.ws.rs + javax.ws.rs-api + 2.0 + \ No newline at end of file diff --git a/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/UsuarioServicoWebController.java b/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/UsuarioServicoWebController.java new file mode 100644 index 0000000..51b201f --- /dev/null +++ b/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/controller/UsuarioServicoWebController.java @@ -0,0 +1,40 @@ +package br.com.eselo.controller; + + + +import br.com.caelum.vraptor.Post; +import br.com.caelum.vraptor.Resource; +import br.com.caelum.vraptor.Result; +import br.com.caelum.vraptor.view.Results; +import br.com.eselo.dao.UsuarioServicoWebDAO; +import br.com.eselo.model.UsuarioServicoWeb; + +@Resource +public class UsuarioServicoWebController { + + + private final UsuarioServicoWebDAO dao; + private final Result result; + + public UsuarioServicoWebController(UsuarioServicoWebDAO _dao, Result result) { + this.dao = _dao; + this.result = result; + + + } + + + //@Path("/existe_usuario_servico_web") + @Post("/existe_usuario_servico_web") + public void existeUsuarioServicoWeb(String codigoHash) { + + Boolean usuarioAutorizado = false; + UsuarioServicoWeb carregado = dao.existeUsuarioServicoWeb(codigoHash); + if (carregado != null) { + usuarioAutorizado = true; + } + + result.use(Results.json()).withoutRoot().from(usuarioAutorizado).serialize(); + } + +} diff --git a/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/dao/UsuarioServicoWebDAO.java b/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/dao/UsuarioServicoWebDAO.java new file mode 100644 index 0000000..f78aa89 --- /dev/null +++ b/Desenvolvimento/Codificacao/e-Selo/src/main/java/br/com/eselo/dao/UsuarioServicoWebDAO.java @@ -0,0 +1,35 @@ +package br.com.eselo.dao; + +import org.hibernate.Session; +import org.hibernate.criterion.Restrictions; + +import br.com.caelum.vraptor.ioc.Component; +import br.com.eselo.model.Usuario; +import br.com.eselo.model.UsuarioServicoWeb; + +@Component +public class UsuarioServicoWebDAO extends GenericDAO { + + public UsuarioServicoWebDAO(Session _session) { + super(_session); + } + + public UsuarioServicoWeb existeUsuarioServicoWeb(String codigoHash) { + return (UsuarioServicoWeb) getSession().createCriteria(getPersistentClass()) + .add(Restrictions.eq("codigoHash", codigoHash)) + .add(Restrictions.eq("usuarioAtivo", true)) + .uniqueResult(); + + /*UsuarioServicoWeb encontrado = + (UsuarioServicoWeb) getSession().createCriteria(getPersistentClass()) + .add(Restrictions.eq("hash_code", codigoHash)) + .add(Restrictions.eq("usuario_ativo", true)) + .uniqueResult(); + if(encontrado != null) + { + usuarioAutorizado = true; + }*/ + + } + +} -- libgit2 0.21.2