From 250cbfa1ddcb3cf38e0d0505c1c7e282b940d25b Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 13 十月 2023 10:30:05 +0800
Subject: [PATCH] admin user id 转crm user id
---
model/index.go | 93 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/model/index.go b/model/index.go
index 27988b4..982fb0a 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"
+ "sync"
)
func Init() error {
@@ -14,7 +16,9 @@
if err := RegisterTables(); err != nil {
return err
}
-
+ safe.Go(func() {
+ InsertDefaultData()
+ })
return nil
}
@@ -45,6 +49,93 @@
SaleType{},
RegularCustomers{},
Possibility{},
+ Status{},
+ Quotation{},
+ MasterOrder{},
+ SubOrder{},
+ Product{},
+ SalesDetails{},
+ SalesReturn{},
+ SalesRefund{},
+ Contract{},
+ Plan{},
+ ServiceContract{},
+ OrderManage{},
+ ServiceFollowup{},
+ CustomerServiceSheet{},
+ ServiceFeeManage{},
+ Authority{},
+ Api{},
+ Department{},
+ Satisfaction{},
+ TimelyRate{},
+ SolveRate{},
+ IsVisit{},
+ IsVisit{},
+ ReportSource{},
+ OrderType{},
+ ServiceContractStatus{},
+ ServiceContractType{},
+ RefundMethod{},
+ IsInvoice{},
+ AccountId{},
+ SalesReturnStatus{},
+ Repository{},
+ QuotationStatus{},
+ Currency{},
+ CollectionProjection{},
+ ContactInformation{},
+ SalesReturn{},
+ SalesRefund{},
+ ServiceCollectionPlan{},
+ Receipt{},
+ ServiceOrder{},
)
return err
}
+
+type InitDefaultData interface {
+ InitDefaultData(errCh chan<- error, wg *sync.WaitGroup)
+}
+
+func InsertDefaultData() {
+ errCh := make(chan error, 2)
+ var wg sync.WaitGroup
+
+ models := []interface{}{
+ NewServiceTypeSearch(),
+ NewPriorityLevelSearch(),
+ NewSeveritySearch(),
+ NewTimeSpentSearch(),
+ NewInvoiceTypeSearch(),
+ NewInvoiceStatusSearch(),
+ NewCourierCompanySearch(),
+ NewServiceContractStatusSearch(),
+ NewServiceContractTypeSearch(),
+ NewServiceOrderStatusSearch(),
+ NewSatisfactionSearch(),
+ NewSolveRateSearch(),
+ NewIsVisitSearch(),
+ NewTimelyRateSearch(),
+ NewFaultTypeSearch(),
+ NewRepositorySearch(),
+ }
+
+ for _, model := range models {
+ if id, ok := model.(InitDefaultData); ok {
+ wg.Add(1)
+ go id.InitDefaultData(errCh, &wg)
+ }
+ }
+
+ go func() {
+ wg.Wait() // 绛夊緟鎵�鏈塯oroutine瀹屾垚
+ close(errCh) // 鍏抽棴閿欒閫氶亾
+ }()
+
+ for err := range errCh {
+ if err != nil {
+ logx.Errorf("InitDefaultData err: %v", err.Error())
+ }
+ }
+}
--
Gitblit v1.8.0