From 07e0edb712b81e8d3b38465f71d66206e81361db Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 17 十月 2023 14:31:40 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm --- model/quotationStatus.go | 37 ++++++++++++++++++++++++++++++++++++- 1 files changed, 36 insertions(+), 1 deletions(-) diff --git a/model/quotationStatus.go b/model/quotationStatus.go index 30e4fcc..b315c7f 100644 --- a/model/quotationStatus.go +++ b/model/quotationStatus.go @@ -3,6 +3,7 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" + "sync" ) type ( @@ -11,7 +12,7 @@ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Name string `json:"name" gorm:"column:name;type:varchar(255);comment:鍟嗘満闃舵鍚嶇О"` } - + QuotationStatusSearch struct { QuotationStatus Orm *gorm.DB @@ -83,3 +84,37 @@ var db = slf.build() return db.Updates(data).Error } + +func (slf *QuotationStatusSearch) CreateBatch(records []*QuotationStatus) error { + var db = slf.build() + return db.Create(records).Error +} + +// InitDefaultData 鍒濆鍖栨暟鎹� +func (slf *QuotationStatusSearch) 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 { + errCh <- err + return + } + if total != 0 { + return + } + records := []*QuotationStatus{ + {1, "宸插垱寤�"}, + {2, "宸插彂閫�"}, + {3, "宸插鎵�"}, + {4, "宸叉嫆缁�"}, + {5, "宸叉帴鍙�"}, + } + + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } +} -- Gitblit v1.8.0