mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-11 15:48:09 +00:00
added subspace model product and item entities
This commit is contained in:
@ -34,6 +34,8 @@ import {
|
|||||||
SpaceProductItemModelEntity,
|
SpaceProductItemModelEntity,
|
||||||
SpaceProductModelEntity,
|
SpaceProductModelEntity,
|
||||||
SubspaceModelEntity,
|
SubspaceModelEntity,
|
||||||
|
SubspaceProductItemModelEntity,
|
||||||
|
SubspaceProductModelEntity,
|
||||||
} from '../modules/space-model/entities';
|
} from '../modules/space-model/entities';
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@ -81,6 +83,8 @@ import {
|
|||||||
SubspaceModelEntity,
|
SubspaceModelEntity,
|
||||||
SpaceProductEntity,
|
SpaceProductEntity,
|
||||||
SpaceProductItemEntity,
|
SpaceProductItemEntity,
|
||||||
|
SubspaceProductModelEntity,
|
||||||
|
SubspaceProductItemModelEntity,
|
||||||
],
|
],
|
||||||
namingStrategy: new SnakeNamingStrategy(),
|
namingStrategy: new SnakeNamingStrategy(),
|
||||||
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
||||||
|
@ -4,6 +4,7 @@ import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
|||||||
import { DeviceEntity } from '../../device/entities';
|
import { DeviceEntity } from '../../device/entities';
|
||||||
import { SpaceProductEntity } from '../../space/entities/space-product.entity';
|
import { SpaceProductEntity } from '../../space/entities/space-product.entity';
|
||||||
import { SpaceProductModelEntity } from '../../space-model/entities';
|
import { SpaceProductModelEntity } from '../../space-model/entities';
|
||||||
|
import { SubspaceProductModelEntity } from '../../space-model/entities/subspace-model/subspace-product-model.entity';
|
||||||
|
|
||||||
@Entity({ name: 'product' })
|
@Entity({ name: 'product' })
|
||||||
export class ProductEntity extends AbstractEntity<ProductDto> {
|
export class ProductEntity extends AbstractEntity<ProductDto> {
|
||||||
@ -37,6 +38,12 @@ export class ProductEntity extends AbstractEntity<ProductDto> {
|
|||||||
)
|
)
|
||||||
spaceProductModels: SpaceProductModelEntity[];
|
spaceProductModels: SpaceProductModelEntity[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => SubspaceProductModelEntity,
|
||||||
|
(subspaceProductModel) => subspaceProductModel.product,
|
||||||
|
)
|
||||||
|
subpaceProductModels: SubspaceProductModelEntity[];
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => DeviceEntity,
|
() => DeviceEntity,
|
||||||
(devicesProductEntity) => devicesProductEntity.productDevice,
|
(devicesProductEntity) => devicesProductEntity.productDevice,
|
||||||
|
@ -49,7 +49,6 @@ export class SpaceModelEntity extends AbstractEntity<SpaceModelDto> {
|
|||||||
() => SpaceProductModelEntity,
|
() => SpaceProductModelEntity,
|
||||||
(productModel) => productModel.spaceModel,
|
(productModel) => productModel.spaceModel,
|
||||||
{
|
{
|
||||||
cascade: true,
|
|
||||||
nullable: true,
|
nullable: true,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1 +1,3 @@
|
|||||||
export * from './subspace-model.entity';
|
export * from './subspace-model.entity';
|
||||||
|
export * from './subspace-product-item-model.entity';
|
||||||
|
export * from './subspace-product-model.entity';
|
||||||
|
@ -3,6 +3,7 @@ import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
|||||||
import { SubSpaceModelDto } from '../../dtos';
|
import { SubSpaceModelDto } from '../../dtos';
|
||||||
import { SpaceModelEntity } from '../space-model.entity';
|
import { SpaceModelEntity } from '../space-model.entity';
|
||||||
import { SubspaceEntity } from '@app/common/modules/space/entities';
|
import { SubspaceEntity } from '@app/common/modules/space/entities';
|
||||||
|
import { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
||||||
|
|
||||||
@Entity({ name: 'subspace-model' })
|
@Entity({ name: 'subspace-model' })
|
||||||
@Unique(['subspaceName', 'spaceModel'])
|
@Unique(['subspaceName', 'spaceModel'])
|
||||||
@ -33,4 +34,13 @@ export class SubspaceModelEntity extends AbstractEntity<SubSpaceModelDto> {
|
|||||||
cascade: true,
|
cascade: true,
|
||||||
})
|
})
|
||||||
public spaces: SubspaceEntity[];
|
public spaces: SubspaceEntity[];
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => SubspaceProductModelEntity,
|
||||||
|
(productModel) => productModel.subspaceModel,
|
||||||
|
{
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
public subspaceProductModels: SubspaceProductModelEntity[];
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||||
|
import { Entity, Column, ManyToOne } from 'typeorm';
|
||||||
|
import { SubspaceProductItemModelDto } from '../../dtos';
|
||||||
|
import { SubspaceProductModelEntity } from './subspace-product-model.entity';
|
||||||
|
|
||||||
|
@Entity({ name: 'subspace-product-item-model' })
|
||||||
|
export class SubspaceProductItemModelEntity extends AbstractEntity<SubspaceProductItemModelDto> {
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
public tag: string;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => SubspaceProductModelEntity,
|
||||||
|
(subspaceProductModel) => subspaceProductModel.items,
|
||||||
|
{
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
public subspaceProductModel: SubspaceProductModelEntity;
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
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 { SubspaceProductItemModelEntity } from './subspace-product-item-model.entity';
|
||||||
|
|
||||||
|
@Entity({ name: 'subspace-product-model' })
|
||||||
|
export class SubspaceProductModelEntity extends AbstractEntity<SubpaceProductModelDto> {
|
||||||
|
@Column({
|
||||||
|
nullable: false,
|
||||||
|
type: 'int',
|
||||||
|
})
|
||||||
|
productCount: number;
|
||||||
|
|
||||||
|
@ManyToOne(
|
||||||
|
() => SubspaceModelEntity,
|
||||||
|
(spaceModel) => spaceModel.subspaceProductModels,
|
||||||
|
{
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
public subspaceModel: SubspaceModelEntity;
|
||||||
|
|
||||||
|
@ManyToOne(() => ProductEntity, (product) => product.subpaceProductModels, {
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
public product: ProductEntity;
|
||||||
|
|
||||||
|
@OneToMany(
|
||||||
|
() => SubspaceProductItemModelEntity,
|
||||||
|
(item) => item.subspaceProductModel,
|
||||||
|
{
|
||||||
|
cascade: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
public items: SubspaceProductItemModelEntity[];
|
||||||
|
}
|
Reference in New Issue
Block a user