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; // ME值(kcal/g),直接配置的代谢能,可选字段 // 如果配置了此值,优先使用;否则通过营养成分计算 @Column({ type: 'double', nullable: true, comment: 'ME值(kcal/g),直接配置的代谢能', }) meValue: number | null; @OneToMany( () => FeedingPlanProduct, (feedingPlanProduct) => feedingPlanProduct.feedingPlan, { cascade: true }, ) feedingPlanProducts: FeedingPlanProduct[]; }