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