66 lines
1.2 KiB
TypeScript
66 lines
1.2 KiB
TypeScript
import { BaseEntity } from '@/core/entity/base.entity';
|
|
import { Column, Entity, OneToMany } from 'typeorm';
|
|
import { FeedingPlanProduct } from '@/pet-feeder/entity/feeding-plan-product.entity';
|
|
import { ProductCategory } from '@/pet-feeder/enum/product-category';
|
|
|
|
@Entity()
|
|
export class Product extends BaseEntity {
|
|
@Column()
|
|
name: string;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: ProductCategory,
|
|
default: ProductCategory.DRY_FOOD,
|
|
})
|
|
category: ProductCategory;
|
|
|
|
@Column()
|
|
photo: string;
|
|
|
|
@Column({
|
|
type: 'json',
|
|
})
|
|
tags: string[];
|
|
|
|
@Column()
|
|
totalWeight: number;
|
|
|
|
//蛋白质(百分比,如0.6表示60%)
|
|
@Column({
|
|
type: 'double',
|
|
})
|
|
protein: number;
|
|
|
|
// 脂肪(百分比)
|
|
@Column({
|
|
type: 'double',
|
|
})
|
|
fat: number;
|
|
|
|
// 粗纤维(百分比)
|
|
@Column({
|
|
type: 'double',
|
|
})
|
|
fiber: number;
|
|
|
|
// 粗灰分(百分比)
|
|
@Column({
|
|
type: 'double',
|
|
})
|
|
ash: number;
|
|
|
|
// 水分(百分比)
|
|
@Column({
|
|
type: 'double',
|
|
})
|
|
moisture: number;
|
|
|
|
@OneToMany(
|
|
() => FeedingPlanProduct,
|
|
(feedingPlanProduct) => feedingPlanProduct.feedingPlan,
|
|
{ cascade: true },
|
|
)
|
|
feedingPlanProducts: FeedingPlanProduct[];
|
|
}
|