mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 19:44:55 +00:00
fixed automation dto
This commit is contained in:
@ -1,11 +1,12 @@
|
|||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
import { IsUUID } from 'class-validator';
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
export class AutomationParamDto {
|
export class AutomationParamDto {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description: 'UUID of the automation',
|
description: 'TuyaId of the automation',
|
||||||
example: 'd290f1ee-6c54-4b01-90e6-d701748f0851',
|
example: 'SfFi2Tbn09btes84',
|
||||||
})
|
})
|
||||||
@IsUUID()
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
automationUuid: string;
|
automationUuid: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ export class SceneService {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'An Internal error has been occured',
|
`An Internal error has been occured ${err}`,
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ export class SceneService {
|
|||||||
|
|
||||||
if (!scenesData.length) {
|
if (!scenesData.length) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
`No scenes found for space UUID ${spaceUuid}`,
|
`No scenes found for space UUID ${spaceUuid} with showInHomePage ${showInHomePage} `,
|
||||||
HttpStatus.NOT_FOUND,
|
HttpStatus.NOT_FOUND,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ export class SceneService {
|
|||||||
err.message,
|
err.message,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (err instanceof BadRequestException) {
|
if (err instanceof HttpException) {
|
||||||
throw err;
|
throw err;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
import {
|
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
||||||
BadRequestException,
|
|
||||||
HttpException,
|
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { GetSpaceParam } from '../dtos';
|
import { GetSpaceParam } from '../dtos';
|
||||||
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
|
||||||
import { SpaceService } from './space.service';
|
import { SpaceService } from './space.service';
|
||||||
@ -42,8 +37,8 @@ export class SpaceSceneService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error retrieving scenes:', error);
|
console.error('Error retrieving scenes:', error);
|
||||||
|
|
||||||
if (error instanceof BadRequestException) {
|
if (error instanceof HttpException) {
|
||||||
throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
|
throw error;
|
||||||
} else {
|
} else {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'An error occurred while retrieving scenes',
|
'An error occurred while retrieving scenes',
|
||||||
|
|||||||
@ -112,12 +112,6 @@ export class SubspaceDeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
device.subspace = null;
|
device.subspace = null;
|
||||||
|
|
||||||
console.log(
|
|
||||||
'Starting to save device with null subspace:',
|
|
||||||
new Date(),
|
|
||||||
device.subspace,
|
|
||||||
);
|
|
||||||
const updatedDevice = await this.deviceRepository.save(device);
|
const updatedDevice = await this.deviceRepository.save(device);
|
||||||
|
|
||||||
return new SuccessResponseDto({
|
return new SuccessResponseDto({
|
||||||
@ -217,7 +211,7 @@ export class SubspaceDeviceService {
|
|||||||
} as GetDeviceDetailsInterface;
|
} as GetDeviceDetailsInterface;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new HttpException(
|
throw new HttpException(
|
||||||
'Error fetching device details from Tuya',
|
`Error fetching device details from Tuya for device uuid ${deviceId}.`,
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user