Add endpoint to rename floor by UUID

This commit is contained in:
faris Aljohari
2024-04-14 10:40:03 +03:00
parent a9be4d315a
commit 8dca50b24d
4 changed files with 95 additions and 1 deletions
+27
View File
@@ -7,6 +7,7 @@ import {
HttpStatus,
Param,
Post,
Put,
Query,
UseGuards,
} from '@nestjs/common';
@@ -14,6 +15,7 @@ import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { JwtAuthGuard } from '../../../libs/common/src/guards/jwt.auth.guard';
import { AddFloorDto } from '../dtos/add.floor.dto';
import { GetFloorChildDto } from '../dtos/get.floor.dto';
import { UpdateFloorNameDto } from '../dtos/update.floor.dto';
@ApiTags('Floor Module')
@Controller({
@@ -99,4 +101,29 @@ export class FloorController {
}
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Put('rename/:floorUuid')
async renameFloorByUuid(
@Param('floorUuid') floorUuid: string,
@Body() updateFloorNameDto: UpdateFloorNameDto,
) {
try {
const floor = await this.floorService.renameFloorByUuid(
floorUuid,
updateFloorNameDto,
);
return floor;
} catch (error) {
if (error.status === 404) {
throw new HttpException('Floor not found', HttpStatus.NOT_FOUND);
} else {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}
}