@Patch idactivo

This commit is contained in:
2026-03-05 14:41:19 -05:00
parent 81ad881d6a
commit 3bb95a3d50
2 changed files with 22 additions and 0 deletions
+6
View File
@@ -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);
+16
View File
@@ -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) {