updated spaceUuid

This commit is contained in:
hannathkadher
2024-10-30 23:50:52 +04:00
parent 689d42cf1e
commit f1c07360cb
4 changed files with 23 additions and 15 deletions

View File

@ -47,7 +47,8 @@ export class SceneEntity extends AbstractEntity<SceneDto> {
@Column({
nullable: false,
})
unitUuid: string;
spaceUuid: string;
@Column({
nullable: false,
})

View File

@ -192,10 +192,10 @@ export class AutomationService {
}
}
async getTapToRunSceneDetailsTuya(
sceneId: string,
sceneUuid: string,
): Promise<AutomationDetailsResult> {
try {
const path = `/v2.0/cloud/scene/rule/${sceneId}`;
const path = `/v2.0/cloud/scene/rule/${sceneUuid}`;
const response = await this.tuya.request({
method: 'GET',
path,

View File

@ -60,7 +60,7 @@ export class SceneController {
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Delete('tap-to-run/:unitUuid/:sceneId')
@Delete('tap-to-run/:unitUuid/:sceneUuid')
async deleteTapToRunScene(@Param() param: DeleteSceneParamDto) {
await this.sceneService.deleteTapToRunScene(param);
return {
@ -70,7 +70,7 @@ export class SceneController {
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post('tap-to-run/trigger/:sceneId')
@Post('tap-to-run/trigger/:sceneUuid')
async triggerTapToRunScene(@Param() param: SceneParamDto) {
await this.sceneService.triggerTapToRunScene(param.sceneUuid);
return {
@ -82,7 +82,7 @@ export class SceneController {
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('tap-to-run/details/:sceneId')
@Get('tap-to-run/details/:sceneUuid')
async getTapToRunSceneDetails(@Param() param: SceneParamDto) {
const tapToRunScenes = await this.sceneService.getTapToRunSceneDetails(
param.sceneUuid,
@ -92,7 +92,7 @@ export class SceneController {
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Put('tap-to-run/:sceneId')
@Put('tap-to-run/:sceneUuid')
async updateTapToRunScene(
@Body() updateSceneTapToRunDto: UpdateSceneTapToRunDto,
@Param() param: SceneParamDto,
@ -108,6 +108,7 @@ export class SceneController {
data: tapToRunScene,
};
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post('icon')

View File

@ -113,7 +113,7 @@ export class SceneService {
: defaultSceneIcon.uuid,
},
showInHomePage: addSceneTapToRunDto.showInHomePage,
unitUuid: spaceUuid ? spaceUuid : addSceneTapToRunDto.spaceUuid,
spaceUuid: spaceUuid ? spaceUuid : addSceneTapToRunDto.spaceUuid,
});
}
return {
@ -124,7 +124,7 @@ export class SceneService {
throw err; // Re-throw BadRequestException
} else {
throw new HttpException(
err.message || 'Scene not found',
err.message || `Scene not found`,
err.status || HttpStatus.NOT_FOUND,
);
}
@ -160,13 +160,14 @@ export class SceneService {
}
}
}
async getTapToRunSceneByUnit(unitUuid: string, inHomePage: GetSceneDto) {
async getTapToRunSceneByUnit(spaceUuid: string, inHomePage: GetSceneDto) {
try {
const showInHomePage = inHomePage?.showInHomePage;
const scenesData = await this.sceneRepository.find({
where: {
unitUuid,
spaceUuid,
...(showInHomePage ? { showInHomePage } : {}),
},
});
@ -180,6 +181,7 @@ export class SceneService {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { actions, ...rest } = sceneData;
return {
uuid: scene.uuid,
...rest,
};
}),
@ -197,6 +199,7 @@ export class SceneService {
}
}
}
async deleteTapToRunScene(param: DeleteSceneParamDto, spaceTuyaId = null) {
const { spaceUuid, sceneUuid } = param;
try {
@ -317,7 +320,10 @@ export class SceneService {
if (err instanceof BadRequestException) {
throw err; // Re-throw BadRequestException
} else {
throw new HttpException('Scene not found', HttpStatus.NOT_FOUND);
throw new HttpException(
`Scene not found for ${sceneId}`,
HttpStatus.NOT_FOUND,
);
}
}
}
@ -375,7 +381,7 @@ export class SceneService {
const newTapToRunScene = await this.addTapToRunScene(
addSceneTapToRunDto,
spaceTuyaId.spaceId,
scene.unitUuid,
scene.spaceUuid,
);
const param: DeleteSceneParamDto = {
@ -394,7 +400,7 @@ export class SceneService {
sceneIcon: {
uuid: addSceneTapToRunDto.iconUuid,
},
unitUuid: scene.unitUuid,
spaceUuid: scene.spaceUuid,
},
);
return newTapToRunScene;
@ -404,7 +410,7 @@ export class SceneService {
throw err; // Re-throw BadRequestException
} else {
throw new HttpException(
err.message || 'Scene not found',
err.message || `Scene not found for id ${sceneUuid}`,
err.status || HttpStatus.NOT_FOUND,
);
}