From 4b2c52b17abef8521f9211b4865e1cad0288b12a Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期六, 21 十月 2023 17:47:50 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm

---
 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