From cdb47d41f39a5c600caa41692c9b5b0732944d6a Mon Sep 17 00:00:00 2001
From: wangpengfei <274878379@qq.com>
Date: 星期二, 08 八月 2023 11:38:27 +0800
Subject: [PATCH] fix
---
model/index.go | 54 +++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/model/index.go b/model/index.go
index 8c7b0f7..04856fa 100644
--- a/model/index.go
+++ b/model/index.go
@@ -4,6 +4,8 @@
"aps_crm/conf"
"aps_crm/pkg/logx"
"aps_crm/pkg/mysqlx"
+ "aps_crm/pkg/safe"
+ "gorm.io/gorm/schema"
)
func Init() error {
@@ -14,7 +16,9 @@
if err := RegisterTables(); err != nil {
return err
}
-
+ safe.Go(func() {
+ InsertDefaultData()
+ })
return nil
}
@@ -66,19 +70,39 @@
Satisfaction{},
TimelyRate{},
SolveRate{},
- IsVisit{},
- IsVisit{},
- ReportSource{},
- OrderType{},
- ServiceContractStatus{},
- ServiceContractType{},
- RefundMethod{},
- IsInvoice{},
- AccountId{},
- SalesReturnStatus{},
- Repository{},
- QuotationStatus{},
- Currency{},
+ IsVisit{},
+ IsVisit{},
+ ReportSource{},
+ OrderType{},
+ ServiceContractStatus{},
+ ServiceContractType{},
+ RefundMethod{},
+ IsInvoice{},
+ AccountId{},
+ SalesReturnStatus{},
+ Repository{},
+ QuotationStatus{},
+ Currency{},
)
return err
-}
\ No newline at end of file
+}
+
+type InitDefaultData interface {
+ InitDefaultData() error
+}
+
+func InsertDefaultData() {
+ models := []interface{}{
+ NewServiceTypeSearch(),
+ NewPriorityLevelSearch(),
+ NewSeveritySearch(),
+ NewTimeSpentSearch(),
+ }
+ for _, model := range models {
+ if id, ok := model.(InitDefaultData); ok {
+ if err := id.InitDefaultData(); err != nil {
+ logx.Errorf("InitDefaultData for table: %v, err :%v", model.(schema.Tabler).TableName(), err.Error())
+ }
+ }
+ }
+}
--
Gitblit v1.8.0