Files

69 lines
3.7 KiB
Go

package model
import "time"
// Disease 蚕病百科条目(知识库-蚕病百科)
type Disease struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Name string `gorm:"size:64" json:"name"`
Category string `gorm:"size:32;index" json:"category"` // viral/fungal/bacterial/protozoan/other
Pathogen string `gorm:"type:text" json:"pathogen"`
Transmission string `gorm:"type:text" json:"transmission"`
Medium string `gorm:"type:text" json:"medium"`
Incubation string `gorm:"type:text" json:"incubation"`
Symptoms string `gorm:"type:text" json:"symptoms"`
HighRiskStage string `gorm:"column:high_risk_stage;type:text" json:"highRiskStage"`
HighRiskCondition string `gorm:"column:high_risk_condition;type:text" json:"highRiskCondition"`
LethalTime string `gorm:"column:lethal_time;type:text" json:"lethalTime"`
SpreadTrend string `gorm:"column:spread_trend;type:text" json:"spreadTrend"`
Recurrence string `gorm:"type:text" json:"recurrence"`
Detection string `gorm:"type:text" json:"detection"`
Prevention string `gorm:"type:text" json:"prevention"`
ImageURL *string `gorm:"column:image_url;size:512" json:"imageUrl,omitempty"`
Status string `gorm:"size:16;default:published;index" json:"status"`
Source *string `gorm:"type:text" json:"source,omitempty"`
SourceDate *time.Time `gorm:"column:source_date;type:date" json:"sourceDate,omitempty"`
ExpertConfirmedBy *string `gorm:"column:expert_confirmed_by;type:uuid" json:"expertConfirmedBy,omitempty"`
SortOrder int `gorm:"column:sort_order;type:int;default:0" json:"sortOrder"`
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (Disease) TableName() string { return "diseases" }
// KnowledgeArticle 知识文章(AI 结果解读、LAMP/SERS 教程、季节性防控提醒等)
type KnowledgeArticle struct {
ID string `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
Kind string `gorm:"size:32;index" json:"kind"` // ai_guide/lamp_guide/sers_guide/seasonal_tip
Title string `gorm:"size:128" json:"title"`
Summary string `gorm:"type:text" json:"summary"`
Content string `gorm:"type:text" json:"content"`
Status string `gorm:"size:16;default:published;index" json:"status"`
Source *string `gorm:"type:text" json:"source,omitempty"`
SourceDate *time.Time `gorm:"column:source_date;type:date" json:"sourceDate,omitempty"`
ExpertConfirmedBy *string `gorm:"column:expert_confirmed_by;type:uuid" json:"expertConfirmedBy,omitempty"`
SortOrder int `gorm:"column:sort_order;type:int;default:0" json:"sortOrder"`
Enabled bool `gorm:"default:true" json:"enabled"`
CreatedAt time.Time `gorm:"type:timestamptz" json:"createdAt"`
UpdatedAt time.Time `gorm:"type:timestamptz" json:"updatedAt"`
}
func (KnowledgeArticle) TableName() string { return "knowledge_articles" }
// ValidKnowledgeTransition 知识审核状态机:draft/review/published/withdrawn。
func ValidKnowledgeTransition(from, to string) bool {
switch from {
case "draft":
return to == "review" || to == "withdrawn"
case "review":
return to == "published" || to == "withdrawn" || to == "draft"
case "published":
return to == "withdrawn"
case "withdrawn":
return to == "review" || to == "draft"
default:
return false
}
}