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/index.go | 133 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 129 insertions(+), 4 deletions(-) diff --git a/model/index.go b/model/index.go index d8bfae8..d62248f 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 } @@ -27,13 +31,134 @@ Country{}, Province{}, City{}, - Region{}, - ClientStatus{}, Client{}, + ClientLevel{}, + ClientOrigin{}, + ClientStatus{}, + ClientType{}, Contact{}, + EnterpriseNature{}, + EnterpriseScale{}, + FollowRecord{}, + Industry{}, + RegisteredCapital{}, + SaleChance{}, SalesLeads{}, SalesSources{}, - FollowRecord{}, + SaleStage{}, + 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{}, + CourierCompany{}, + InvoiceStatus{}, + InvoiceType{}, + Invoice{}, + RefundType{}, ) 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(), + NewSaleStageSearch(), + NewQuotationStatusSearch(), + NewSalesSourcesSearch(), + NewClientStatusSearch(), + NewClientTypeSearch(), + NewClientOriginSearch(), + NewClientLevelSearch(), + NewIndustrySearch(), + NewRegisteredCapitalSearch(), + NewEnterpriseNatureSearch(), + NewEnterpriseScaleSearch(), + NewContactInformationSearch(), + NewSaleTypeSearch(), + NewPossibilitySearch(), + NewStatusSearch(), + NewPaymentTypeSearch(), + NewBankAccountSearch(), + NewRefundTypeSearch(), + } + + 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