kebblar / petstore-back

Pet Store app Backend
MIT License
0 stars 1 forks source link

Crear servicio de Login #24

Open arellano-gustavo opened 3 years ago

arellano-gustavo commented 3 years ago

Condiciones:

Adjunto archivo con propuesta de interfaz ingresar-al-sistema.pdf

Se propone como estructura de tablas del servicio la siguiente:

CREATE TABLE `rol` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(128) NOT NULL,
  `activo` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE `usuario_rol` (
  `id_usuario` int(11) NOT NULL,
  `id_rol` int(12) NOT NULL,
  PRIMARY KEY (`id_usuario`, `id_rol`),
  CONSTRAINT `fk_usuario` FOREIGN KEY (`id_usuario`) REFERENCES `usuario` (`id`),
  CONSTRAINT `fk_rol` FOREIGN KEY (`id_rol`) REFERENCES `rol` (`id`)
);

CREATE TABLE `usuario` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `correo` varchar(128) NOT NULL,
  `clave` varchar(128) NOT NULL DEFAULT 'temp',
  `creado` bigint(20) NOT NULL DEFAULT 0,
  `activo` tinyint(1) NOT NULL DEFAULT 0,
  `acceso_negado_contador` int(11) NOT NULL DEFAULT 0,
  `instante_bloqueo` bigint(20) NOT NULL DEFAULT 0,
  `instante_ultimo_acceso` bigint(20) NOT NULL DEFAULT 0,
  `instante_ultimo_cambio_clave` bigint(20) NOT NULL DEFAULT 0,
  `regenera_clave_token` varchar(128) NOT NULL DEFAULT 'NA',
  `regenera_clave_instante` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_usuario_correo` (`correo`),
  KEY `idx_usuario_regenera` (`regenera_clave_token`)
)

Se propone el siguiente JSON para REQUEST de login

{
"usuario":"gustavo",
"clave":"arellano"
}

Se propone los siguientes JSON para RESPONSE de login

De éxito

{
  "usuarioDetalle": {
    "id": 1765,
    "nombre": "Gustavo",
    "apellidoPaterno": "Arellano"
  },
  "correo": "gus@aol.com",
  "jwt": "jwt-bchfjdbchfd",
  "ultimoAcceso": "2021-04-16T14:13:27.793+00:00",
  "roles": [
    {
      "id": 1,
      "nombre": "abc1",
      "activo": true,
      "hash": 4199836
    }
  ],
  "direcciones": [
       {
        "id":7,
        "calleNumero":"Kopoma 1765",
        "colonia":"Pedregal",
        "delegacion":23,
        "estado": 5
       }
   ],
  "hash": 199844168
}

Con códigos de retorno menores a 300

De error (es sólo un ejemplo)

  "tipo-error": 2005,
  "cve-exception": "CVE_2005",
  "desc-exception": "El usuario proporcionado ya se encuentra registrado en la base de datos.",
  "http-error": "BAD_REQUEST"
}

Con códigos de retorno mayores a 299

arellano-gustavo commented 3 years ago

@fherevans Favor de cambiar el nombre de la tabla de "usuario" a "user"

arellano-gustavo commented 3 years ago

1) Ya se tiene la interfaz de login

imagen

2) Ya está el diseño correspondiente a lo que se requiere en la base de datos.

arellano-gustavo commented 3 years ago
  1. Ya está creado el contrato JSON (request y response) (ver cuerpo principal del issue)
arellano-gustavo commented 3 years ago
  1. Ya están creadas las clases de dominio: Direccion, Rol, LoginResponse y UsuarioDetalle
  2. Ya está creado el controlador REST (puede y generalmente va a nacer siendo Dummy)
arellano-gustavo commented 3 years ago
  1. Ya se ha creado la interfase
  2. Este servicio NO requiere (por el momento) clases de soporte
  3. Mappers creados
  4. Implementar interfase (primero dummy)