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/invoiceStatus.go | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/model/invoiceStatus.go b/model/invoiceStatus.go index dadfe4e..19a4cde 100644 --- a/model/invoiceStatus.go +++ b/model/invoiceStatus.go @@ -6,24 +6,25 @@ "errors" "fmt" "gorm.io/gorm" + "sync" ) type ( // InvoiceStatus 鍙戠エ鐘舵�� InvoiceStatus 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"` } // InvoiceStatusSearch 鍙戠エ鐘舵�佹悳绱㈡潯浠� InvoiceStatusSearch struct { InvoiceStatus - Orm *gorm.DB - QueryClass constvar.InvoiceStatusQueryClass - KeywordType constvar.InvoiceStatusKeywordType - Keyword string - PageNum int - PageSize int + Orm *gorm.DB + QueryClass constvar.InvoiceStatusQueryClass + KeywordType constvar.InvoiceStatusKeywordType + Keyword string + PageNum int + PageSize int } ) @@ -124,17 +125,28 @@ } // InitDefaultData 鍒濆鍖栨暟鎹� -func (slf *InvoiceStatusSearch) InitDefaultData() error { +func (slf *InvoiceStatusSearch) 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 := []*InvoiceStatus{} - return slf.CreateBatch(records) + records := []*InvoiceStatus{ + {1, "宸插垱寤�"}, + {2, "宸插瘎閫�"}, + {3, "鑷姩鍒涘缓"}, + } + + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } } -- Gitblit v1.8.0