mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 15:37:55 +00:00
Refactor controllers to return UUID of added entities
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user