mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 10:46:17 +00:00
space cleanup
This commit is contained in:
@ -9,7 +9,7 @@ import { EmailService } from './util/email.service';
|
||||
import { ErrorMessageService } from 'src/error-message/error-message.service';
|
||||
import { TuyaService } from './integrations/tuya/services/tuya.service';
|
||||
import { SceneDeviceRepository } from './modules/scene-device/repositories';
|
||||
import { SpaceProductItemRepository, SpaceRepository } from './modules/space';
|
||||
import { SpaceRepository } from './modules/space';
|
||||
import {
|
||||
SpaceModelRepository,
|
||||
SubspaceModelRepository,
|
||||
@ -26,7 +26,6 @@ import { SubspaceRepository } from './modules/space/repositories/subspace.reposi
|
||||
SubspaceRepository,
|
||||
SubspaceModelRepository,
|
||||
SpaceModelRepository,
|
||||
SpaceProductItemRepository,
|
||||
],
|
||||
exports: [
|
||||
CommonService,
|
||||
|
@ -11,10 +11,7 @@ import { PermissionTypeEntity } from '../modules/permission/entities';
|
||||
import {
|
||||
SpaceEntity,
|
||||
SpaceLinkEntity,
|
||||
SpaceProductItemEntity,
|
||||
SubspaceEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
} from '../modules/space/entities';
|
||||
import { UserSpaceEntity } from '../modules/user/entities';
|
||||
import { DeviceUserPermissionEntity } from '../modules/device/entities';
|
||||
@ -28,7 +25,6 @@ import { CommunityEntity } from '../modules/community/entities';
|
||||
import { DeviceStatusLogEntity } from '../modules/device-status-log/entities';
|
||||
import { SceneEntity, SceneIconEntity } from '../modules/scene/entities';
|
||||
import { SceneDeviceEntity } from '../modules/scene-device/entities';
|
||||
import { SpaceProductEntity } from '../modules/space/entities/space-product.entity';
|
||||
import { ProjectEntity } from '../modules/project/entities';
|
||||
import {
|
||||
SpaceModelEntity,
|
||||
@ -65,7 +61,6 @@ import {
|
||||
SpaceEntity,
|
||||
SpaceLinkEntity,
|
||||
SubspaceEntity,
|
||||
SpaceProductEntity,
|
||||
UserSpaceEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
RoleTypeEntity,
|
||||
@ -81,10 +76,6 @@ import {
|
||||
SpaceModelEntity,
|
||||
SubspaceModelEntity,
|
||||
TagModel,
|
||||
SpaceProductEntity,
|
||||
SpaceProductItemEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
InviteUserEntity,
|
||||
InviteUserSpaceEntity,
|
||||
],
|
||||
|
@ -6,15 +6,10 @@ import {
|
||||
Unique,
|
||||
Index,
|
||||
JoinColumn,
|
||||
OneToOne,
|
||||
} from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
||||
import {
|
||||
SpaceEntity,
|
||||
SpaceProductItemEntity,
|
||||
SubspaceEntity,
|
||||
} from '../../space/entities';
|
||||
import { SpaceEntity, SubspaceEntity } from '../../space/entities';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { DeviceNotificationDto } from '../dtos';
|
||||
@ -79,11 +74,6 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
||||
@OneToMany(() => SceneDeviceEntity, (sceneDevice) => sceneDevice.device, {})
|
||||
sceneDevices: SceneDeviceEntity[];
|
||||
|
||||
@OneToOne(() => SpaceProductItemEntity, (tag) => tag.device, {
|
||||
nullable: true,
|
||||
})
|
||||
public tag?: SpaceProductItemEntity;
|
||||
|
||||
constructor(partial: Partial<DeviceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
@ -2,7 +2,6 @@ import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { ProductDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { SpaceProductEntity } from '../../space/entities/space-product.entity';
|
||||
import { TagModel } from '../../space-model';
|
||||
|
||||
@Entity({ name: 'product' })
|
||||
@ -28,9 +27,6 @@ export class ProductEntity extends AbstractEntity<ProductDto> {
|
||||
})
|
||||
public prodType: string;
|
||||
|
||||
@OneToMany(() => SpaceProductEntity, (spaceProduct) => spaceProduct.product)
|
||||
spaceProducts: SpaceProductEntity[];
|
||||
|
||||
@OneToMany(() => TagModel, (tag) => tag.product)
|
||||
tagModels: TagModel[];
|
||||
|
||||
|
@ -1,4 +1,2 @@
|
||||
export * from './space.dto';
|
||||
export * from './subspace.dto';
|
||||
export * from './space-product-item.dto';
|
||||
export * from './space-product.dto';
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class SpaceProductItemDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
tag: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
spaceProductUuid: string;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
import { SpaceProductItemDto } from './space-product-item.dto';
|
||||
|
||||
export class SpaceProductModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of individual items with specific names for the product',
|
||||
type: [SpaceProductItemDto],
|
||||
})
|
||||
items: SpaceProductItemDto[];
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
export * from './space.entity';
|
||||
export * from './subspace';
|
||||
export * from './space-product.entity';
|
||||
export * from './space-product-item.entity';
|
||||
export * from './space-link.entity';
|
||||
|
@ -1,29 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, OneToOne } from 'typeorm';
|
||||
import { SpaceProductEntity } from './space-product.entity';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemDto } from '../dtos';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'space-product-item' })
|
||||
export class SpaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public tag: string;
|
||||
|
||||
@ManyToOne(() => SpaceProductEntity, (spaceProduct) => spaceProduct.items, {
|
||||
nullable: false,
|
||||
})
|
||||
public spaceProduct: SpaceProductEntity;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@OneToOne(() => DeviceEntity, (device) => device.tag, {
|
||||
nullable: true,
|
||||
})
|
||||
public device?: DeviceEntity;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
|
||||
import { SpaceEntity } from './space.entity';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { SpaceProductItemEntity } from './space-product-item.entity';
|
||||
|
||||
@Entity({ name: 'space-product' })
|
||||
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.spaceProducts, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'space_uuid' })
|
||||
space: SpaceEntity;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.spaceProducts, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'product_uuid' })
|
||||
product: ProductEntity;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@OneToMany(() => SpaceProductItemEntity, (item) => item.spaceProduct, {
|
||||
cascade: true,
|
||||
})
|
||||
public items: SpaceProductItemEntity[];
|
||||
|
||||
constructor(partial: Partial<SpaceProductEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ import { DeviceEntity } from '../../device/entities';
|
||||
import { CommunityEntity } from '../../community/entities';
|
||||
import { SubspaceEntity } from './subspace';
|
||||
import { SpaceLinkEntity } from './space-link.entity';
|
||||
import { SpaceProductEntity } from './space-product.entity';
|
||||
import { SceneEntity } from '../../scene/entities';
|
||||
import { SpaceModelEntity } from '../../space-model';
|
||||
import { InviteUserSpaceEntity } from '../../Invite-user/entities';
|
||||
@ -100,9 +99,6 @@ export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
})
|
||||
public icon: string;
|
||||
|
||||
@OneToMany(() => SpaceProductEntity, (spaceProduct) => spaceProduct.space)
|
||||
spaceProducts: SpaceProductEntity[];
|
||||
|
||||
@OneToMany(() => SceneEntity, (scene) => scene.space)
|
||||
scenes: SceneEntity[];
|
||||
|
||||
|
@ -1,3 +1 @@
|
||||
export * from './subspace.entity';
|
||||
export * from './subspace-product.entity';
|
||||
export * from './subspace-product-item.entity';
|
||||
|
@ -1,32 +0,0 @@
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemDto } from '../../dtos';
|
||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||
import { SubspaceProductEntity } from './subspace-product.entity';
|
||||
|
||||
@Entity({ name: 'subspace-product-item' })
|
||||
export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public tag: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceProductEntity,
|
||||
(subspaceProduct) => subspaceProduct.items,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public subspaceProduct: SubspaceProductEntity;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
constructor(partial: Partial<SubspaceProductItemEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubspaceEntity } from './subspace.entity';
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
||||
import { SpaceProductModelDto } from '../../dtos';
|
||||
|
||||
@Entity({ name: 'subspace-product' })
|
||||
export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@ManyToOne(() => SubspaceEntity, (subspace) => subspace.subspaceProducts, {
|
||||
nullable: false,
|
||||
})
|
||||
public subspace: SubspaceEntity;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.spaceProducts, {
|
||||
nullable: false,
|
||||
})
|
||||
public product: ProductEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.subspaceProduct, {
|
||||
nullable: true,
|
||||
})
|
||||
public items: SubspaceProductItemEntity[];
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import { SubspaceModelEntity } from '@app/common/modules/space-model';
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubspaceDto } from '../../dtos';
|
||||
import { SpaceEntity } from '../space.entity';
|
||||
import { SubspaceProductEntity } from './subspace-product.entity';
|
||||
|
||||
@Entity({ name: 'subspace' })
|
||||
export class SubspaceEntity extends AbstractEntity<SubspaceDto> {
|
||||
@ -41,15 +40,6 @@ export class SubspaceEntity extends AbstractEntity<SubspaceDto> {
|
||||
@JoinColumn({ name: 'subspace_model_uuid' })
|
||||
subSpaceModel?: SubspaceModelEntity;
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceProductEntity,
|
||||
(subspaceProduct) => subspaceProduct.subspace,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public subspaceProducts: SubspaceProductEntity[];
|
||||
|
||||
constructor(partial: Partial<SubspaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
@ -1,11 +1,6 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceProductEntity } from '../entities/space-product.entity';
|
||||
import {
|
||||
SpaceEntity,
|
||||
SpaceLinkEntity,
|
||||
SpaceProductItemEntity,
|
||||
} from '../entities';
|
||||
import { SpaceEntity, SpaceLinkEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceRepository extends Repository<SpaceEntity> {
|
||||
@ -20,16 +15,3 @@ export class SpaceLinkRepository extends Repository<SpaceLinkEntity> {
|
||||
super(SpaceLinkEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class SpaceProductRepository extends Repository<SpaceProductEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceProductEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SpaceProductItemRepository extends Repository<SpaceProductItemEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceProductItemEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import {
|
||||
SubspaceEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
} from '../entities';
|
||||
import { SubspaceEntity } from '../entities';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
@ -12,17 +8,3 @@ export class SubspaceRepository extends Repository<SubspaceEntity> {
|
||||
super(SubspaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SubspaceProductRepository extends Repository<SubspaceProductEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SubspaceProductEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SubspaceProductItemRepository extends Repository<SubspaceProductItemEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SubspaceProductItemEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SpaceEntity, SubspaceEntity, SubspaceProductEntity } from './entities';
|
||||
import { SpaceEntity, SubspaceEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
SpaceEntity,
|
||||
SubspaceEntity,
|
||||
SubspaceProductEntity,
|
||||
]),
|
||||
],
|
||||
imports: [TypeOrmModule.forFeature([SpaceEntity, SubspaceEntity])],
|
||||
})
|
||||
export class SpaceRepositoryModule {}
|
||||
|
Reference in New Issue
Block a user