agregar funciones en servicio de usuarios

This commit is contained in:
Mariela 2022-08-02 21:50:01 -06:00
parent ca19da1d19
commit e2f0b401c5
2 changed files with 12 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import { MongoExceptionFilter } from 'src/MongoExceptionFilter';
@Controller()
export class UsersController {
constructor(private readonly userService: UsersService) {}
constructor(private readonly userService: UsersService) { }
@MessagePattern({ cmd: 'createUser' })
create(@Payload() user: UserDocument) {
@ -117,6 +117,11 @@ export class UsersController {
return this.userService.deleteAdminSystem(user['id']);
}
@MessagePattern({ cmd: 'changeStatus' })
changeStatus(@Payload() body: string) {
let pid = body['id'];
let pstatus = body['status'];
return this.userService.changeStatus(pid, pstatus);
}
}

View File

@ -223,5 +223,10 @@ export class UsersService {
return num_house;
}
async changeStatus(id: string, status: string) {
return this.userModel.findOneAndUpdate({ _id: id }, {status: status}, {
new: true,
});
}
}