实现 猪舍相关路由组 和 猪圈相关路由组
This commit is contained in:
@@ -67,6 +67,10 @@ type Medication struct {
|
||||
Instructions datatypes.JSON `gorm:"type:jsonb;comment:使用说明" json:"instructions"`
|
||||
}
|
||||
|
||||
func (Medication) TableName() string {
|
||||
return "medications"
|
||||
}
|
||||
|
||||
// MedicationReasonType 定义了用药原因
|
||||
type MedicationReasonType string
|
||||
|
||||
@@ -78,7 +82,7 @@ const (
|
||||
|
||||
// GroupMedicationLog 记录了对整个猪批次的用药情况
|
||||
type GroupMedicationLog struct {
|
||||
gorm.Model
|
||||
ID uint `gorm:"primaryKey"`
|
||||
PigBatchID uint `gorm:"not null;index;comment:关联的猪批次ID"`
|
||||
MedicationID uint `gorm:"not null;index;comment:关联的药品ID"`
|
||||
Medication Medication `gorm:"foreignKey:MedicationID"` // 预加载药品信息
|
||||
@@ -87,5 +91,12 @@ type GroupMedicationLog struct {
|
||||
Reason MedicationReasonType `gorm:"size:20;not null;comment:用药原因"`
|
||||
Description string `gorm:"size:255;comment:具体描述,如'治疗呼吸道病'"`
|
||||
Operator string `gorm:"size:50;comment:操作员"`
|
||||
HappenedAt time.Time `gorm:"not null;default:CURRENT_TIMESTAMP;comment:用药时间"`
|
||||
HappenedAt time.Time `gorm:"primaryKey;comment:用药时间"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
}
|
||||
|
||||
func (GroupMedicationLog) TableName() string {
|
||||
return "group_medication_logs"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user