package bootstrap

import (
	"github.com/break/junhong_cmp_fiber/internal/store/postgres"
	"github.com/break/junhong_cmp_fiber/pkg/queue"
)

type workerStores struct {
	AssetOperationLog          *postgres.AssetOperationLogStore
	AssetAllocationRecord      *postgres.AssetAllocationRecordStore
	IotCardImportTask          *postgres.IotCardImportTaskStore
	IotCard                    *postgres.IotCardStore
	DeviceImportTask           *postgres.DeviceImportTaskStore
	ExportTask                 *postgres.ExportTaskStore
	ExportShardTask            *postgres.ExportShardTaskStore
	Device                     *postgres.DeviceStore
	DeviceSimBinding           *postgres.DeviceSimBindingStore
	ShopSeriesCommissionStats  *postgres.ShopSeriesCommissionStatsStore
	ShopPackageAllocation      *postgres.ShopPackageAllocationStore
	CommissionRecord           *postgres.CommissionRecordStore
	Shop                       *postgres.ShopStore
	ShopSeriesAllocation       *postgres.ShopSeriesAllocationStore
	PackageSeries              *postgres.PackageSeriesStore
	Order                      *postgres.OrderStore
	OrderItem                  *postgres.OrderItemStore
	Package                    *postgres.PackageStore
	PackageUsage               *postgres.PackageUsageStore
	PackageUsageDailyRecord    *postgres.PackageUsageDailyRecordStore
	PollingAlertRule           *postgres.PollingAlertRuleStore
	PollingAlertHistory        *postgres.PollingAlertHistoryStore
	DataCleanupConfig          *postgres.DataCleanupConfigStore
	DataCleanupLog             *postgres.DataCleanupLogStore
	AgentWallet                *postgres.AgentWalletStore
	AgentWalletTransaction     *postgres.AgentWalletTransactionStore
	AssetWallet                *postgres.AssetWalletStore
	AssetIdentifier            *postgres.AssetIdentifierStore
	PersonalCustomer           *postgres.PersonalCustomerStore
	PersonalCustomerPhone      *postgres.PersonalCustomerPhoneStore
	OrderPackageInvalidateTask *postgres.OrderPackageInvalidateTaskStore
	AssetPackageBatchOrderTask *postgres.AssetPackageBatchOrderTaskStore
}

func initWorkerStores(deps *WorkerDependencies) *queue.WorkerStores {
	stores := &workerStores{
		AssetOperationLog:          postgres.NewAssetOperationLogStore(deps.DB),
		AssetAllocationRecord:      postgres.NewAssetAllocationRecordStore(deps.DB, deps.Redis),
		IotCardImportTask:          postgres.NewIotCardImportTaskStore(deps.DB, deps.Redis),
		IotCard:                    postgres.NewIotCardStore(deps.DB, deps.Redis),
		DeviceImportTask:           postgres.NewDeviceImportTaskStore(deps.DB, deps.Redis),
		ExportTask:                 postgres.NewExportTaskStore(deps.DB, deps.Redis),
		ExportShardTask:            postgres.NewExportShardTaskStore(deps.DB, deps.Redis),
		Device:                     postgres.NewDeviceStore(deps.DB, deps.Redis),
		DeviceSimBinding:           postgres.NewDeviceSimBindingStore(deps.DB, deps.Redis),
		ShopSeriesCommissionStats:  postgres.NewShopSeriesCommissionStatsStore(deps.DB),
		ShopPackageAllocation:      postgres.NewShopPackageAllocationStore(deps.DB),
		CommissionRecord:           postgres.NewCommissionRecordStore(deps.DB, deps.Redis),
		Shop:                       postgres.NewShopStore(deps.DB, deps.Redis),
		ShopSeriesAllocation:       postgres.NewShopSeriesAllocationStore(deps.DB),
		PackageSeries:              postgres.NewPackageSeriesStore(deps.DB),
		Order:                      postgres.NewOrderStore(deps.DB, deps.Redis),
		OrderItem:                  postgres.NewOrderItemStore(deps.DB, deps.Redis),
		Package:                    postgres.NewPackageStore(deps.DB),
		PackageUsage:               postgres.NewPackageUsageStore(deps.DB, deps.Redis),
		PackageUsageDailyRecord:    postgres.NewPackageUsageDailyRecordStore(deps.DB, deps.Redis),
		PollingAlertRule:           postgres.NewPollingAlertRuleStore(deps.DB),
		PollingAlertHistory:        postgres.NewPollingAlertHistoryStore(deps.DB),
		DataCleanupConfig:          postgres.NewDataCleanupConfigStore(deps.DB),
		DataCleanupLog:             postgres.NewDataCleanupLogStore(deps.DB),
		AgentWallet:                postgres.NewAgentWalletStore(deps.DB, deps.Redis),
		AgentWalletTransaction:     postgres.NewAgentWalletTransactionStore(deps.DB, deps.Redis),
		AssetWallet:                postgres.NewAssetWalletStore(deps.DB, deps.Redis),
		AssetIdentifier:            postgres.NewAssetIdentifierStore(deps.DB),
		PersonalCustomer:           postgres.NewPersonalCustomerStore(deps.DB, deps.Redis),
		PersonalCustomerPhone:      postgres.NewPersonalCustomerPhoneStore(deps.DB),
		OrderPackageInvalidateTask: postgres.NewOrderPackageInvalidateTaskStore(deps.DB),
		AssetPackageBatchOrderTask: postgres.NewAssetPackageBatchOrderTaskStore(deps.DB),
	}

	return &queue.WorkerStores{
		AssetOperationLog:          stores.AssetOperationLog,
		AssetAllocationRecord:      stores.AssetAllocationRecord,
		IotCardImportTask:          stores.IotCardImportTask,
		IotCard:                    stores.IotCard,
		DeviceImportTask:           stores.DeviceImportTask,
		ExportTask:                 stores.ExportTask,
		ExportShardTask:            stores.ExportShardTask,
		Device:                     stores.Device,
		DeviceSimBinding:           stores.DeviceSimBinding,
		ShopSeriesCommissionStats:  stores.ShopSeriesCommissionStats,
		ShopPackageAllocation:      stores.ShopPackageAllocation,
		CommissionRecord:           stores.CommissionRecord,
		Shop:                       stores.Shop,
		ShopSeriesAllocation:       stores.ShopSeriesAllocation,
		PackageSeries:              stores.PackageSeries,
		Order:                      stores.Order,
		OrderItem:                  stores.OrderItem,
		Package:                    stores.Package,
		PackageUsage:               stores.PackageUsage,
		PackageUsageDailyRecord:    stores.PackageUsageDailyRecord,
		PollingAlertRule:           stores.PollingAlertRule,
		PollingAlertHistory:        stores.PollingAlertHistory,
		DataCleanupConfig:          stores.DataCleanupConfig,
		DataCleanupLog:             stores.DataCleanupLog,
		AgentWallet:                stores.AgentWallet,
		AgentWalletTransaction:     stores.AgentWalletTransaction,
		AssetWallet:                stores.AssetWallet,
		AssetIdentifier:            stores.AssetIdentifier,
		PersonalCustomer:           stores.PersonalCustomer,
		PersonalCustomerPhone:      stores.PersonalCustomerPhone,
		OrderPackageInvalidateTask: stores.OrderPackageInvalidateTask,
		AssetPackageBatchOrderTask: stores.AssetPackageBatchOrderTask,
	}
}
