mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 20:44:53 +00:00
added entities for space product item
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
export * from './subspace-model.dto';
|
||||
export * from './space-model.dto';
|
||||
export * from './space-product-item.dto';
|
||||
export * from './space-product-item-model.dto';
|
||||
export * from './space-product-model.dto';
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
import { IsString, IsNotEmpty } from 'class-validator';
|
||||
|
||||
export class SpaceProductItemModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
tag: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
spaceProductModelUuid: string;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
|
||||
import { SpaceProductItemDto } from './space-product-item.dto';
|
||||
import { SpaceProductItemModelDto } from './space-product-item-model.dto';
|
||||
|
||||
export class SpaceProductModelDto {
|
||||
@IsString()
|
||||
@ -17,7 +17,7 @@ export class SpaceProductModelDto {
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of individual items with specific names for the product',
|
||||
type: [SpaceProductItemDto],
|
||||
type: [SpaceProductItemModelDto],
|
||||
})
|
||||
items: SpaceProductItemDto[];
|
||||
items: SpaceProductItemModelDto[];
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import { Entity, Column, ManyToOne, Unique } from 'typeorm';
|
||||
import { Entity, Column, ManyToOne } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemDto } from '../dtos';
|
||||
import { SpaceProductItemModelDto } from '../dtos';
|
||||
import { SpaceProductModelEntity } from './space-product-model.entity';
|
||||
import { SpaceModelEntity } from './space-model.entity';
|
||||
|
||||
@Entity({ name: 'space-product-item-model' })
|
||||
@Unique(['tag', 'spaceProductModel', 'spaceModel'])
|
||||
export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||
export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItemModelDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
@ -20,13 +18,4 @@ export class SpaceProductItemModelEntity extends AbstractEntity<SpaceProductItem
|
||||
},
|
||||
)
|
||||
public spaceProductModel: SpaceProductModelEntity;
|
||||
|
||||
@ManyToOne(
|
||||
() => SpaceModelEntity,
|
||||
(spaceModel) => spaceModel.spaceProductModels,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
public spaceModel: SpaceModelEntity;
|
||||
}
|
||||
|
||||
@ -1,2 +1,4 @@
|
||||
export * from './space.dto';
|
||||
export * from './subspace.dto';
|
||||
export * from './space-product-item.dto';
|
||||
export * from './space-product.dto';
|
||||
|
||||
@ -11,5 +11,5 @@ export class SpaceProductItemDto {
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
spaceProductModelUuid: string;
|
||||
spaceProductUuid: string;
|
||||
}
|
||||
23
libs/common/src/modules/space/dtos/space-product.dto.ts
Normal file
23
libs/common/src/modules/space/dtos/space-product.dto.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsString, IsNotEmpty, IsNumber } from 'class-validator';
|
||||
import { SpaceProductItemDto } from './space-product-item.dto';
|
||||
|
||||
export class SpaceProductModelDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
uuid: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
productCount: number;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'List of individual items with specific names for the product',
|
||||
type: [SpaceProductItemDto],
|
||||
})
|
||||
items: SpaceProductItemDto[];
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
export * from './space.entity';
|
||||
export * from './subspace.entity';
|
||||
export * from './space-product-item.entity';
|
||||
export * from './space-product.entity';
|
||||
export * from './space-link.entity';
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
import { Column, Entity, ManyToOne } from 'typeorm';
|
||||
import { SpaceProductEntity } from './space-product.entity';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceProductItemDto } from '../dtos';
|
||||
|
||||
@Entity({ name: 'space-product-item-model' })
|
||||
export class SpaceProductItemEntity extends AbstractEntity<SpaceProductItemDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public tag: string;
|
||||
|
||||
@ManyToOne(() => SpaceProductEntity, (spaceProduct) => spaceProduct.items, {
|
||||
nullable: false,
|
||||
})
|
||||
public spaceProducts: SpaceProductEntity;
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
import { Column, Entity, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Column, Entity, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
|
||||
import { SpaceEntity } from './space.entity';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { SpaceProductItemEntity } from './space-product-item.entity';
|
||||
|
||||
@Entity({ name: 'space-product' })
|
||||
export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||
@ -25,6 +26,11 @@ export class SpaceProductEntity extends AbstractEntity<SpaceProductEntity> {
|
||||
})
|
||||
productCount: number;
|
||||
|
||||
@OneToMany(() => SpaceProductItemEntity, (item) => item.spaceProducts, {
|
||||
cascade: true,
|
||||
})
|
||||
public items: SpaceProductItemEntity[];
|
||||
|
||||
constructor(partial: Partial<SpaceProductEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
||||
Reference in New Issue
Block a user