| | |
| | | "aps_crm/conf" |
| | | "aps_crm/pkg/logx" |
| | | "aps_crm/pkg/mysqlx" |
| | | "aps_crm/pkg/safe" |
| | | "sync" |
| | | ) |
| | | |
| | | func Init() error { |
| | |
| | | if err := RegisterTables(); err != nil { |
| | | return err |
| | | } |
| | | |
| | | safe.Go(func() { |
| | | InsertDefaultData() |
| | | }) |
| | | return nil |
| | | } |
| | | |
| | |
| | | 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() // 等待所有goroutine完成 |
| | | close(errCh) // 关闭错误通道 |
| | | }() |
| | | |
| | | for err := range errCh { |
| | | if err != nil { |
| | | logx.Errorf("InitDefaultData err: %v", err.Error()) |
| | | } |
| | | } |
| | | } |