Datasets:
ArXiv:
License:
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package ws; | |
import beans.Conductor; | |
import beans.Respuesta; | |
import beans.RespuestaValidacion; | |
import java.sql.Date; | |
import javax.ws.rs.core.Context; | |
import javax.ws.rs.core.UriInfo; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.Consumes; | |
import javax.ws.rs.FormParam; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.POST; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.PUT; | |
import javax.ws.rs.core.MediaType; | |
import model.dao.ConductorDAO; | |
/** | |
* REST Web Service | |
* | |
* @author manolo | |
* @author Juan Carlos | |
*/ | |
public class ConductorWS { | |
private UriInfo context; | |
/** | |
* Creates a new instance of ConductorWS | |
*/ | |
public ConductorWS() { | |
} | |
public Respuesta registrarUsuario( | |
String nombre, | |
String telefono, | |
String password, | |
String fechaNacimiento, | |
String numeroLicencia | |
) { | |
Respuesta res = new Respuesta(); | |
Conductor conductor = new Conductor(nombre, Date.valueOf(fechaNacimiento), | |
numeroLicencia, telefono, password); | |
int fa = ConductorDAO.registrarConductor(conductor); | |
if (fa > 0) { | |
res.setError(false); | |
res.setErrorcode(0); | |
res.setMensaje("Conductor registrado exitosamente"); | |
} else { | |
switch (fa) { | |
case -1: | |
res.setError(true); | |
res.setErrorcode(1); | |
res.setMensaje("Error al registrar conductor, datos no válidos"); | |
break; | |
case -2: | |
res.setError(true); | |
res.setErrorcode(2); | |
res.setMensaje("Error al registrar conductor, ese numero " | |
+ "ya está registrado"); | |
break; | |
default: | |
res.setError(true); | |
res.setErrorcode(3); | |
res.setMensaje("Error de conexión"); | |
break; | |
} | |
} | |
return res; | |
} | |
public RespuestaValidacion autenticarConductor( | |
String telefono, | |
String token | |
){ | |
RespuestaValidacion res = new RespuestaValidacion(); | |
res = ConductorDAO.autenticarConductor(telefono, token); | |
return res; | |
} | |
public RespuestaValidacion iniciarSesion( | |
String telefono, | |
String password | |
){ | |
RespuestaValidacion res = new RespuestaValidacion(); | |
res = ConductorDAO.iniciarSesion(telefono, password); | |
return res; | |
} | |
} | |