finshed get room by id api

This commit is contained in:
faris Aljohari
2024-03-12 15:29:25 +03:00
parent dce87ac2b6
commit dc51cbb5ef
3 changed files with 38 additions and 4 deletions

View File

@ -1,5 +1,13 @@
import { RoomService } from '../services/room.service';
import { Body, Controller, Get, Post, Param, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Get,
Post,
UseGuards,
Query,
Param,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
import { AddRoomDto } from '../dtos/add.room.dto';
@ -14,15 +22,24 @@ export class RoomController {
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':homeId')
async userList(@Param('homeId') homeId: string) {
@Get()
async getRoomsByHomeId(@Query('homeId') homeId: string) {
try {
return await this.roomService.getRoomsByHomeId(homeId);
} catch (err) {
throw new Error(err);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':roomId')
async getRoomsByRoomId(@Param('roomId') roomId: string) {
try {
return await this.roomService.getRoomsByRoomId(roomId);
} catch (err) {
throw new Error(err);
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post()