editar funcion en backend

This commit is contained in:
Mariela 2022-08-22 09:14:55 -06:00
parent 05600cb829
commit 387cf0ebca
3 changed files with 11 additions and 3 deletions

View File

@ -182,7 +182,7 @@ export class AppController {
@Post('user/updateAdminSystem')
updateAdminSystem(
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono
@Body('_id') _id: string,
@Body('dni') dni: string,
@Body('name') name: string,

View File

@ -74,10 +74,9 @@ export class UsersController {
let dni = id['dni'];
return this.userService.remove(dni);
}
@MessagePattern({ cmd: 'updateAdminSystem' })
updateAdminSystem(@Payload() user: UserDocument) {
return this.userService.update(user._id, user);
return this.userService.updateAdminSystem(user._id, user);
}
//inicio de sesion
@MessagePattern({ cmd: 'loginUser' })

View File

@ -78,6 +78,15 @@ export class UsersService {
});
}
async updateAdminSystem(id: string, user: UserDocument) {
return this.userModel.findOneAndUpdate({ _id: id }, {
name: user['name'], last_name: user['last_name'],
dni:user['dni'], email: user['email'], phone: user['phone']
}, {
new: true,
});
}
/* async remove(id: string) {
return this.userModel.findByIdAndRemove({ _id: id }).exec();
}*/