passcode controller and service
This commit is contained in:
@@ -24,8 +24,6 @@ import { IdEquipoPaginaDto } from '../dto/id-equipo-pagina.dto';
|
||||
import { IdUsuarioDto } from '../dto/id-usuario.dto';
|
||||
import { IdUsuarioPaginaDto } from '../dto/id-usuario-pagina.dto';
|
||||
import { NumeroInventarioDto } from '../dto/numero-inventario.dto';
|
||||
// import { PasscodeDto } from '../dto/passcode.dto';
|
||||
import { AutoprestamoDto} from './dto/input/autoprestamo.dto'
|
||||
import { ActivosDto } from './dto/input/activos.dto';
|
||||
import { CancelarUsuarioDto } from './dto/input/cancelar-usuario.dto';
|
||||
import { CancelarOperadorDto } from './dto/input/cancelar-operador.dto';
|
||||
@@ -35,7 +33,6 @@ import { PedirDto } from './dto/input/pedir.dto';
|
||||
import { EntregarDto } from './dto/input/entregar.dto';
|
||||
import { RegresarIdPrestamoDto } from './dto/input/regresar-id-prestamo.dto';
|
||||
import { RegresarNumeroInventarioDto } from './dto/input/regresar-numero-inventario.dto';
|
||||
import { RegresarAutoprestamoDto } from './dto/input/regresar-autoprestamo.dto';
|
||||
import { ActivosOutputDto } from './dto/output/activos.dto';
|
||||
import { EntregaOutputDto } from './dto/output/entrega.dto';
|
||||
import { PrestamoOutputDto } from './dto/output/prestamo.dto';
|
||||
@@ -125,34 +122,6 @@ export class PrestamoController {
|
||||
return this.prestamoService.findAll(query);
|
||||
}
|
||||
|
||||
@Serealize(EntregaOutputDto)
|
||||
@Put('autoprestamo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que actualiza el status del equipo a "En uso" por medio del autoprestamo.',
|
||||
})
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
description: 'Ambas variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { passcode: 123456789012, id_locker: 30 } } },
|
||||
})
|
||||
autoprestamo(@Request() req, @Body() body: AutoprestamoDto) {
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
if (
|
||||
!operador ||
|
||||
(operador.tipoUsuario.id_tipo_usuario != 3 &&
|
||||
operador.tipoUsuario.id_tipo_usuario != 4)
|
||||
)
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
const passcode = body.passcode + ''
|
||||
let id_prestamo = passcode.substring(2,8)
|
||||
|
||||
return this.prestamoService.entregar(parseInt(id_prestamo), body.id_operador);
|
||||
}
|
||||
|
||||
@Put('cancelar-operador')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
@@ -506,63 +475,6 @@ export class PrestamoController {
|
||||
);
|
||||
}
|
||||
|
||||
// prestamoPasscode(
|
||||
// @Request() req,
|
||||
// @Query() query: PasscodeDto,
|
||||
// ) {
|
||||
// const operador: Operador = req.user.operador;
|
||||
|
||||
// if (
|
||||
// !operador ||
|
||||
// (operador.tipoUsuario.id_tipo_usuario != 1)
|
||||
// )
|
||||
// throw new ForbiddenException(
|
||||
// 'No tienes los permisos necesarios para realizar esta acción.',
|
||||
// );
|
||||
// //revisar el tipo de dato del id_locker o id_carrito
|
||||
// return this.prestamoService.findByNumeroInventario(
|
||||
// parseInt(query.passcode),
|
||||
// query.id_locker,
|
||||
// );
|
||||
// }
|
||||
|
||||
@Put('regresar-autoprestamo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que desactiva un autopréstamo.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiBody({
|
||||
description: 'Solo necesitamos el passcode.',
|
||||
examples: {
|
||||
ejemplo: {
|
||||
value: {
|
||||
passcode: 123456789012,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
regresarAutoprestamo(
|
||||
@Request() req,
|
||||
@Body() body: RegresarAutoprestamoDto,
|
||||
) {
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
if (
|
||||
!operador ||
|
||||
(operador.tipoUsuario.id_tipo_usuario != 3 &&
|
||||
operador.tipoUsuario.id_tipo_usuario != 4)
|
||||
)
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
const passcode = body.passcode + ''
|
||||
const id_prestamo = passcode.substring(2,8)
|
||||
|
||||
return this.prestamoService.regresarIdPrestamo(
|
||||
body.id_operador,
|
||||
parseInt(id_prestamo)
|
||||
);
|
||||
}
|
||||
|
||||
@Put('regresar-id-prestamo')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que desactiva un préstamo.' })
|
||||
|
||||
Reference in New Issue
Block a user