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
@@ -30,8 +30,8 @@ export class RoomController {
@Post()
async addRoom(@Body() addRoomDto: AddRoomDto) {
try {
await this.roomService.addRoom(addRoomDto);
return { message: 'Room added successfully' };
const room = await this.roomService.addRoom(addRoomDto);
return { message: 'Room added successfully', uuid: room.uuid };
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
+2 -1
View File
@@ -32,11 +32,12 @@ export class RoomService {
},
});
await this.spaceRepository.save({
const room = await this.spaceRepository.save({
spaceName: addRoomDto.roomName,
parent: { uuid: addRoomDto.unitUuid },
spaceType: { uuid: spaceType.uuid },
});
return room;
} catch (err) {
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
}