From 115bd9b51f5d8eade4658f844de37516486c60e7 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期六, 18 十一月 2023 17:25:25 +0800 Subject: [PATCH] crm获取aps项目模块信息 --- model/priorityLevel.go | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/model/priorityLevel.go b/model/priorityLevel.go index b2240f8..b1902f4 100644 --- a/model/priorityLevel.go +++ b/model/priorityLevel.go @@ -6,6 +6,7 @@ "errors" "fmt" "gorm.io/gorm" + "sync" ) type ( @@ -119,22 +120,29 @@ } // InitDefaultData 鍒濆鍖栨暟鎹� -func (slf *PriorityLevelSearch) InitDefaultData() error { +func (slf *PriorityLevelSearch) 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 := []*PriorityLevel{ - {Name: "浣�"}, - {Name: "涓�鑸�"}, - {Name: "楂�"}, - {Name: "绱ф��"}, + {1, "浣�"}, + {2, "涓�鑸�"}, + {3, "楂�"}, + {4, "绱ф��"}, } - return slf.CreateBatch(records) + err := slf.CreateBatch(records) + if err != nil { + errCh <- err + return + } } -- Gitblit v1.8.0