From 11aff885e7a70bbca81bb1de800388f89f1d2dee Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Sun, 21 Aug 2022 04:35:59 -0600 Subject: [PATCH] add plumbing to delete tenant --- api-gateway/src/app.controller.ts | 4 ++++ api-gateway/src/app.service.ts | 12 ++++++++++-- servicio-usuarios/src/users/users.controller.ts | 6 ++++-- servicio-usuarios/src/users/users.service.ts | 1 - 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index 94b6fc14..7e6fe785 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -160,6 +160,10 @@ export class AppController { return this.appService.deleteAdminCommunity(id); } + @Delete('user/deleteTenant/:id') + deleteTenant(@Param('id') id: string) { + return this.appService.deleteTenant(id); + } @Post('user/changeStatus') changeStatusUser( diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 42e9bf22..c3396486 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -54,8 +54,8 @@ export class AppService { } updateUser( - dni: string, - name: string, + dni: string, + name: string, last_name: string, email: string, phone: number, @@ -201,6 +201,14 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + deleteTenant(id: string) { + const pattern = { cmd: 'deleteTenant' }; + const payload = { id: id }; + return this.clientUserApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + inicioSesion(pEmail: string, pPassword: string) { const pattern = { cmd: 'loginUser' }; const payload = { email: pEmail, password: pPassword }; diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index e8f261a4..a13bae7c 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -115,13 +115,15 @@ export class UsersController { return this.userService.deleteAdminSystem(user['id']); } - @MessagePattern({ cmd: 'deleteAdminCommunity' }) deleteAdminCommunity(@Payload() user: any) { return this.userService.deleteAdminCommunity(user['id']); } - + @MessagePattern({ cmd: 'deleteTenant' }) + deleteTenant(@Payload() user: any) { + return this.userService.deleteTenant(user['id']); + } @MessagePattern({ cmd: 'changeStatus' }) changeStatus(@Payload() body: string) { diff --git a/servicio-usuarios/src/users/users.service.ts b/servicio-usuarios/src/users/users.service.ts index 26ae3c95..cbe1689a 100644 --- a/servicio-usuarios/src/users/users.service.ts +++ b/servicio-usuarios/src/users/users.service.ts @@ -189,7 +189,6 @@ export class UsersService { }); } - deleteAdminCommunity(id: string) { return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, { new: true,