mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-24 16:37:55 +00:00
added subspace product item
This commit is contained in:
@@ -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