mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 11:15:14 +00:00
clean model entities
This commit is contained in:
@ -12,10 +12,7 @@ import { SceneDeviceRepository } from './modules/scene-device/repositories';
|
||||
import { SpaceProductItemRepository, SpaceRepository } from './modules/space';
|
||||
import {
|
||||
SpaceModelRepository,
|
||||
SpaceProductModelRepository,
|
||||
SubspaceModelRepository,
|
||||
SubspaceProductItemModelRepository,
|
||||
SubspaceProductModelRepository,
|
||||
} from './modules/space-model';
|
||||
import { SubspaceRepository } from './modules/space/repositories/subspace.repository';
|
||||
@Module({
|
||||
@ -28,10 +25,7 @@ import { SubspaceRepository } from './modules/space/repositories/subspace.reposi
|
||||
SpaceRepository,
|
||||
SubspaceRepository,
|
||||
SubspaceModelRepository,
|
||||
SubspaceProductModelRepository,
|
||||
SubspaceProductItemModelRepository,
|
||||
SpaceModelRepository,
|
||||
SpaceProductModelRepository,
|
||||
SpaceProductItemRepository,
|
||||
],
|
||||
exports: [
|
||||
@ -45,10 +39,7 @@ import { SubspaceRepository } from './modules/space/repositories/subspace.reposi
|
||||
SpaceRepository,
|
||||
SubspaceRepository,
|
||||
SubspaceModelRepository,
|
||||
SubspaceProductModelRepository,
|
||||
SubspaceProductItemModelRepository,
|
||||
SpaceModelRepository,
|
||||
SpaceProductModelRepository,
|
||||
],
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
|
@ -32,11 +32,8 @@ import { SpaceProductEntity } from '../modules/space/entities/space-product.enti
|
||||
import { ProjectEntity } from '../modules/project/entities';
|
||||
import {
|
||||
SpaceModelEntity,
|
||||
SpaceProductItemModelEntity,
|
||||
SpaceProductModelEntity,
|
||||
SubspaceModelEntity,
|
||||
SubspaceProductItemModelEntity,
|
||||
SubspaceProductModelEntity,
|
||||
TagModel,
|
||||
} from '../modules/space-model/entities';
|
||||
import {
|
||||
InviteUserEntity,
|
||||
@ -82,13 +79,10 @@ import {
|
||||
SceneIconEntity,
|
||||
SceneDeviceEntity,
|
||||
SpaceModelEntity,
|
||||
SpaceProductModelEntity,
|
||||
SpaceProductItemModelEntity,
|
||||
SubspaceModelEntity,
|
||||
TagModel,
|
||||
SpaceProductEntity,
|
||||
SpaceProductItemEntity,
|
||||
SubspaceProductModelEntity,
|
||||
SubspaceProductItemModelEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
InviteUserEntity,
|
||||
|
@ -3,8 +3,7 @@ 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 { SpaceProductModelEntity } from '../../space-model/entities';
|
||||
import { SubspaceProductModelEntity } from '../../space-model/entities/subspace-model/subspace-product-model.entity';
|
||||
import { TagModel } from '../../space-model';
|
||||
|
||||
@Entity({ name: 'product' })
|
||||
export class ProductEntity extends AbstractEntity<ProductDto> {
|
||||
@ -32,17 +31,8 @@ export class ProductEntity extends AbstractEntity<ProductDto> {
|
||||
@OneToMany(() => SpaceProductEntity, (spaceProduct) => spaceProduct.product)
|
||||
spaceProducts: SpaceProductEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductModelEntity,
|
||||
(spaceProductModel) => spaceProductModel.product,
|
||||
)
|
||||
spaceProductModels: SpaceProductModelEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceProductModelEntity,
|
||||
(subspaceProductModel) => subspaceProductModel.product,
|
||||
)
|
||||
subpaceProductModels: SubspaceProductModelEntity[];
|
||||
@OneToMany(() => TagModel, (tag) => tag.product)
|
||||
tagModels: TagModel[];
|
||||
|
||||
@OneToMany(
|
||||
() => DeviceEntity,
|
||||
|
@ -1,4 +1,2 @@
|
||||
export * from './subspace-model';
|
||||
export * from './space-model.dto';
|
||||
export * from './space-product-item-model.dto';
|
||||
export * from './space-product-model.dto';
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class SpaceProductItemModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
tag: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
spaceProductModelUuid: string;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { SpaceProductItemModelDto } from './space-product-item-model.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: [SpaceProductItemModelDto],
|
||||
})
|
||||
items: SpaceProductItemModelDto[];
|
||||
}
|
@ -1,3 +1 @@
|
||||
export * from './subspace-model.dto';
|
||||
export * from './subspace-product-item-model.dto';
|
||||
export * from './subspace-product-model.dto';
|
||||
|
@ -1,15 +0,0 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class SubspaceProductItemModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
tag: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
subspaceProductModelUuid: string;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { SubspaceProductItemModelDto } from './subspace-product-item-model.dto';
|
||||
|
||||
export class SubpaceProductModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of individual items with specific names for the product',
|
||||
type: [SubspaceProductItemModelDto],
|
||||
})
|
||||
items: SubspaceProductItemModelDto[];
|
||||
}
|
21
libs/common/src/modules/space-model/dtos/tag-model.dto.ts
Normal file
21
libs/common/src/modules/space-model/dtos/tag-model.dto.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class TagModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public name: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public productUuid: string;
|
||||
|
||||
@IsString()
|
||||
spaceModelUuid: string;
|
||||
|
||||
@IsString()
|
||||
subspaceModelUuid: string;
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
export * from './space-model.entity';
|
||||
export * from './space-product-item-model.entity';
|
||||
export * from './space-product-model.entity';
|
||||
export * from './subspace-model';
|
||||
export * from './tag-model.entity';
|
||||
|
@ -9,9 +9,9 @@ import {
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceModelDto } from '../dtos';
|
||||
import { SubspaceModelEntity } from './subspace-model';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { ProjectEntity } from '../../project/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { TagModel } from './tag-model.entity';
|
||||
|
||||
@Entity({ name: 'space-model' })
|
||||
@Unique(['modelName', 'project'])
|
||||
@ -51,17 +51,11 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
||||
)
|
||||
public subspaceModels: SubspaceModelEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductModelEntity,
|
||||
(productModel) => productModel.spaceModel,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public spaceProductModels: SpaceProductModelEntity[];
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceModel, {
|
||||
cascade: true,
|
||||
})
|
||||
public spaces: SpaceEntity[];
|
||||
|
||||
@OneToMany(() => TagModel, (tag) => tag.spaceModel)
|
||||
tags: TagModel[];
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemModelDto } from '../dtos';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { SpaceProductItemEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-product-item-model' })
|
||||
export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItemModelDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public tag: string;
|
||||
|
||||
@ManyToOne(
|
||||
() => SpaceProductModelEntity,
|
||||
(spaceProductModel) => spaceProductModel.items,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public spaceProductModel: SpaceProductModelEntity;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductItemEntity,
|
||||
(spaceProductItem) => spaceProductItem.spaceProductItemModel,
|
||||
{ cascade: true },
|
||||
)
|
||||
public items: SpaceProductItemEntity[];
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { SpaceModelEntity } from './space-model.entity';
|
||||
import { SpaceProductItemModelEntity } from './space-product-item-model.entity';
|
||||
import { SpaceProductModelDto } from '../dtos';
|
||||
import { SpaceProductEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-product-model' })
|
||||
export class SpaceProductModelEntity extends AbstractEntity<SpaceProductModelDto> {
|
||||
@ManyToOne(
|
||||
() => SpaceModelEntity,
|
||||
(spaceModel) => spaceModel.spaceProductModels,
|
||||
{
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
)
|
||||
public spaceModel: SpaceModelEntity;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.spaceProductModels, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public product: ProductEntity;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductItemModelEntity,
|
||||
(item) => item.spaceProductModel,
|
||||
{
|
||||
cascade: true,
|
||||
},
|
||||
)
|
||||
public items: SpaceProductItemModelEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SpaceProductEntity,
|
||||
(spaceProduct) => spaceProduct.spaceProductModel,
|
||||
{
|
||||
cascade: true,
|
||||
},
|
||||
)
|
||||
public spaceProducts: SpaceProductEntity[];
|
||||
}
|
@ -1,3 +1,2 @@
|
||||
export * from './subspace-model.entity';
|
||||
export * from './subspace-product-item-model.entity';
|
||||
export * from './subspace-product-model.entity';
|
||||
|
@ -3,7 +3,7 @@ import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import { SubSpaceModelDto } from '../../dtos';
|
||||
import { SpaceModelEntity } from '../space-model.entity';
|
||||
import { SubspaceEntity } from '@app/common/modules/space/entities';
|
||||
import { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
||||
import { TagModel } from '../tag-model.entity';
|
||||
|
||||
@Entity({ name: 'subspace-model' })
|
||||
@Unique(['subspaceName', 'spaceModel'])
|
||||
@ -41,12 +41,6 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceProductModelEntity,
|
||||
(productModel) => productModel.subspaceModel,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public productModels: SubspaceProductModelEntity[];
|
||||
@OneToMany(() => TagModel, (tag) => tag.subspaceModel)
|
||||
tags: TagModel[];
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubspaceProductItemModelDto } from '../../dtos';
|
||||
import { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
||||
import { SubspaceProductItemEntity } from '@app/common/modules/space/entities';
|
||||
|
||||
@Entity({ name: 'subspace-product-item-model' })
|
||||
export class SubspaceProductItemModelEntity extends AbstractEntity<SubspaceProductItemModelDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public tag: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceProductModelEntity,
|
||||
(productModel) => productModel.itemModels,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public subspaceProductModel: SubspaceProductModelEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.subspaceProduct, {
|
||||
nullable: true,
|
||||
})
|
||||
items: SubspaceProductItemEntity[];
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
import { Entity, Column, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubpaceProductModelDto } from '../../dtos';
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { SubspaceModelEntity } from './subspace-model.entity';
|
||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||
import { SubspaceProductEntity } from '@app/common/modules/space/entities';
|
||||
import { SubspaceProductItemModelEntity } from './subspace-product-item-model.entity';
|
||||
|
||||
@Entity({ name: 'subspace-product-model' })
|
||||
export class SubspaceProductModelEntity extends AbstractEntity<SubpaceProductModelDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: false,
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceModelEntity,
|
||||
(spaceModel) => spaceModel.productModels,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public subspaceModel: SubspaceModelEntity;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.subpaceProductModels, {
|
||||
nullable: false,
|
||||
})
|
||||
public product: ProductEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductEntity, (product) => product.model, {
|
||||
nullable: true,
|
||||
})
|
||||
public subspaceProducts: SubspaceProductEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceProductItemModelEntity,
|
||||
(product) => product.subspaceProductModel,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public itemModels: SubspaceProductItemModelEntity[];
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
import { Column, Entity, JoinColumn, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { TagModelDto } from '../dtos/tag-model.dto';
|
||||
import { SpaceModelEntity } from './space-model.entity';
|
||||
import { SubspaceModelEntity } from './subspace-model';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
|
||||
@Entity({ name: 'tag_model' })
|
||||
@Unique(['tag', 'product', 'spaceModel', 'subspaceModel'])
|
||||
export class TagModel extends AbstractEntity<TagModelDto> {
|
||||
@Column({ type: 'varchar', length: 255 })
|
||||
tag: string;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.tagModels, {
|
||||
nullable: false,
|
||||
})
|
||||
@JoinColumn({ name: 'product_id' })
|
||||
product: ProductEntity;
|
||||
|
||||
@ManyToOne(() => SpaceModelEntity, (space) => space.tags, { nullable: true })
|
||||
@JoinColumn({ name: 'space_id' })
|
||||
spaceModel: SpaceModelEntity;
|
||||
|
||||
@ManyToOne(() => SubspaceModelEntity, (subspace) => subspace.tags, {
|
||||
nullable: true,
|
||||
})
|
||||
@JoinColumn({ name: 'subspace_id' })
|
||||
subspaceModel: SubspaceModelEntity;
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
SpaceModelEntity,
|
||||
SpaceProductItemModelEntity,
|
||||
SpaceProductModelEntity,
|
||||
SubspaceModelEntity,
|
||||
SubspaceProductItemModelEntity,
|
||||
SubspaceProductModelEntity,
|
||||
} from '../entities';
|
||||
import { SpaceModelEntity, SubspaceModelEntity, TagModel } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceModelRepository extends Repository<SpaceModelEntity> {
|
||||
@ -23,28 +16,8 @@ export class SubspaceModelRepository extends Repository<SubspaceModelEntity> {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SubspaceProductModelRepository extends Repository<SubspaceProductModelEntity> {
|
||||
export class TagModelRepository extends Repository<TagModel> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SubspaceProductModelEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SubspaceProductItemModelRepository extends Repository<SubspaceProductItemModelEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SubspaceProductItemModelEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SpaceProductModelRepository extends Repository<SpaceProductModelEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceProductModelEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class SpaceProductItemModelRepository extends Repository<SpaceProductItemModelEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceProductItemModelEntity, dataSource.createEntityManager());
|
||||
super(TagModel, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import {
|
||||
SpaceModelEntity,
|
||||
SpaceProductItemModelEntity,
|
||||
SpaceProductModelEntity,
|
||||
SubspaceModelEntity,
|
||||
} from './entities';
|
||||
import { SpaceModelEntity, SubspaceModelEntity, TagModel } from './entities';
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
@Module({
|
||||
@ -12,12 +7,7 @@ import { Module } from '@nestjs/common';
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
SpaceModelEntity,
|
||||
SubspaceModelEntity,
|
||||
SpaceProductModelEntity,
|
||||
SpaceProductItemModelEntity,
|
||||
]),
|
||||
TypeOrmModule.forFeature([SpaceModelEntity, SubspaceModelEntity, TagModel]),
|
||||
],
|
||||
})
|
||||
export class SpaceModelRepositoryModule {}
|
||||
|
@ -2,7 +2,6 @@ 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 { SpaceProductItemModelEntity } from '../../space-model';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'space-product-item' })
|
||||
@ -23,15 +22,6 @@ export class SpaceProductItemEntity extends AbstractEntity<SpaceProductItemDto>
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@ManyToOne(
|
||||
() => SpaceProductItemModelEntity,
|
||||
(spaceProductItemModel) => spaceProductItemModel.items,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public spaceProductItemModel?: SpaceProductItemModelEntity;
|
||||
|
||||
@OneToOne(() => DeviceEntity, (device) => device.tag, {
|
||||
nullable: true,
|
||||
})
|
||||
|
@ -3,7 +3,6 @@ import { SpaceEntity } from './space.entity';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { SpaceProductItemEntity } from './space-product-item.entity';
|
||||
import { SpaceProductModelEntity } from '../../space-model';
|
||||
|
||||
@Entity({ name: 'space-product' })
|
||||
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||
@ -32,16 +31,6 @@ export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||
})
|
||||
public items: SpaceProductItemEntity[];
|
||||
|
||||
@ManyToOne(
|
||||
() => SpaceProductModelEntity,
|
||||
(spaceProductModel) => spaceProductModel.spaceProducts,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
@JoinColumn({ name: 'space_product_model_uuid' })
|
||||
public spaceProductModel?: SpaceProductModelEntity;
|
||||
|
||||
constructor(partial: Partial<SpaceProductEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
@ -2,7 +2,6 @@ import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.e
|
||||
import { SpaceProductItemDto } from '../../dtos';
|
||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||
import { SubspaceProductEntity } from './subspace-product.entity';
|
||||
import { SubspaceProductItemModelEntity } from '@app/common/modules/space-model';
|
||||
|
||||
@Entity({ name: 'subspace-product-item' })
|
||||
export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||
@ -26,11 +25,6 @@ export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDt
|
||||
})
|
||||
public disabled: boolean;
|
||||
|
||||
@ManyToOne(() => SubspaceProductItemModelEntity, (model) => model.items, {
|
||||
nullable: true,
|
||||
})
|
||||
model: SubspaceProductItemModelEntity;
|
||||
|
||||
constructor(partial: Partial<SubspaceProductItemEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
@ -3,7 +3,6 @@ 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 { SubspaceProductModelEntity } from '@app/common/modules/space-model';
|
||||
import { SpaceProductModelDto } from '../../dtos';
|
||||
|
||||
@Entity({ name: 'subspace-product' })
|
||||
@ -26,7 +25,7 @@ export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto>
|
||||
})
|
||||
public subspace: SubspaceEntity;
|
||||
|
||||
@ManyToOne(() => ProductEntity, (product) => product.subpaceProductModels, {
|
||||
@ManyToOne(() => ProductEntity, (product) => product.spaceProducts, {
|
||||
nullable: false,
|
||||
})
|
||||
public product: ProductEntity;
|
||||
@ -36,12 +35,4 @@ export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto>
|
||||
})
|
||||
public items: SubspaceProductItemEntity[];
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceProductModelEntity,
|
||||
(model) => model.subspaceProducts,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
model: SubspaceProductModelEntity;
|
||||
}
|
||||
|
Reference in New Issue
Block a user