From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- model/severity.go | 26 +++++++++++++++++--------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/model/severity.go b/model/severity.go index 681c4f7..51284df 100644 --- a/model/severity.go +++ b/model/severity.go @@ -6,6 +6,7 @@ "errors" "fmt" "gorm.io/gorm" + "sync" ) type ( @@ -28,7 +29,7 @@ ) func (Severity) TableName() string { - return "severity" + return "severity_order" } func NewSeveritySearch() *SeveritySearch { @@ -119,22 +120,29 @@ } // InitDefaultData 鍒濆鍖栨暟鎹� -func (slf *SeveritySearch) InitDefaultData() error { +func (slf *SeveritySearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) { var ( db = slf.Orm.Table(slf.TableName()) total int64 = 0 ) + defer wg.Done() + if err := db.Count(&total).Error; err != nil { - return err + errCh <- err + return } if total != 0 { - return nil + return } records := []*Severity{ - {Name: "杞�"}, - {Name: "涓ラ噸"}, - {Name: "杈冧弗閲�"}, - {Name: "鐗逛弗閲�"}, + {1, "杞�"}, + {2, "涓ラ噸"}, + {3, "杈冧弗閲�"}, + {4, "鐗逛弗閲�"}, } - return slf.CreateBatch(records) + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } } -- Gitblit v1.8.0