67 lines
1.3 KiB
TypeScript
67 lines
1.3 KiB
TypeScript
import {
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Entity,
|
|
ManyToMany,
|
|
JoinTable,
|
|
} from 'typeorm';
|
|
import { ApiProperty } from '@midwayjs/swagger';
|
|
import { DictItem } from './dict_item.entity';
|
|
|
|
@Entity()
|
|
export class Product {
|
|
@ApiProperty({
|
|
example: '1',
|
|
description: 'ID',
|
|
type: 'number',
|
|
required: true,
|
|
})
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@ApiProperty({
|
|
example: 'ZYN 6MG WINTERGREEN',
|
|
description: '产品名称',
|
|
type: 'string',
|
|
required: true,
|
|
})
|
|
@Column()
|
|
name: string;
|
|
|
|
@ApiProperty({ description: '产品中文名称' })
|
|
@Column({ default: '' })
|
|
nameCn: string;
|
|
|
|
@ApiProperty({ example: '产品描述', description: '产品描述' })
|
|
@Column({ nullable: true })
|
|
description?: string;
|
|
|
|
@ApiProperty({ description: 'sku'})
|
|
@Column({ unique: true })
|
|
sku: string;
|
|
|
|
@ManyToMany(() => DictItem, {
|
|
cascade: true,
|
|
})
|
|
@JoinTable()
|
|
attributes: DictItem[];
|
|
|
|
@ApiProperty({
|
|
example: '2022-12-12 11:11:11',
|
|
description: '创建时间',
|
|
required: true,
|
|
})
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@ApiProperty({
|
|
example: '2022-12-12 11:11:11',
|
|
description: '更新时间',
|
|
required: true,
|
|
})
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|