import { ApiProperty } from '@midwayjs/swagger'; import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; import { Product } from './product.entity'; // 套餐产品构成 item(sku,0013,xx20,mixed008)n--siteSkus(0013,xx20,xx)旧版数据-->product-component(0020)(套装(1 5 10 20 50 100 (erp 手动创建)mixed))->(product(单品)+ quantity)->sales // CA -> site-product -> components // PRODUCT->compoentn(一次性做完) product+关联sku @Entity('product_stock_component') export class ProductStockComponent { @ApiProperty({ type: Number }) @PrimaryGeneratedColumn() id: number; @ApiProperty({ type: Number }) @Column() productId: number; // zi @ApiProperty({ description: '组件所关联的 SKU', type: 'string' }) @Column({ type: 'varchar', length: 64 }) sku: string; // zi @ApiProperty({ type: Number, description: '组成数量' }) @Column({ type: 'int', default: 1 }) quantity: number; // baba // 多对一,组件隶属于一个产品 @ManyToOne(() => Product, (product) => product.components, { onDelete: 'CASCADE' }) product: Product; @ApiProperty({ description: '创建时间' }) @CreateDateColumn() createdAt: Date; @ApiProperty({ description: '更新时间' }) @UpdateDateColumn() updatedAt: Date; }