finished 4scene configration endpoints

This commit is contained in:
faris Aljohari
2024-11-16 23:05:06 -06:00
parent 4bb598d8b0
commit eb916b79b4
25 changed files with 429 additions and 15 deletions
@@ -0,0 +1 @@
export * from './scene-device.entity';
@@ -0,0 +1,50 @@
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { SceneDeviceDto } from '../dtos';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { FourSceneSwitchesEnum } from '@app/common/constants/four-scene.enum';
import { DeviceEntity } from '../../device/entities';
import { SceneEntity } from '../../scene/entities';
@Entity({ name: 'scene-device' })
export class SceneDeviceEntity extends AbstractEntity<SceneDeviceDto> {
@Column({
type: 'uuid',
default: () => 'gen_random_uuid()',
nullable: false,
})
public uuid: string;
@ManyToOne(() => DeviceEntity, (device) => device.sceneDevices, {
nullable: false,
})
@JoinColumn({ name: 'device_uuid' })
device: DeviceEntity;
@Column({
nullable: false,
})
sceneUuid: string;
@Column({
nullable: false,
type: 'enum',
enum: FourSceneSwitchesEnum,
})
switchName: FourSceneSwitchesEnum;
@Column({
nullable: false,
})
automationTuyaUuid: string;
@ManyToOne(() => SceneEntity, (scene) => scene.sceneDevices, {
nullable: false,
})
@JoinColumn({ name: 'scene_uuid' })
scene: SceneEntity;
constructor(partial: Partial<SceneDeviceEntity>) {
super();
Object.assign(this, partial);
}
}