| | |
| | | "aps_crm/conf" |
| | | "aps_crm/pkg/logx" |
| | | "aps_crm/pkg/mysqlx" |
| | | "aps_crm/pkg/safe" |
| | | "gorm.io/gorm/schema" |
| | | ) |
| | | |
| | | func Init() error { |
| | |
| | | if err := RegisterTables(); err != nil { |
| | | return err |
| | | } |
| | | |
| | | safe.Go(func() { |
| | | InsertDefaultData() |
| | | }) |
| | | return nil |
| | | } |
| | | |
| | |
| | | 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 |
| | | } |
| | | } |
| | | |
| | | 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()) |
| | | } |
| | | } |
| | | } |
| | | } |