added subspace product item

This commit is contained in:
hannathkadher
2024-12-13 15:57:25 +04:00
parent 654642db6c
commit 7cab62b02a
5 changed files with 31 additions and 22 deletions
@@ -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;
}