mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 02:15:21 +00:00
remove device-tag relation
This commit is contained in:
@ -6,10 +6,11 @@ import {
|
|||||||
Unique,
|
Unique,
|
||||||
Index,
|
Index,
|
||||||
JoinColumn,
|
JoinColumn,
|
||||||
|
OneToOne,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
||||||
import { SpaceEntity, SubspaceEntity } from '../../space/entities';
|
import { SpaceEntity, SubspaceEntity, TagEntity } from '../../space/entities';
|
||||||
import { ProductEntity } from '../../product/entities';
|
import { ProductEntity } from '../../product/entities';
|
||||||
import { UserEntity } from '../../user/entities';
|
import { UserEntity } from '../../user/entities';
|
||||||
import { DeviceNotificationDto } from '../dtos';
|
import { DeviceNotificationDto } from '../dtos';
|
||||||
@ -74,6 +75,11 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
|||||||
@OneToMany(() => SceneDeviceEntity, (sceneDevice) => sceneDevice.device, {})
|
@OneToMany(() => SceneDeviceEntity, (sceneDevice) => sceneDevice.device, {})
|
||||||
sceneDevices: SceneDeviceEntity[];
|
sceneDevices: SceneDeviceEntity[];
|
||||||
|
|
||||||
|
@OneToOne(() => TagEntity, (tag) => tag.device, {
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
tag: TagEntity;
|
||||||
|
|
||||||
constructor(partial: Partial<DeviceEntity>) {
|
constructor(partial: Partial<DeviceEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
@ -102,6 +108,7 @@ export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationD
|
|||||||
nullable: false,
|
nullable: false,
|
||||||
})
|
})
|
||||||
user: UserEntity;
|
user: UserEntity;
|
||||||
|
|
||||||
constructor(partial: Partial<DeviceNotificationEntity>) {
|
constructor(partial: Partial<DeviceNotificationEntity>) {
|
||||||
super();
|
super();
|
||||||
Object.assign(this, partial);
|
Object.assign(this, partial);
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
import { Entity, Column, ManyToOne, JoinColumn, Unique } from 'typeorm';
|
import {
|
||||||
|
Entity,
|
||||||
|
Column,
|
||||||
|
ManyToOne,
|
||||||
|
JoinColumn,
|
||||||
|
Unique,
|
||||||
|
OneToOne,
|
||||||
|
} from 'typeorm';
|
||||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||||
import { ProductEntity } from '../../product/entities';
|
import { ProductEntity } from '../../product/entities';
|
||||||
import { TagDto } from '../dtos';
|
import { TagDto } from '../dtos';
|
||||||
import { TagModel } from '../../space-model/entities/tag-model.entity';
|
import { TagModel } from '../../space-model/entities/tag-model.entity';
|
||||||
import { SpaceEntity } from './space.entity';
|
import { SpaceEntity } from './space.entity';
|
||||||
import { SubspaceEntity } from './subspace';
|
import { SubspaceEntity } from './subspace';
|
||||||
|
import { DeviceEntity } from '../../device/entities';
|
||||||
|
|
||||||
@Entity({ name: 'tag' })
|
@Entity({ name: 'tag' })
|
||||||
@Unique(['tag', 'product', 'space', 'subspace'])
|
@Unique(['tag', 'product', 'space', 'subspace'])
|
||||||
@ -36,4 +44,9 @@ export class TagEntity extends AbstractEntity<TagDto> {
|
|||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
public disabled: boolean;
|
public disabled: boolean;
|
||||||
|
|
||||||
|
@OneToOne(() => DeviceEntity, (device) => device.tag, {
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
device: DeviceEntity;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ export class TagService {
|
|||||||
queryRunner.manager.update(
|
queryRunner.manager.update(
|
||||||
this.tagRepository.target,
|
this.tagRepository.target,
|
||||||
{ uuid: id },
|
{ uuid: id },
|
||||||
{ disabled: true },
|
{ disabled: true, device: null },
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user