35 lines
1008 B
TypeScript
35 lines
1008 B
TypeScript
import { ApiProperty } from '@midwayjs/swagger';
|
|
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';
|
|
import { Product } from './product.entity';
|
|
|
|
@Entity('product_stock_component')
|
|
export class ProductStockComponent {
|
|
@ApiProperty({ type: Number })
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@ApiProperty({ type: Number })
|
|
@Column()
|
|
productId: number;
|
|
|
|
@ApiProperty({ description: '组件所关联的 SKU', type: 'string' })
|
|
@Column({ type: 'varchar', length: 64 })
|
|
sku: string;
|
|
|
|
@ApiProperty({ type: Number, description: '组成数量' })
|
|
@Column({ type: 'int', default: 1 })
|
|
quantity: number;
|
|
|
|
// 多对一,组件隶属于一个产品
|
|
@ManyToOne(() => Product, (product) => product.components, { onDelete: 'CASCADE' })
|
|
product: Product;
|
|
|
|
@ApiProperty({ description: '创建时间' })
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@ApiProperty({ description: '更新时间' })
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|