mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 19:04:54 +00:00
added subspace product item
This commit is contained in:
@ -13,14 +13,14 @@ export class SubspaceProductItemModelEntity extends AbstractEntity<SubspaceProdu
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceProductModelEntity,
|
||||
(subspaceProductModel) => subspaceProductModel.items,
|
||||
(productModel) => productModel.itemModels,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public subspaceProductModel: SubspaceProductModelEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.model, {
|
||||
@OneToMany(() => SubspaceProductItemEntity, (item) => item.subspaceProduct, {
|
||||
nullable: true,
|
||||
})
|
||||
items: SubspaceProductItemEntity[];
|
||||
|
||||
@ -3,6 +3,7 @@ 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' })
|
||||
@ -27,12 +28,17 @@ export class SubspaceProductModelEntity extends AbstractEntity<SubpaceProductMod
|
||||
})
|
||||
public product: ProductEntity;
|
||||
|
||||
@OneToMany(() => SubspaceProductEntity, (product) => product.model, {
|
||||
nullable: true,
|
||||
})
|
||||
public subspaceProducts: SubspaceProductEntity[];
|
||||
|
||||
@OneToMany(
|
||||
() => SubspaceProductItemModelEntity,
|
||||
(item) => item.subspaceProductModel,
|
||||
(product) => product.subspaceProductModel,
|
||||
{
|
||||
cascade: true,
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
public items: SubspaceProductItemModelEntity[];
|
||||
public itemModels: SubspaceProductItemModelEntity[];
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
|
||||
|
||||
export class SubspaceProductDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
productCount: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
}
|
||||
@ -24,4 +24,9 @@ export class SubspaceProductItemEntity extends AbstractEntity<SpaceProductItemDt
|
||||
nullable: true,
|
||||
})
|
||||
model: SubspaceProductItemModelEntity;
|
||||
|
||||
constructor(partial: Partial<SubspaceProductItemEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,15 @@ 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 { SubspaceProductDto } from '../../dtos/subspace/subspace-product.dto';
|
||||
import { SubspaceProductItemEntity } from './subspace-product-item.entity';
|
||||
import {
|
||||
SubspaceProductItemModelEntity,
|
||||
SubspaceProductModelEntity,
|
||||
} from '@app/common/modules/space-model';
|
||||
import { SpaceProductModelDto } from '../../dtos';
|
||||
|
||||
@Entity({ name: 'subspace-product' })
|
||||
export class SubspaceProductEntity extends AbstractEntity<SubspaceProductDto> {
|
||||
export class SubspaceProductEntity extends AbstractEntity<SpaceProductModelDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
@ -34,4 +38,13 @@ export class SubspaceProductEntity extends AbstractEntity<SubspaceProductDto> {
|
||||
nullable: true,
|
||||
})
|
||||
public items: SubspaceProductItemEntity[];
|
||||
|
||||
@ManyToOne(
|
||||
() => SubspaceProductModelEntity,
|
||||
(model) => model.subspaceProducts,
|
||||
{
|
||||
nullable: true,
|
||||
},
|
||||
)
|
||||
model: SubspaceProductItemModelEntity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user