feat: 完善环境规则、会诊治理、知识审核与效果评估
This commit is contained in:
@@ -44,6 +44,9 @@ func Init(cfg *config.Config) error {
|
||||
&model.SeedSource{},
|
||||
&model.DisinfectionRecord{},
|
||||
&model.IdentityLink{},
|
||||
&model.ConsultationOpinionVersion{},
|
||||
&model.RuleEngineResult{},
|
||||
&model.KnowledgeReview{},
|
||||
&model.Tray{}, &model.Batch{}, &model.RearingRecord{},
|
||||
&model.WechatBinding{},
|
||||
&model.WeatherAlert{},
|
||||
@@ -71,7 +74,9 @@ func seedKnowledge(db *gorm.DB) {
|
||||
var cnt int64
|
||||
db.Model(&model.Disease{}).Where("name = ?", d.Name).Count(&cnt)
|
||||
if cnt == 0 {
|
||||
if err := db.Create(&d).Error; err != nil {
|
||||
seed := d
|
||||
seed.Status = "published"
|
||||
if err := db.Create(&seed).Error; err != nil {
|
||||
slog.Warn("写入病种种子失败", "name", d.Name, "err", err)
|
||||
}
|
||||
}
|
||||
@@ -80,7 +85,9 @@ func seedKnowledge(db *gorm.DB) {
|
||||
var cnt int64
|
||||
db.Model(&model.KnowledgeArticle{}).Where("kind = ? AND title = ?", a.Kind, a.Title).Count(&cnt)
|
||||
if cnt == 0 {
|
||||
if err := db.Create(&a).Error; err != nil {
|
||||
seed := a
|
||||
seed.Status = "published"
|
||||
if err := db.Create(&seed).Error; err != nil {
|
||||
slog.Warn("写入知识文章种子失败", "title", a.Title, "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// CurrentSchemaVersion 是当前后端代码期望的迁移版本。
|
||||
const CurrentSchemaVersion = "7"
|
||||
const CurrentSchemaVersion = "8"
|
||||
|
||||
// RunMigrations 使用嵌入式 SQL 迁移文件将数据库升级到最新版本。
|
||||
func RunMigrations(db *gorm.DB) error {
|
||||
|
||||
@@ -120,4 +120,8 @@ func TestEmbeddedMigrationsIncludeBaseline(t *testing.T) {
|
||||
if err != nil || next != 7 {
|
||||
t.Fatalf("expected inspection idempotency migration version 7, got %d (err %v)", next, err)
|
||||
}
|
||||
next, err = driver.Next(next)
|
||||
if err != nil || next != 8 {
|
||||
t.Fatalf("expected governance migration version 8, got %d (err %v)", next, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user