|
@@ -0,0 +1,61 @@
|
|
|
|
|
+import { TraceableEntity } from '@/core/entity/traceable.entity';
|
|
|
|
|
+import { PetType } from '@/pet-feeder/enum/pet-type';
|
|
|
|
|
+import { Gender } from '@/core/enum/Gender';
|
|
|
|
|
+import { PetBodyType } from '@/pet-feeder/enum/pet-body-type';
|
|
|
|
|
+import { Column, Entity, JoinColumn, OneToOne } from 'typeorm';
|
|
|
|
|
+import { FeedingPlan } from '@/pet-feeder/entity/feeding-plan.entity';
|
|
|
|
|
+
|
|
|
|
|
+@Entity()
|
|
|
|
|
+export class Pet extends TraceableEntity {
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ name: string;
|
|
|
|
|
+
|
|
|
|
|
+ @Column({
|
|
|
|
|
+ type: 'enum',
|
|
|
|
|
+ enum: PetType,
|
|
|
|
|
+ default: PetType.CAT,
|
|
|
|
|
+ })
|
|
|
|
|
+ type: PetType;
|
|
|
|
|
+
|
|
|
|
|
+ @Column({
|
|
|
|
|
+ type: 'enum',
|
|
|
|
|
+ enum: PetType,
|
|
|
|
|
+ default: PetType.CAT,
|
|
|
|
|
+ })
|
|
|
|
|
+ gender: Gender;
|
|
|
|
|
+
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ birthday: Date;
|
|
|
|
|
+
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ weight: number;
|
|
|
|
|
+
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ isActive: boolean;
|
|
|
|
|
+
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ isPregnant: boolean;
|
|
|
|
|
+
|
|
|
|
|
+ // 是否绝育
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ isSterilization: boolean;
|
|
|
|
|
+
|
|
|
|
|
+ // 是否在哺乳
|
|
|
|
|
+ @Column()
|
|
|
|
|
+ isLactation: boolean;
|
|
|
|
|
+
|
|
|
|
|
+ // 体型
|
|
|
|
|
+ @Column({
|
|
|
|
|
+ type: 'enum',
|
|
|
|
|
+ enum: PetBodyType,
|
|
|
|
|
+ default: PetBodyType.IDEAL,
|
|
|
|
|
+ })
|
|
|
|
|
+ bodyType: PetBodyType;
|
|
|
|
|
+
|
|
|
|
|
+ // 一对一喂养计划
|
|
|
|
|
+ @OneToOne(() => FeedingPlan, (feedingPlan) => feedingPlan.pet, {
|
|
|
|
|
+ cascade: true,
|
|
|
|
|
+ })
|
|
|
|
|
+ @JoinColumn() // 用于指定外键关系
|
|
|
|
|
+ feedingPlan: FeedingPlan;
|
|
|
|
|
+}
|