From b45b8ce8051e2ad9c80aafa42d1a5892f6a36bce Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 17 十月 2023 15:27:44 +0800
Subject: [PATCH] 初始化一些表shuju
---
model/clientStatus.go | 35 +++++++++++++++++
model/index.go | 2 +
model/salesSources.go | 34 +++++++++++++++++
3 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/model/clientStatus.go b/model/clientStatus.go
index 6d51a64..c2fa2b1 100644
--- a/model/clientStatus.go
+++ b/model/clientStatus.go
@@ -3,6 +3,7 @@
import (
"aps_crm/pkg/mysqlx"
"gorm.io/gorm"
+ "sync"
)
type (
@@ -91,3 +92,37 @@
var db = slf.build()
return db.Updates(values).Error
}
+
+func (slf *ClientStatusSearch) CreateBatch(records []*ClientStatus) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *ClientStatusSearch) 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 := []*ClientStatus{
+ {1, "鍒濇湡娌熼��"},
+ {2, "闇�姹傚垎鏋�"},
+ {3, "鏂规鎶ヤ环"},
+ {4, "鍟嗗姟璋堝垽"},
+ {5, "鎴愬姛缁撴"},
+ }
+
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
diff --git a/model/index.go b/model/index.go
index e60709e..ee1caf1 100644
--- a/model/index.go
+++ b/model/index.go
@@ -124,6 +124,8 @@
NewRepositorySearch(),
NewSaleStageSearch(),
NewQuotationStatusSearch(),
+ NewSalesSourcesSearch(),
+ NewClientStatusSearch(),
}
for _, model := range models {
diff --git a/model/salesSources.go b/model/salesSources.go
index 9c7f05f..3472066 100644
--- a/model/salesSources.go
+++ b/model/salesSources.go
@@ -3,6 +3,7 @@
import (
"aps_crm/pkg/mysqlx"
"gorm.io/gorm"
+ "sync"
)
type (
@@ -84,3 +85,36 @@
var db = slf.build()
return db.Updates(data).Error
}
+
+func (slf *SalesSourcesSearch) CreateBatch(records []*SalesSources) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *SalesSourcesSearch) 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 := []*SalesSources{
+ {1, "鐢佃瘽鏉ヨ"},
+ {2, "鍏徃鍒嗛厤"},
+ {3, "瀹㈡埛浠嬬粛"},
+ {4, "鐙珛寮�鍙�"},
+ }
+
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
--
Gitblit v1.8.0