mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
added subspace product item
This commit is contained in:
@ -14,6 +14,7 @@ import {
|
||||
SpaceProductItemEntity,
|
||||
SubspaceEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
} from '../modules/space/entities';
|
||||
import { UserSpaceEntity } from '../modules/user/entities';
|
||||
import { DeviceUserPermissionEntity } from '../modules/device/entities';
|
||||
@ -87,6 +88,7 @@ import {
|
||||
SubspaceProductModelEntity,
|
||||
SubspaceProductItemModelEntity,
|
||||
SubspaceProductEntity,
|
||||
SubspaceProductItemEntity,
|
||||
],
|
||||
namingStrategy: new SnakeNamingStrategy(),
|
||||
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
||||
|
@ -1,2 +1,3 @@
|
||||
export * from './subspace.entity';
|
||||
export * from './subspace-product.entity';
|
||||
export * from './subspace-product-item.entity';
|
||||
|
@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { ProductEntity } from '@app/common/modules/product/entities';
|
||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { SubspaceEntity } from './subspace.entity';
|
||||
import { AbstractEntity } from '@app/common/modules/abstract/entities/abstract.entity';
|
||||
import { SubspaceProductDto } from '../../dtos/subspace/subspace-product.dto';
|
||||
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
||||
|
||||
@Entity({ name: 'subspace-product' })
|
||||
export class SubspaceProductEntity extends AbstractEntity<SubspaceProductDto> {
|
||||
@ -28,4 +29,9 @@ export class SubspaceProductEntity extends AbstractEntity<SubspaceProductDto> {
|
||||
nullable: false,
|
||||
})
|
||||
public product: ProductEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.subspaceProduct, {
|
||||
nullable: true,
|
||||
})
|
||||
public items: SubspaceProductItemEntity[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user