mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 18:24:54 +00:00
finished add default icon for scene
This commit is contained in:
@ -74,10 +74,10 @@ export class AddSceneTapToRunDto {
|
||||
public unitUuid: string;
|
||||
@ApiProperty({
|
||||
description: 'Icon UUID',
|
||||
required: true,
|
||||
required: false,
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
public iconUuid: string;
|
||||
@ApiProperty({
|
||||
description: 'show in home page',
|
||||
|
||||
@ -28,6 +28,7 @@ import {
|
||||
SceneIconRepository,
|
||||
SceneRepository,
|
||||
} from '@app/common/modules/scene/repositories';
|
||||
import { SceneIconType } from '@app/common/constants/secne-icon-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class SceneService {
|
||||
@ -101,10 +102,16 @@ export class SceneService {
|
||||
if (!response.success) {
|
||||
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
|
||||
} else {
|
||||
const defaultSceneIcon = await this.sceneIconRepository.findOne({
|
||||
where: { iconType: SceneIconType.Default },
|
||||
});
|
||||
|
||||
await this.sceneRepository.save({
|
||||
sceneTuyaUuid: response.result.id,
|
||||
sceneIcon: {
|
||||
uuid: addSceneTapToRunDto.iconUuid,
|
||||
uuid: addSceneTapToRunDto.iconUuid
|
||||
? addSceneTapToRunDto.iconUuid
|
||||
: defaultSceneIcon.uuid,
|
||||
},
|
||||
showInHomePage: addSceneTapToRunDto.showInHomePage,
|
||||
unitUuid: unitUuid ? unitUuid : addSceneTapToRunDto.unitUuid,
|
||||
@ -174,7 +181,7 @@ export class SceneService {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { actions, ...rest } = sceneData;
|
||||
return {
|
||||
rest,
|
||||
...rest,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user