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 |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/model/satisfaction.go b/model/satisfaction.go
index e8c3e14..5b77f9e 100644
--- a/model/satisfaction.go
+++ b/model/satisfaction.go
@@ -3,6 +3,7 @@
 import (
 	"aps_crm/pkg/mysqlx"
 	"gorm.io/gorm"
+	"sync"
 )
 
 type (
@@ -84,16 +85,18 @@
 }
 
 // InitDefaultData 鍒濆鍖栨暟鎹�
-func (slf *SatisfactionSearch) InitDefaultData() error {
+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 {
-		return err
+		errCh <- err
+		return
 	}
 	if total != 0 {
-		return nil
+		return
 	}
 	records := []*Satisfaction{
 		{1, "100%"},
@@ -107,5 +110,9 @@
 		{9, "20%"},
 		{10, "10%"},
 	}
-	return slf.CreateBatch(records)
+	err := slf.CreateBatch(records)
+	if err != nil {
+		errCh <- err
+		return
+	}
 }

--
Gitblit v1.8.0