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/satisfaction.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/model/satisfaction.go b/model/satisfaction.go index 11690e6..5b77f9e 100644 --- a/model/satisfaction.go +++ b/model/satisfaction.go @@ -3,6 +3,7 @@ import ( "aps_crm/pkg/mysqlx" "gorm.io/gorm" + "sync" ) type ( @@ -77,3 +78,41 @@ var db = slf.build() return db.Updates(data).Error } + +func (slf *SatisfactionSearch) CreateBatch(records []*Satisfaction) error { + var db = slf.build() + return db.Create(records).Error +} + +// InitDefaultData 鍒濆鍖栨暟鎹� +func (slf *SatisfactionSearch) 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 := []*Satisfaction{ + {1, "100%"}, + {2, "90%"}, + {3, "80%"}, + {4, "70%"}, + {5, "60%"}, + {6, "50%"}, + {7, "40%"}, + {8, "30%"}, + {9, "20%"}, + {10, "10%"}, + } + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } +} -- Gitblit v1.8.0