@Patch idactivo
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Res,
|
||||
Req,
|
||||
Param,
|
||||
Patch,
|
||||
} from '@nestjs/common';
|
||||
import type { Response } from 'express';
|
||||
import { UserService } from './user.service';
|
||||
@@ -40,6 +41,11 @@ export class UserController {
|
||||
return this.userService.getAllPerfil();
|
||||
}
|
||||
|
||||
@Patch(':id/activo')
|
||||
toggleActivo(@Param('id') id: number) {
|
||||
return this.userService.toggleActivo(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async Login(@Body() data: Login, @Res() res: Response) {
|
||||
return this.userService.Login(data, res);
|
||||
|
||||
@@ -20,6 +20,22 @@ export class UserService {
|
||||
private perfilRepository: Repository<Perfil>,
|
||||
private jwtService: JwtService,
|
||||
) {}
|
||||
async toggleActivo(id: number) {
|
||||
|
||||
const usuario = await this.userRepository.findOne({
|
||||
where: { id_usuario: id }
|
||||
});
|
||||
|
||||
|
||||
if(!usuario){
|
||||
throw new NotFoundException("no se encontro usuario")
|
||||
}
|
||||
|
||||
|
||||
usuario.activo = usuario.activo === 1 ? 0 : 1;
|
||||
|
||||
return this.userRepository.save(usuario);
|
||||
}
|
||||
|
||||
|
||||
async getactive(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user