From 5b4ef02fafbc14e8c36c81484620dd86b51ab929 Mon Sep 17 00:00:00 2001 From: Matrix-X Date: Fri, 20 Sep 2024 12:20:03 +0800 Subject: [PATCH] feat(pro): add pro migrate and seed --- cmd/ctl/database/migrate/powerx.go | 4 ++++ cmd/ctl/database/pro/migrate/custom.go | 12 ++++++++++++ cmd/ctl/database/pro/seed/datadictionary.go | 17 +++++++++++++++++ cmd/ctl/database/pro/seed/pro.go | 9 +++++++++ .../seed/datadictionary/datadictionary.go | 8 +++++--- cmd/ctl/database/seed/powerx.go | 8 ++++++-- 6 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 cmd/ctl/database/pro/migrate/custom.go create mode 100644 cmd/ctl/database/pro/seed/datadictionary.go create mode 100644 cmd/ctl/database/pro/seed/pro.go diff --git a/cmd/ctl/database/migrate/powerx.go b/cmd/ctl/database/migrate/powerx.go index 99fe1fdf..d2c856a5 100644 --- a/cmd/ctl/database/migrate/powerx.go +++ b/cmd/ctl/database/migrate/powerx.go @@ -2,6 +2,7 @@ package migrate import ( "PowerX/cmd/ctl/database/custom/migrate" + migratePro "PowerX/cmd/ctl/database/pro/migrate" "PowerX/internal/config" "PowerX/internal/model" "PowerX/internal/model/crm/customerdomain" @@ -92,6 +93,9 @@ func (m *PowerMigrator) AutoMigrate() { trade.TokenReservation{}, trade.TokenTransaction{}, ) + // pro + migratePro.AutoMigratePro(m.db) + // custom migrate.AutoMigrateCustom(m.db) diff --git a/cmd/ctl/database/pro/migrate/custom.go b/cmd/ctl/database/pro/migrate/custom.go new file mode 100644 index 00000000..b78e3b2d --- /dev/null +++ b/cmd/ctl/database/pro/migrate/custom.go @@ -0,0 +1,12 @@ +package migrate + +import ( + "gorm.io/gorm" +) + +func AutoMigratePro(db *gorm.DB) { + // migrate your pro models + + _ = db.AutoMigrate() + +} diff --git a/cmd/ctl/database/pro/seed/datadictionary.go b/cmd/ctl/database/pro/seed/datadictionary.go new file mode 100644 index 00000000..e01a29a5 --- /dev/null +++ b/cmd/ctl/database/pro/seed/datadictionary.go @@ -0,0 +1,17 @@ +package seed + +import ( + "PowerX/internal/model" + "PowerX/internal/uc/powerx" + "gorm.io/gorm" +) + +var UseCaseDD *powerx.DataDictionaryUseCase + +func ProDataDictionary(db *gorm.DB) (data []*model.DataDictionaryType) { + + UseCaseDD = powerx.NewDataDictionaryUseCase(db) + + return data + +} diff --git a/cmd/ctl/database/pro/seed/pro.go b/cmd/ctl/database/pro/seed/pro.go new file mode 100644 index 00000000..fb1e8f34 --- /dev/null +++ b/cmd/ctl/database/pro/seed/pro.go @@ -0,0 +1,9 @@ +package seed + +import ( + "gorm.io/gorm" +) + +func CreateProSeeds(db *gorm.DB) { + +} diff --git a/cmd/ctl/database/seed/datadictionary/datadictionary.go b/cmd/ctl/database/seed/datadictionary/datadictionary.go index 6f979d28..9078a2fb 100644 --- a/cmd/ctl/database/seed/datadictionary/datadictionary.go +++ b/cmd/ctl/database/seed/datadictionary/datadictionary.go @@ -1,7 +1,8 @@ package datadictionary import ( - "PowerX/cmd/ctl/database/custom/seed" + seedCustom "PowerX/cmd/ctl/database/custom/seed" + seedPro "PowerX/cmd/ctl/database/pro/seed" "PowerX/internal/model" "PowerX/internal/uc/powerx" "PowerX/pkg/slicex" @@ -20,8 +21,9 @@ func CreateDataDictionaries(db *gorm.DB) (err error) { UseCaseDD = powerx.NewDataDictionaryUseCase(db) data := DefaultDataDictionary() - customData := seed.CustomDataDictionary(db) - data = slicex.Concatenate(data, customData) + proData := seedPro.ProDataDictionary(db) + customData := seedCustom.CustomDataDictionary(db) + data = slicex.Concatenate(data, proData, customData) if count == 0 { if err = db.Model(&model.DataDictionaryType{}).Create(data).Error; err != nil { diff --git a/cmd/ctl/database/seed/powerx.go b/cmd/ctl/database/seed/powerx.go index cdc50ad1..adc26829 100644 --- a/cmd/ctl/database/seed/powerx.go +++ b/cmd/ctl/database/seed/powerx.go @@ -1,7 +1,8 @@ package seed import ( - "PowerX/cmd/ctl/database/custom/seed" + seedCustom "PowerX/cmd/ctl/database/custom/seed" + seedPro "PowerX/cmd/ctl/database/pro/seed" "PowerX/cmd/ctl/database/seed/datadictionary" "PowerX/internal/config" "gorm.io/driver/mysql" @@ -60,8 +61,11 @@ func (s *PowerSeeder) CreatePowerX() (err error) { // Marketing _ = CreateMGMRules(s.db) + // pro + seedPro.CreateProSeeds(s.db) + // custom - seed.CreateCustomSeeds(s.db) + seedCustom.CreateCustomSeeds(s.db) return }