From 1481cc2c4edd485cfd4332434dc223d820012e37 Mon Sep 17 00:00:00 2001 From: Traym17 <51390112+Traym17@users.noreply.github.com> Date: Wed, 31 Aug 2022 22:11:13 -0600 Subject: [PATCH] =?UTF-8?q?Reservaci=C3=B3n=20por=20id=20de=20inquilino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-gateway/src/app.controller.ts | 6 ++++++ api-gateway/src/app.service.ts | 8 ++++++++ mobile-ui/App.js | 2 +- mobile-ui/components/Reservas.js | 4 +++- servicio-reservaciones/package-lock.json | 1 - .../src/reservations/reservations.controller.ts | 6 ++++++ .../src/reservations/reservations.service.ts | 4 ++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index f865c1fd..8014ab26 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -600,4 +600,10 @@ export class AppController { html(@Body('email') email: string, @Body('name') name: string) { return this.appService.html(email, name); } + + @Get('reservation/findReservationUser/:id') + findReservationUser(@Param('id') paramComment: string) { + return this.appService.findReservationUser(paramComment); + } + } diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index 605c4688..74c70b9b 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -786,4 +786,12 @@ export class AppService { return pass; } + + findReservationUser(paramGuestId: string) { + const pattern = { cmd: 'findReservationUser' }; + const payload = { id: paramGuestId }; + return this.clientReservationApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } } diff --git a/mobile-ui/App.js b/mobile-ui/App.js index f7b25e24..da04b65e 100644 --- a/mobile-ui/App.js +++ b/mobile-ui/App.js @@ -72,7 +72,7 @@ export default function App() { - { @@ -26,7 +28,7 @@ export default function Reservas({navigation}) { setIsRequesting(true); try { - const jsonResponse = await fetch(`${API.BASE_URL}/reservation/allReservations`, { + const jsonResponse = await fetch(`${API.BASE_URL}/reservation/findReservationUser/`+`${id}`, { method: "GET", headers: { 'Content-Type': 'application/json' diff --git a/servicio-reservaciones/package-lock.json b/servicio-reservaciones/package-lock.json index 37e3caca..9e9de38f 100644 --- a/servicio-reservaciones/package-lock.json +++ b/servicio-reservaciones/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "servicio-reservaciones", "version": "0.0.1", "license": "UNLICENSED", "dependencies": { diff --git a/servicio-reservaciones/src/reservations/reservations.controller.ts b/servicio-reservaciones/src/reservations/reservations.controller.ts index 49621768..038b1433 100644 --- a/servicio-reservaciones/src/reservations/reservations.controller.ts +++ b/servicio-reservaciones/src/reservations/reservations.controller.ts @@ -38,4 +38,10 @@ export class ReservationsController { let _id = id['id']; return this.reservationsService.remove(_id); } + + @MessagePattern({ cmd: 'findReservationUser' }) + findReservationUser(@Payload() id: string) { + let _id = id['id']; + return this.reservationsService.findReservationUser(_id); + } } diff --git a/servicio-reservaciones/src/reservations/reservations.service.ts b/servicio-reservaciones/src/reservations/reservations.service.ts index 45382f50..9c4130fa 100644 --- a/servicio-reservaciones/src/reservations/reservations.service.ts +++ b/servicio-reservaciones/src/reservations/reservations.service.ts @@ -45,4 +45,8 @@ export class ReservationsService { new: true, }); } + + async findReservationUser(id: string): Promise { + return this.reservationModel.find({user_id:id}).setOptions({ sanitizeFilter: true }).exec(); + } }