From 5f0170df9787c6f3ff17cc168b3f2e3f511453f6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 31 十月 2023 20:04:16 +0800
Subject: [PATCH] 支持职级降级的情况
---
model/industry.go | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/model/industry.go b/model/industry.go
index 5d6ff03..3c01531 100644
--- a/model/industry.go
+++ b/model/industry.go
@@ -3,6 +3,7 @@
import (
"aps_crm/pkg/mysqlx"
"gorm.io/gorm"
+ "sync"
)
type (
@@ -84,3 +85,38 @@
var db = slf.build()
return db.Updates(data).Error
}
+
+func (slf *IndustrySearch) CreateBatch(records []*Industry) error {
+ var db = slf.build()
+ return db.Create(records).Error
+}
+
+// InitDefaultData 鍒濆鍖栨暟鎹�
+func (slf *IndustrySearch) 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 := []*Industry{
+ {1, "鍒堕�犱笟"},
+ {2, "浜ら�氳繍杈�"},
+ {3, "寤虹瓚涓�"},
+ {4, "鐜鍜屽叕鍏辫鏂界鐞嗕笟"},
+ {5, "鎵瑰彂鍜岄浂鍞笟"},
+ {6, "鍏朵粬"},
+ }
+ err := slf.CreateBatch(records)
+ if err != nil {
+ errCh <- err
+ return
+ }
+}
--
Gitblit v1.8.0