From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/contactInformation.go | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/model/contactInformation.go b/model/contactInformation.go
index 1ae901d..3fec063 100644
--- a/model/contactInformation.go
+++ b/model/contactInformation.go
@@ -3,6 +3,7 @@
import (
"aps_crm/pkg/mysqlx"
"gorm.io/gorm"
+ "sync"
)
type (
@@ -78,3 +79,35 @@
slf.Name = name
return slf
}
+
+func (slf *ContactInformationSearch) CreateBatch(records []*ContactInformation) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ContactInformationSearch) 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 := []*ContactInformation{
+ {1, "绾夸笅鎷滆"},
+ {2, "鐢佃瘽鑱旂郴"},
+ {3, "浼氳"},
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
--
Gitblit v1.8.0