Files
silk/server-go/internal/model/tray_batch.go
T
2026-08-17 21:43:26 +08:00

56 lines
3.1 KiB
Go

package model
import "time"
// Tray 蚕匾
type Tray struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"size:64" json:"name"`
Code *string `gorm:"size:64" json:"code,omitempty"`
Position *string `gorm:"size:128" json:"position,omitempty"`
RoomID string `gorm:"column:room_id;type:uuid;index" json:"roomId"`
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (Tray) TableName() string { return "trays" }
// Batch 蚕种批次
type Batch struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
RoomID string `gorm:"column:room_id;type:uuid;index" json:"roomId"`
Name string `gorm:"size:64" json:"name"`
Variety *string `gorm:"size:64" json:"variety,omitempty"` // 品种
Source *string `gorm:"size:128" json:"source,omitempty"` // 蚕种来源/供应商
SeedSourceID *string `gorm:"column:seed_source_id;type:uuid;index" json:"seedSourceId,omitempty"`
SeedBatchNo *string `gorm:"column:seed_batch_no;size:64" json:"seedBatchNo,omitempty"` // 蚕种批次号
QuarantineNo *string `gorm:"column:quarantine_no;size:64" json:"quarantineNo,omitempty"` // 检疫证明编号
Instar *int `gorm:"type:int" json:"instar,omitempty"` // 龄期 1-5
EnteredAt *time.Time `gorm:"column:entered_at;type:timestamptz" json:"enteredAt,omitempty"` // 入房时间
MountAt *time.Time `gorm:"column:mount_at;type:timestamptz" json:"mountAt,omitempty"` // 上蔟时间
Status string `gorm:"size:16;default:rearing" json:"status"` // rearing/mounted/finished
Note *string `gorm:"type:text" json:"note,omitempty"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (Batch) TableName() string { return "batches" }
// RearingRecord 饲养记录
type RearingRecord struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
BatchID string `gorm:"column:batch_id;type:uuid;index" json:"batchId"`
RecordDate time.Time `gorm:"column:record_date;type:timestamptz" json:"recordDate"`
Instar *int `gorm:"type:int" json:"instar,omitempty"`
MulberrySource *string `gorm:"column:mulberry_source;size:128" json:"mulberrySource,omitempty"` // 桑叶来源
Density *string `gorm:"size:64" json:"density,omitempty"` // 饲养密度
DeathCount *int `gorm:"column:death_count;type:int" json:"deathCount,omitempty"`
CulledCount *int `gorm:"column:culled_count;type:int" json:"culledCount,omitempty"`
Note *string `gorm:"type:text" json:"note,omitempty"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (RearingRecord) TableName() string { return "rearing_records" }