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/saleStage.go | 35 +++++++++++++++++ model/quotationStatus.go | 37 ++++++++++++++++++ model/index.go | 2 + 3 files changed, 73 insertions(+), 1 deletions(-) diff --git a/model/index.go b/model/index.go index d3efc32..e60709e 100644 --- a/model/index.go +++ b/model/index.go @@ -122,6 +122,8 @@ NewTimelyRateSearch(), NewFaultTypeSearch(), NewRepositorySearch(), + NewSaleStageSearch(), + NewQuotationStatusSearch(), } for _, model := range models { 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 + } +} diff --git a/model/saleStage.go b/model/saleStage.go index e4b5f8d..7bd1c53 100644 --- a/model/saleStage.go +++ b/model/saleStage.go @@ -3,6 +3,7 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" + "sync" ) type ( @@ -84,3 +85,37 @@ var db = slf.build() return db.Updates(data).Error } + +func (slf *SaleStageSearch) CreateBatch(records []*SaleStage) error { + var db = slf.build() + return db.Create(records).Error +} + +// InitDefaultData 鍒濆鍖栨暟鎹� +func (slf *SaleStageSearch) 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 := []*SaleStage{ + {1, "鍒濇湡娌熼��"}, + {2, "闇�姹傚垎鏋�"}, + {3, "鍟嗗姟璋堝垽"}, + {4, "鎴愬姛鍏抽棴"}, + {4, "鎴愬姛缁撴"}, + } + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } +} -- Gitblit v1.8.0