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(); + } }