mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-23 17:37:54 +00:00
Refactor controllers to return UUID of added entities
This commit is contained in:
@@ -32,8 +32,8 @@ export class UnitController {
|
||||
@Post()
|
||||
async addUnit(@Body() addUnitDto: AddUnitDto) {
|
||||
try {
|
||||
await this.unitService.addUnit(addUnitDto);
|
||||
return { message: 'Unit added successfully' };
|
||||
const unit = await this.unitService.addUnit(addUnitDto);
|
||||
return { message: 'Unit added successfully', uuid: unit.uuid };
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
|
||||
@@ -35,11 +35,12 @@ export class UnitService {
|
||||
},
|
||||
});
|
||||
|
||||
await this.spaceRepository.save({
|
||||
const unit = await this.spaceRepository.save({
|
||||
spaceName: addUnitDto.unitName,
|
||||
parent: { uuid: addUnitDto.floorUuid },
|
||||
spaceType: { uuid: spaceType.uuid },
|
||||
});
|
||||
return unit;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user