From 4b2c52b17abef8521f9211b4865e1cad0288b12a Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 21 十月 2023 17:47:50 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm --- model/bankAccount.go | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/model/bankAccount.go b/model/bankAccount.go index 006e9b8..aba9f92 100644 --- a/model/bankAccount.go +++ b/model/bankAccount.go @@ -6,24 +6,25 @@ "errors" "fmt" "gorm.io/gorm" + "sync" ) type ( // BankAccount 閾惰璐︽埛 BankAccount struct { Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - Name string `json:"name" gorm:"column:name"` + Name string `json:"name" gorm:"column:name"` } // BankAccountSearch 閾惰璐︽埛鎼滅储鏉′欢 BankAccountSearch struct { BankAccount - Orm *gorm.DB - QueryClass constvar.BankAccountQueryClass - KeywordType constvar.BankAccountKeywordType - Keyword string - PageNum int - PageSize int + Orm *gorm.DB + QueryClass constvar.BankAccountQueryClass + KeywordType constvar.BankAccountKeywordType + Keyword string + PageNum int + PageSize int } ) @@ -124,17 +125,26 @@ } // InitDefaultData 鍒濆鍖栨暟鎹� -func (slf *BankAccountSearch) InitDefaultData() error { +func (slf *BankAccountSearch) 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 := []*BankAccount{} - return slf.CreateBatch(records) + records := []*BankAccount{ + {1, "榛樿璐︽埛"}, + } + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } } -- Gitblit v1.8.0