Refactor controllers to return UUID of added entities

This commit is contained in:
faris Aljohari
2024-05-01 10:34:07 +03:00
parent 229909f959
commit d146cce1bb
10 changed files with 21 additions and 15 deletions
+2 -2
View File
@@ -32,8 +32,8 @@ export class FloorController {
@Post()
async addFloor(@Body() addFloorDto: AddFloorDto) {
try {
await this.floorService.addFloor(addFloorDto);
return { message: 'Floor added successfully' };
const floor = await this.floorService.addFloor(addFloorDto);
return { message: 'Floor added successfully', uuid: floor.uuid };
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
+2 -1
View File
@@ -35,11 +35,12 @@ export class FloorService {
},
});
await this.spaceRepository.save({
const floor = await this.spaceRepository.save({
spaceName: addFloorDto.floorName,
parent: { uuid: addFloorDto.buildingUuid },
spaceType: { uuid: spaceType.uuid },
});
return floor;
} catch (err) {
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
}