mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 18:56:22 +00:00
Refactor: Remove group and group-device modules
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceDto } from '../dtos/device.dto';
|
||||
import { GroupDeviceEntity } from '../../group-device/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities';
|
||||
@ -41,11 +40,6 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
||||
},
|
||||
)
|
||||
deviceUserNotification: DeviceNotificationEntity[];
|
||||
@OneToMany(
|
||||
() => GroupDeviceEntity,
|
||||
(userGroupDevices) => userGroupDevices.device,
|
||||
)
|
||||
userGroupDevices: GroupDeviceEntity[];
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.devicesSpaceEntity, {
|
||||
nullable: true,
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class GroupDeviceDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public groupUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.device.dto';
|
@ -1,48 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { GroupDeviceDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { GroupEntity } from '../../group/entities';
|
||||
|
||||
@Entity({ name: 'group-device' })
|
||||
@Unique(['device', 'group'])
|
||||
export class GroupDeviceEntity extends AbstractEntity<GroupDeviceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@Column({
|
||||
type: 'string',
|
||||
nullable: false,
|
||||
})
|
||||
groupUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.userGroupDevices, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(() => GroupEntity, (group) => group.groupDevices, {
|
||||
nullable: false,
|
||||
})
|
||||
group: GroupEntity;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
default: true,
|
||||
})
|
||||
public isActive: boolean;
|
||||
constructor(partial: Partial<GroupDeviceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.device.entity';
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { GroupDeviceEntity } from './entities/group.device.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([GroupDeviceEntity])],
|
||||
})
|
||||
export class GroupDeviceRepositoryModule {}
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { GroupDeviceEntity } from '../entities/group.device.entity';
|
||||
|
||||
@Injectable()
|
||||
export class GroupDeviceRepository extends Repository<GroupDeviceEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(GroupDeviceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.device.repository';
|
@ -1,11 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class GroupDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public groupName: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.dto';
|
@ -1,34 +0,0 @@
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { GroupDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { GroupDeviceEntity } from '../../group-device/entities';
|
||||
|
||||
@Entity({ name: 'group' })
|
||||
export class GroupEntity extends AbstractEntity<GroupDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public groupName: string;
|
||||
|
||||
@OneToMany(() => GroupDeviceEntity, (groupDevice) => groupDevice.group, {
|
||||
cascade: true,
|
||||
})
|
||||
groupDevices: GroupDeviceEntity[];
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
default: true,
|
||||
})
|
||||
public isActive: boolean;
|
||||
constructor(partial: Partial<GroupEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.entity';
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { GroupEntity } from './entities/group.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([GroupEntity])],
|
||||
})
|
||||
export class GroupRepositoryModule {}
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { GroupEntity } from '../entities/group.entity';
|
||||
|
||||
@Injectable()
|
||||
export class GroupRepository extends Repository<GroupEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(GroupEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './group.repository';
|
Reference in New Issue
Block a user