mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|
import { PresenceSensorDto } from '../dtos';
|
|
import { DeviceEntity } from '../../device/entities/device.entity';
|
|
import { SpaceEntity } from '../../space/entities/space.entity';
|
|
|
|
@Entity({ name: 'presence-sensor-daily-device-detection' })
|
|
@Unique(['deviceUuid', 'eventDate'])
|
|
export class PresenceSensorDailyDeviceEntity extends AbstractEntity<PresenceSensorDto> {
|
|
@Column({ nullable: false })
|
|
public deviceUuid: string;
|
|
|
|
@Column({ nullable: false, type: 'date' })
|
|
public eventDate: string;
|
|
|
|
@Column({ nullable: false })
|
|
public CountMotionDetected: number;
|
|
|
|
@Column({ nullable: false })
|
|
public CountPresenceDetected: number;
|
|
|
|
@Column({ nullable: false })
|
|
public CountTotalPresenceDetected: number;
|
|
|
|
@ManyToOne(() => DeviceEntity, (device) => device.presenceSensorDaily)
|
|
device: DeviceEntity;
|
|
|
|
constructor(partial: Partial<PresenceSensorDailyDeviceEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|
|
@Entity({ name: 'presence-sensor-daily-space-detection' })
|
|
@Unique(['spaceUuid', 'eventDate'])
|
|
export class PresenceSensorDailySpaceEntity extends AbstractEntity<PresenceSensorDto> {
|
|
@Column({ nullable: false })
|
|
public spaceUuid: string;
|
|
|
|
@Column({ nullable: false, type: 'date' })
|
|
public eventDate: string;
|
|
|
|
@Column({ nullable: false })
|
|
public CountMotionDetected: number;
|
|
|
|
@Column({ nullable: false })
|
|
public CountPresenceDetected: number;
|
|
|
|
@Column({ nullable: false })
|
|
public CountTotalPresenceDetected: number;
|
|
|
|
@ManyToOne(() => SpaceEntity, (space) => space.presenceSensorDaily)
|
|
space: SpaceEntity;
|
|
|
|
constructor(partial: Partial<PresenceSensorDailySpaceEntity>) {
|
|
super();
|
|
Object.assign(this, partial);
|
|
}
|
|
}
|