mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 19:54:54 +00:00
Refactor SceneService to update device uuid in actions
This commit is contained in:
@ -241,12 +241,30 @@ export class SceneService {
|
|||||||
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
|
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
const responseData = convertKeysToCamelCase(response.result);
|
const responseData = convertKeysToCamelCase(response.result);
|
||||||
|
const actions = responseData.actions.map((action) => {
|
||||||
|
return {
|
||||||
|
...action,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const action of actions) {
|
||||||
|
if (action.actionExecutor === 'device_issue') {
|
||||||
|
const device = await this.deviceService.getDeviceByDeviceTuyaUuid(
|
||||||
|
action.entityId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (device) {
|
||||||
|
action.entityId = device.uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: responseData.id,
|
id: responseData.id,
|
||||||
name: responseData.name,
|
name: responseData.name,
|
||||||
status: responseData.status,
|
status: responseData.status,
|
||||||
type: 'tap_to_run',
|
type: 'tap_to_run',
|
||||||
actions: responseData.actions,
|
actions: actions,
|
||||||
...(withSpaceId && { spaceId: responseData.spaceId }),
|
...(withSpaceId && { spaceId: responseData.spaceId }),
|
||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user