From a9053682a59a20d5994bae402de549b46d4ac969 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 16 八月 2023 19:34:21 +0800 Subject: [PATCH] fix --- model/index.go | 58 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 43 insertions(+), 15 deletions(-) diff --git a/model/index.go b/model/index.go index 7a0f17c..8ea162c 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,43 @@ 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{}, + CollectionProjection{}, + ContactInformation{}, + SalesReturn{}, + SalesRefund{}, ) 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