mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-25 23:07:55 +00:00
finished scene icons
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from './scene.entity';
|
||||
@@ -0,0 +1,57 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SceneDto, SceneIconDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
|
||||
// Define SceneIconEntity before SceneEntity
|
||||
@Entity({ name: 'scene-icon' })
|
||||
export class SceneIconEntity extends AbstractEntity<SceneIconDto> {
|
||||
@Column({
|
||||
nullable: true,
|
||||
type: 'text',
|
||||
})
|
||||
public icon: string;
|
||||
|
||||
@OneToMany(
|
||||
() => SceneEntity,
|
||||
(scenesIconEntity) => scenesIconEntity.sceneIcon,
|
||||
)
|
||||
scenesIconEntity: SceneEntity[];
|
||||
|
||||
constructor(partial: Partial<SceneIconEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'scene' })
|
||||
export class SceneEntity extends AbstractEntity<SceneDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
sceneTuyaUuid: string;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
unitUuid: string;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
showInHomePage: boolean;
|
||||
|
||||
@ManyToOne(() => SceneIconEntity, (icon) => icon.scenesIconEntity, {
|
||||
nullable: false,
|
||||
})
|
||||
sceneIcon: SceneIconEntity;
|
||||
|
||||
constructor(partial: Partial<SceneEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user