// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.

package dao

import (
	"context"
	"database/sql"

	"gorm.io/gorm"

	"gorm.io/gen"

	"gorm.io/plugin/dbresolver"
)

var (
	Q                      = new(Query)
	Activities             *activities
	ActivityCategories     *activityCategories
	ActivityDrawEffects    *activityDrawEffects
	ActivityDrawLogs       *activityDrawLogs
	ActivityDrawReceipts   *activityDrawReceipts
	ActivityIssues         *activityIssues
	ActivityRewardSettings *activityRewardSettings
	Admin                  *admin
	AuditRollbackLogs      *auditRollbackLogs
	Banner                 *banner
	Channels               *channels
	DouyinBlacklist        *douyinBlacklist
	DouyinOrders           *douyinOrders
	DouyinProductRewards   *douyinProductRewards
	GamePassPackages       *gamePassPackages
	GameTicketLogs         *gameTicketLogs
	IssuePositionClaims    *issuePositionClaims
	LivestreamActivities   *livestreamActivities
	LivestreamDrawLogs     *livestreamDrawLogs
	LivestreamPrizes       *livestreamPrizes
	LogOperation           *logOperation
	LogRequest             *logRequest
	LotteryRefundLogs      *lotteryRefundLogs
	MatchingCardTypes      *matchingCardTypes
	MenuActions            *menuActions
	Menus                  *menus
	OpsShippingStats       *opsShippingStats
	OrderCoupons           *orderCoupons
	OrderItems             *orderItems
	OrderSnapshots         *orderSnapshots
	Orders                 *orders
	PaymentBillDiff        *paymentBillDiff
	PaymentBills           *paymentBills
	PaymentNotifyEvents    *paymentNotifyEvents
	PaymentPreorders       *paymentPreorders
	PaymentRefunds         *paymentRefunds
	PaymentTransactions    *paymentTransactions
	ProductCategories      *productCategories
	Products               *products
	RoleActions            *roleActions
	RoleMenus              *roleMenus
	RoleUsers              *roleUsers
	Roles                  *roles
	ShippingRecords        *shippingRecords
	SystemConfigs          *systemConfigs
	SystemCoupons          *systemCoupons
	SystemItemCards        *systemItemCards
	SystemTitleEffects     *systemTitleEffects
	SystemTitles           *systemTitles
	TaskCenterEventLogs    *taskCenterEventLogs
	TaskCenterTaskRewards  *taskCenterTaskRewards
	TaskCenterTaskTiers    *taskCenterTaskTiers
	TaskCenterTasks        *taskCenterTasks
	TaskCenterUserProgress *taskCenterUserProgress
	UserAddresses          *userAddresses
	UserCouponLedger       *userCouponLedger
	UserCoupons            *userCoupons
	UserGamePasses         *userGamePasses
	UserGameTickets        *userGameTickets
	UserInventory          *userInventory
	UserInventoryTransfers *userInventoryTransfers
	UserInvites            *userInvites
	UserItemCards          *userItemCards
	UserPoints             *userPoints
	UserPointsLedger       *userPointsLedger
	UserTitleEffectClaims  *userTitleEffectClaims
	UserTitles             *userTitles
	Users                  *users
)

func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
	*Q = *Use(db, opts...)
	Activities = &Q.Activities
	ActivityCategories = &Q.ActivityCategories
	ActivityDrawEffects = &Q.ActivityDrawEffects
	ActivityDrawLogs = &Q.ActivityDrawLogs
	ActivityDrawReceipts = &Q.ActivityDrawReceipts
	ActivityIssues = &Q.ActivityIssues
	ActivityRewardSettings = &Q.ActivityRewardSettings
	Admin = &Q.Admin
	AuditRollbackLogs = &Q.AuditRollbackLogs
	Banner = &Q.Banner
	Channels = &Q.Channels
	DouyinBlacklist = &Q.DouyinBlacklist
	DouyinOrders = &Q.DouyinOrders
	DouyinProductRewards = &Q.DouyinProductRewards
	GamePassPackages = &Q.GamePassPackages
	GameTicketLogs = &Q.GameTicketLogs
	IssuePositionClaims = &Q.IssuePositionClaims
	LivestreamActivities = &Q.LivestreamActivities
	LivestreamDrawLogs = &Q.LivestreamDrawLogs
	LivestreamPrizes = &Q.LivestreamPrizes
	LogOperation = &Q.LogOperation
	LogRequest = &Q.LogRequest
	LotteryRefundLogs = &Q.LotteryRefundLogs
	MatchingCardTypes = &Q.MatchingCardTypes
	MenuActions = &Q.MenuActions
	Menus = &Q.Menus
	OpsShippingStats = &Q.OpsShippingStats
	OrderCoupons = &Q.OrderCoupons
	OrderItems = &Q.OrderItems
	OrderSnapshots = &Q.OrderSnapshots
	Orders = &Q.Orders
	PaymentBillDiff = &Q.PaymentBillDiff
	PaymentBills = &Q.PaymentBills
	PaymentNotifyEvents = &Q.PaymentNotifyEvents
	PaymentPreorders = &Q.PaymentPreorders
	PaymentRefunds = &Q.PaymentRefunds
	PaymentTransactions = &Q.PaymentTransactions
	ProductCategories = &Q.ProductCategories
	Products = &Q.Products
	RoleActions = &Q.RoleActions
	RoleMenus = &Q.RoleMenus
	RoleUsers = &Q.RoleUsers
	Roles = &Q.Roles
	ShippingRecords = &Q.ShippingRecords
	SystemConfigs = &Q.SystemConfigs
	SystemCoupons = &Q.SystemCoupons
	SystemItemCards = &Q.SystemItemCards
	SystemTitleEffects = &Q.SystemTitleEffects
	SystemTitles = &Q.SystemTitles
	TaskCenterEventLogs = &Q.TaskCenterEventLogs
	TaskCenterTaskRewards = &Q.TaskCenterTaskRewards
	TaskCenterTaskTiers = &Q.TaskCenterTaskTiers
	TaskCenterTasks = &Q.TaskCenterTasks
	TaskCenterUserProgress = &Q.TaskCenterUserProgress
	UserAddresses = &Q.UserAddresses
	UserCouponLedger = &Q.UserCouponLedger
	UserCoupons = &Q.UserCoupons
	UserGamePasses = &Q.UserGamePasses
	UserGameTickets = &Q.UserGameTickets
	UserInventory = &Q.UserInventory
	UserInventoryTransfers = &Q.UserInventoryTransfers
	UserInvites = &Q.UserInvites
	UserItemCards = &Q.UserItemCards
	UserPoints = &Q.UserPoints
	UserPointsLedger = &Q.UserPointsLedger
	UserTitleEffectClaims = &Q.UserTitleEffectClaims
	UserTitles = &Q.UserTitles
	Users = &Q.Users
}

func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
	return &Query{
		db:                     db,
		Activities:             newActivities(db, opts...),
		ActivityCategories:     newActivityCategories(db, opts...),
		ActivityDrawEffects:    newActivityDrawEffects(db, opts...),
		ActivityDrawLogs:       newActivityDrawLogs(db, opts...),
		ActivityDrawReceipts:   newActivityDrawReceipts(db, opts...),
		ActivityIssues:         newActivityIssues(db, opts...),
		ActivityRewardSettings: newActivityRewardSettings(db, opts...),
		Admin:                  newAdmin(db, opts...),
		AuditRollbackLogs:      newAuditRollbackLogs(db, opts...),
		Banner:                 newBanner(db, opts...),
		Channels:               newChannels(db, opts...),
		DouyinBlacklist:        newDouyinBlacklist(db, opts...),
		DouyinOrders:           newDouyinOrders(db, opts...),
		DouyinProductRewards:   newDouyinProductRewards(db, opts...),
		GamePassPackages:       newGamePassPackages(db, opts...),
		GameTicketLogs:         newGameTicketLogs(db, opts...),
		IssuePositionClaims:    newIssuePositionClaims(db, opts...),
		LivestreamActivities:   newLivestreamActivities(db, opts...),
		LivestreamDrawLogs:     newLivestreamDrawLogs(db, opts...),
		LivestreamPrizes:       newLivestreamPrizes(db, opts...),
		LogOperation:           newLogOperation(db, opts...),
		LogRequest:             newLogRequest(db, opts...),
		LotteryRefundLogs:      newLotteryRefundLogs(db, opts...),
		MatchingCardTypes:      newMatchingCardTypes(db, opts...),
		MenuActions:            newMenuActions(db, opts...),
		Menus:                  newMenus(db, opts...),
		OpsShippingStats:       newOpsShippingStats(db, opts...),
		OrderCoupons:           newOrderCoupons(db, opts...),
		OrderItems:             newOrderItems(db, opts...),
		OrderSnapshots:         newOrderSnapshots(db, opts...),
		Orders:                 newOrders(db, opts...),
		PaymentBillDiff:        newPaymentBillDiff(db, opts...),
		PaymentBills:           newPaymentBills(db, opts...),
		PaymentNotifyEvents:    newPaymentNotifyEvents(db, opts...),
		PaymentPreorders:       newPaymentPreorders(db, opts...),
		PaymentRefunds:         newPaymentRefunds(db, opts...),
		PaymentTransactions:    newPaymentTransactions(db, opts...),
		ProductCategories:      newProductCategories(db, opts...),
		Products:               newProducts(db, opts...),
		RoleActions:            newRoleActions(db, opts...),
		RoleMenus:              newRoleMenus(db, opts...),
		RoleUsers:              newRoleUsers(db, opts...),
		Roles:                  newRoles(db, opts...),
		ShippingRecords:        newShippingRecords(db, opts...),
		SystemConfigs:          newSystemConfigs(db, opts...),
		SystemCoupons:          newSystemCoupons(db, opts...),
		SystemItemCards:        newSystemItemCards(db, opts...),
		SystemTitleEffects:     newSystemTitleEffects(db, opts...),
		SystemTitles:           newSystemTitles(db, opts...),
		TaskCenterEventLogs:    newTaskCenterEventLogs(db, opts...),
		TaskCenterTaskRewards:  newTaskCenterTaskRewards(db, opts...),
		TaskCenterTaskTiers:    newTaskCenterTaskTiers(db, opts...),
		TaskCenterTasks:        newTaskCenterTasks(db, opts...),
		TaskCenterUserProgress: newTaskCenterUserProgress(db, opts...),
		UserAddresses:          newUserAddresses(db, opts...),
		UserCouponLedger:       newUserCouponLedger(db, opts...),
		UserCoupons:            newUserCoupons(db, opts...),
		UserGamePasses:         newUserGamePasses(db, opts...),
		UserGameTickets:        newUserGameTickets(db, opts...),
		UserInventory:          newUserInventory(db, opts...),
		UserInventoryTransfers: newUserInventoryTransfers(db, opts...),
		UserInvites:            newUserInvites(db, opts...),
		UserItemCards:          newUserItemCards(db, opts...),
		UserPoints:             newUserPoints(db, opts...),
		UserPointsLedger:       newUserPointsLedger(db, opts...),
		UserTitleEffectClaims:  newUserTitleEffectClaims(db, opts...),
		UserTitles:             newUserTitles(db, opts...),
		Users:                  newUsers(db, opts...),
	}
}

type Query struct {
	db *gorm.DB

	Activities             activities
	ActivityCategories     activityCategories
	ActivityDrawEffects    activityDrawEffects
	ActivityDrawLogs       activityDrawLogs
	ActivityDrawReceipts   activityDrawReceipts
	ActivityIssues         activityIssues
	ActivityRewardSettings activityRewardSettings
	Admin                  admin
	AuditRollbackLogs      auditRollbackLogs
	Banner                 banner
	Channels               channels
	DouyinBlacklist        douyinBlacklist
	DouyinOrders           douyinOrders
	DouyinProductRewards   douyinProductRewards
	GamePassPackages       gamePassPackages
	GameTicketLogs         gameTicketLogs
	IssuePositionClaims    issuePositionClaims
	LivestreamActivities   livestreamActivities
	LivestreamDrawLogs     livestreamDrawLogs
	LivestreamPrizes       livestreamPrizes
	LogOperation           logOperation
	LogRequest             logRequest
	LotteryRefundLogs      lotteryRefundLogs
	MatchingCardTypes      matchingCardTypes
	MenuActions            menuActions
	Menus                  menus
	OpsShippingStats       opsShippingStats
	OrderCoupons           orderCoupons
	OrderItems             orderItems
	OrderSnapshots         orderSnapshots
	Orders                 orders
	PaymentBillDiff        paymentBillDiff
	PaymentBills           paymentBills
	PaymentNotifyEvents    paymentNotifyEvents
	PaymentPreorders       paymentPreorders
	PaymentRefunds         paymentRefunds
	PaymentTransactions    paymentTransactions
	ProductCategories      productCategories
	Products               products
	RoleActions            roleActions
	RoleMenus              roleMenus
	RoleUsers              roleUsers
	Roles                  roles
	ShippingRecords        shippingRecords
	SystemConfigs          systemConfigs
	SystemCoupons          systemCoupons
	SystemItemCards        systemItemCards
	SystemTitleEffects     systemTitleEffects
	SystemTitles           systemTitles
	TaskCenterEventLogs    taskCenterEventLogs
	TaskCenterTaskRewards  taskCenterTaskRewards
	TaskCenterTaskTiers    taskCenterTaskTiers
	TaskCenterTasks        taskCenterTasks
	TaskCenterUserProgress taskCenterUserProgress
	UserAddresses          userAddresses
	UserCouponLedger       userCouponLedger
	UserCoupons            userCoupons
	UserGamePasses         userGamePasses
	UserGameTickets        userGameTickets
	UserInventory          userInventory
	UserInventoryTransfers userInventoryTransfers
	UserInvites            userInvites
	UserItemCards          userItemCards
	UserPoints             userPoints
	UserPointsLedger       userPointsLedger
	UserTitleEffectClaims  userTitleEffectClaims
	UserTitles             userTitles
	Users                  users
}

func (q *Query) Available() bool { return q.db != nil }

func (q *Query) clone(db *gorm.DB) *Query {
	return &Query{
		db:                     db,
		Activities:             q.Activities.clone(db),
		ActivityCategories:     q.ActivityCategories.clone(db),
		ActivityDrawEffects:    q.ActivityDrawEffects.clone(db),
		ActivityDrawLogs:       q.ActivityDrawLogs.clone(db),
		ActivityDrawReceipts:   q.ActivityDrawReceipts.clone(db),
		ActivityIssues:         q.ActivityIssues.clone(db),
		ActivityRewardSettings: q.ActivityRewardSettings.clone(db),
		Admin:                  q.Admin.clone(db),
		AuditRollbackLogs:      q.AuditRollbackLogs.clone(db),
		Banner:                 q.Banner.clone(db),
		Channels:               q.Channels.clone(db),
		DouyinBlacklist:        q.DouyinBlacklist.clone(db),
		DouyinOrders:           q.DouyinOrders.clone(db),
		DouyinProductRewards:   q.DouyinProductRewards.clone(db),
		GamePassPackages:       q.GamePassPackages.clone(db),
		GameTicketLogs:         q.GameTicketLogs.clone(db),
		IssuePositionClaims:    q.IssuePositionClaims.clone(db),
		LivestreamActivities:   q.LivestreamActivities.clone(db),
		LivestreamDrawLogs:     q.LivestreamDrawLogs.clone(db),
		LivestreamPrizes:       q.LivestreamPrizes.clone(db),
		LogOperation:           q.LogOperation.clone(db),
		LogRequest:             q.LogRequest.clone(db),
		LotteryRefundLogs:      q.LotteryRefundLogs.clone(db),
		MatchingCardTypes:      q.MatchingCardTypes.clone(db),
		MenuActions:            q.MenuActions.clone(db),
		Menus:                  q.Menus.clone(db),
		OpsShippingStats:       q.OpsShippingStats.clone(db),
		OrderCoupons:           q.OrderCoupons.clone(db),
		OrderItems:             q.OrderItems.clone(db),
		OrderSnapshots:         q.OrderSnapshots.clone(db),
		Orders:                 q.Orders.clone(db),
		PaymentBillDiff:        q.PaymentBillDiff.clone(db),
		PaymentBills:           q.PaymentBills.clone(db),
		PaymentNotifyEvents:    q.PaymentNotifyEvents.clone(db),
		PaymentPreorders:       q.PaymentPreorders.clone(db),
		PaymentRefunds:         q.PaymentRefunds.clone(db),
		PaymentTransactions:    q.PaymentTransactions.clone(db),
		ProductCategories:      q.ProductCategories.clone(db),
		Products:               q.Products.clone(db),
		RoleActions:            q.RoleActions.clone(db),
		RoleMenus:              q.RoleMenus.clone(db),
		RoleUsers:              q.RoleUsers.clone(db),
		Roles:                  q.Roles.clone(db),
		ShippingRecords:        q.ShippingRecords.clone(db),
		SystemConfigs:          q.SystemConfigs.clone(db),
		SystemCoupons:          q.SystemCoupons.clone(db),
		SystemItemCards:        q.SystemItemCards.clone(db),
		SystemTitleEffects:     q.SystemTitleEffects.clone(db),
		SystemTitles:           q.SystemTitles.clone(db),
		TaskCenterEventLogs:    q.TaskCenterEventLogs.clone(db),
		TaskCenterTaskRewards:  q.TaskCenterTaskRewards.clone(db),
		TaskCenterTaskTiers:    q.TaskCenterTaskTiers.clone(db),
		TaskCenterTasks:        q.TaskCenterTasks.clone(db),
		TaskCenterUserProgress: q.TaskCenterUserProgress.clone(db),
		UserAddresses:          q.UserAddresses.clone(db),
		UserCouponLedger:       q.UserCouponLedger.clone(db),
		UserCoupons:            q.UserCoupons.clone(db),
		UserGamePasses:         q.UserGamePasses.clone(db),
		UserGameTickets:        q.UserGameTickets.clone(db),
		UserInventory:          q.UserInventory.clone(db),
		UserInventoryTransfers: q.UserInventoryTransfers.clone(db),
		UserInvites:            q.UserInvites.clone(db),
		UserItemCards:          q.UserItemCards.clone(db),
		UserPoints:             q.UserPoints.clone(db),
		UserPointsLedger:       q.UserPointsLedger.clone(db),
		UserTitleEffectClaims:  q.UserTitleEffectClaims.clone(db),
		UserTitles:             q.UserTitles.clone(db),
		Users:                  q.Users.clone(db),
	}
}

func (q *Query) ReadDB() *Query {
	return q.ReplaceDB(q.db.Clauses(dbresolver.Read))
}

func (q *Query) WriteDB() *Query {
	return q.ReplaceDB(q.db.Clauses(dbresolver.Write))
}

func (q *Query) ReplaceDB(db *gorm.DB) *Query {
	return &Query{
		db:                     db,
		Activities:             q.Activities.replaceDB(db),
		ActivityCategories:     q.ActivityCategories.replaceDB(db),
		ActivityDrawEffects:    q.ActivityDrawEffects.replaceDB(db),
		ActivityDrawLogs:       q.ActivityDrawLogs.replaceDB(db),
		ActivityDrawReceipts:   q.ActivityDrawReceipts.replaceDB(db),
		ActivityIssues:         q.ActivityIssues.replaceDB(db),
		ActivityRewardSettings: q.ActivityRewardSettings.replaceDB(db),
		Admin:                  q.Admin.replaceDB(db),
		AuditRollbackLogs:      q.AuditRollbackLogs.replaceDB(db),
		Banner:                 q.Banner.replaceDB(db),
		Channels:               q.Channels.replaceDB(db),
		DouyinBlacklist:        q.DouyinBlacklist.replaceDB(db),
		DouyinOrders:           q.DouyinOrders.replaceDB(db),
		DouyinProductRewards:   q.DouyinProductRewards.replaceDB(db),
		GamePassPackages:       q.GamePassPackages.replaceDB(db),
		GameTicketLogs:         q.GameTicketLogs.replaceDB(db),
		IssuePositionClaims:    q.IssuePositionClaims.replaceDB(db),
		LivestreamActivities:   q.LivestreamActivities.replaceDB(db),
		LivestreamDrawLogs:     q.LivestreamDrawLogs.replaceDB(db),
		LivestreamPrizes:       q.LivestreamPrizes.replaceDB(db),
		LogOperation:           q.LogOperation.replaceDB(db),
		LogRequest:             q.LogRequest.replaceDB(db),
		LotteryRefundLogs:      q.LotteryRefundLogs.replaceDB(db),
		MatchingCardTypes:      q.MatchingCardTypes.replaceDB(db),
		MenuActions:            q.MenuActions.replaceDB(db),
		Menus:                  q.Menus.replaceDB(db),
		OpsShippingStats:       q.OpsShippingStats.replaceDB(db),
		OrderCoupons:           q.OrderCoupons.replaceDB(db),
		OrderItems:             q.OrderItems.replaceDB(db),
		OrderSnapshots:         q.OrderSnapshots.replaceDB(db),
		Orders:                 q.Orders.replaceDB(db),
		PaymentBillDiff:        q.PaymentBillDiff.replaceDB(db),
		PaymentBills:           q.PaymentBills.replaceDB(db),
		PaymentNotifyEvents:    q.PaymentNotifyEvents.replaceDB(db),
		PaymentPreorders:       q.PaymentPreorders.replaceDB(db),
		PaymentRefunds:         q.PaymentRefunds.replaceDB(db),
		PaymentTransactions:    q.PaymentTransactions.replaceDB(db),
		ProductCategories:      q.ProductCategories.replaceDB(db),
		Products:               q.Products.replaceDB(db),
		RoleActions:            q.RoleActions.replaceDB(db),
		RoleMenus:              q.RoleMenus.replaceDB(db),
		RoleUsers:              q.RoleUsers.replaceDB(db),
		Roles:                  q.Roles.replaceDB(db),
		ShippingRecords:        q.ShippingRecords.replaceDB(db),
		SystemConfigs:          q.SystemConfigs.replaceDB(db),
		SystemCoupons:          q.SystemCoupons.replaceDB(db),
		SystemItemCards:        q.SystemItemCards.replaceDB(db),
		SystemTitleEffects:     q.SystemTitleEffects.replaceDB(db),
		SystemTitles:           q.SystemTitles.replaceDB(db),
		TaskCenterEventLogs:    q.TaskCenterEventLogs.replaceDB(db),
		TaskCenterTaskRewards:  q.TaskCenterTaskRewards.replaceDB(db),
		TaskCenterTaskTiers:    q.TaskCenterTaskTiers.replaceDB(db),
		TaskCenterTasks:        q.TaskCenterTasks.replaceDB(db),
		TaskCenterUserProgress: q.TaskCenterUserProgress.replaceDB(db),
		UserAddresses:          q.UserAddresses.replaceDB(db),
		UserCouponLedger:       q.UserCouponLedger.replaceDB(db),
		UserCoupons:            q.UserCoupons.replaceDB(db),
		UserGamePasses:         q.UserGamePasses.replaceDB(db),
		UserGameTickets:        q.UserGameTickets.replaceDB(db),
		UserInventory:          q.UserInventory.replaceDB(db),
		UserInventoryTransfers: q.UserInventoryTransfers.replaceDB(db),
		UserInvites:            q.UserInvites.replaceDB(db),
		UserItemCards:          q.UserItemCards.replaceDB(db),
		UserPoints:             q.UserPoints.replaceDB(db),
		UserPointsLedger:       q.UserPointsLedger.replaceDB(db),
		UserTitleEffectClaims:  q.UserTitleEffectClaims.replaceDB(db),
		UserTitles:             q.UserTitles.replaceDB(db),
		Users:                  q.Users.replaceDB(db),
	}
}

type queryCtx struct {
	Activities             *activitiesDo
	ActivityCategories     *activityCategoriesDo
	ActivityDrawEffects    *activityDrawEffectsDo
	ActivityDrawLogs       *activityDrawLogsDo
	ActivityDrawReceipts   *activityDrawReceiptsDo
	ActivityIssues         *activityIssuesDo
	ActivityRewardSettings *activityRewardSettingsDo
	Admin                  *adminDo
	AuditRollbackLogs      *auditRollbackLogsDo
	Banner                 *bannerDo
	Channels               *channelsDo
	DouyinBlacklist        *douyinBlacklistDo
	DouyinOrders           *douyinOrdersDo
	DouyinProductRewards   *douyinProductRewardsDo
	GamePassPackages       *gamePassPackagesDo
	GameTicketLogs         *gameTicketLogsDo
	IssuePositionClaims    *issuePositionClaimsDo
	LivestreamActivities   *livestreamActivitiesDo
	LivestreamDrawLogs     *livestreamDrawLogsDo
	LivestreamPrizes       *livestreamPrizesDo
	LogOperation           *logOperationDo
	LogRequest             *logRequestDo
	LotteryRefundLogs      *lotteryRefundLogsDo
	MatchingCardTypes      *matchingCardTypesDo
	MenuActions            *menuActionsDo
	Menus                  *menusDo
	OpsShippingStats       *opsShippingStatsDo
	OrderCoupons           *orderCouponsDo
	OrderItems             *orderItemsDo
	OrderSnapshots         *orderSnapshotsDo
	Orders                 *ordersDo
	PaymentBillDiff        *paymentBillDiffDo
	PaymentBills           *paymentBillsDo
	PaymentNotifyEvents    *paymentNotifyEventsDo
	PaymentPreorders       *paymentPreordersDo
	PaymentRefunds         *paymentRefundsDo
	PaymentTransactions    *paymentTransactionsDo
	ProductCategories      *productCategoriesDo
	Products               *productsDo
	RoleActions            *roleActionsDo
	RoleMenus              *roleMenusDo
	RoleUsers              *roleUsersDo
	Roles                  *rolesDo
	ShippingRecords        *shippingRecordsDo
	SystemConfigs          *systemConfigsDo
	SystemCoupons          *systemCouponsDo
	SystemItemCards        *systemItemCardsDo
	SystemTitleEffects     *systemTitleEffectsDo
	SystemTitles           *systemTitlesDo
	TaskCenterEventLogs    *taskCenterEventLogsDo
	TaskCenterTaskRewards  *taskCenterTaskRewardsDo
	TaskCenterTaskTiers    *taskCenterTaskTiersDo
	TaskCenterTasks        *taskCenterTasksDo
	TaskCenterUserProgress *taskCenterUserProgressDo
	UserAddresses          *userAddressesDo
	UserCouponLedger       *userCouponLedgerDo
	UserCoupons            *userCouponsDo
	UserGamePasses         *userGamePassesDo
	UserGameTickets        *userGameTicketsDo
	UserInventory          *userInventoryDo
	UserInventoryTransfers *userInventoryTransfersDo
	UserInvites            *userInvitesDo
	UserItemCards          *userItemCardsDo
	UserPoints             *userPointsDo
	UserPointsLedger       *userPointsLedgerDo
	UserTitleEffectClaims  *userTitleEffectClaimsDo
	UserTitles             *userTitlesDo
	Users                  *usersDo
}

func (q *Query) WithContext(ctx context.Context) *queryCtx {
	return &queryCtx{
		Activities:             q.Activities.WithContext(ctx),
		ActivityCategories:     q.ActivityCategories.WithContext(ctx),
		ActivityDrawEffects:    q.ActivityDrawEffects.WithContext(ctx),
		ActivityDrawLogs:       q.ActivityDrawLogs.WithContext(ctx),
		ActivityDrawReceipts:   q.ActivityDrawReceipts.WithContext(ctx),
		ActivityIssues:         q.ActivityIssues.WithContext(ctx),
		ActivityRewardSettings: q.ActivityRewardSettings.WithContext(ctx),
		Admin:                  q.Admin.WithContext(ctx),
		AuditRollbackLogs:      q.AuditRollbackLogs.WithContext(ctx),
		Banner:                 q.Banner.WithContext(ctx),
		Channels:               q.Channels.WithContext(ctx),
		DouyinBlacklist:        q.DouyinBlacklist.WithContext(ctx),
		DouyinOrders:           q.DouyinOrders.WithContext(ctx),
		DouyinProductRewards:   q.DouyinProductRewards.WithContext(ctx),
		GamePassPackages:       q.GamePassPackages.WithContext(ctx),
		GameTicketLogs:         q.GameTicketLogs.WithContext(ctx),
		IssuePositionClaims:    q.IssuePositionClaims.WithContext(ctx),
		LivestreamActivities:   q.LivestreamActivities.WithContext(ctx),
		LivestreamDrawLogs:     q.LivestreamDrawLogs.WithContext(ctx),
		LivestreamPrizes:       q.LivestreamPrizes.WithContext(ctx),
		LogOperation:           q.LogOperation.WithContext(ctx),
		LogRequest:             q.LogRequest.WithContext(ctx),
		LotteryRefundLogs:      q.LotteryRefundLogs.WithContext(ctx),
		MatchingCardTypes:      q.MatchingCardTypes.WithContext(ctx),
		MenuActions:            q.MenuActions.WithContext(ctx),
		Menus:                  q.Menus.WithContext(ctx),
		OpsShippingStats:       q.OpsShippingStats.WithContext(ctx),
		OrderCoupons:           q.OrderCoupons.WithContext(ctx),
		OrderItems:             q.OrderItems.WithContext(ctx),
		OrderSnapshots:         q.OrderSnapshots.WithContext(ctx),
		Orders:                 q.Orders.WithContext(ctx),
		PaymentBillDiff:        q.PaymentBillDiff.WithContext(ctx),
		PaymentBills:           q.PaymentBills.WithContext(ctx),
		PaymentNotifyEvents:    q.PaymentNotifyEvents.WithContext(ctx),
		PaymentPreorders:       q.PaymentPreorders.WithContext(ctx),
		PaymentRefunds:         q.PaymentRefunds.WithContext(ctx),
		PaymentTransactions:    q.PaymentTransactions.WithContext(ctx),
		ProductCategories:      q.ProductCategories.WithContext(ctx),
		Products:               q.Products.WithContext(ctx),
		RoleActions:            q.RoleActions.WithContext(ctx),
		RoleMenus:              q.RoleMenus.WithContext(ctx),
		RoleUsers:              q.RoleUsers.WithContext(ctx),
		Roles:                  q.Roles.WithContext(ctx),
		ShippingRecords:        q.ShippingRecords.WithContext(ctx),
		SystemConfigs:          q.SystemConfigs.WithContext(ctx),
		SystemCoupons:          q.SystemCoupons.WithContext(ctx),
		SystemItemCards:        q.SystemItemCards.WithContext(ctx),
		SystemTitleEffects:     q.SystemTitleEffects.WithContext(ctx),
		SystemTitles:           q.SystemTitles.WithContext(ctx),
		TaskCenterEventLogs:    q.TaskCenterEventLogs.WithContext(ctx),
		TaskCenterTaskRewards:  q.TaskCenterTaskRewards.WithContext(ctx),
		TaskCenterTaskTiers:    q.TaskCenterTaskTiers.WithContext(ctx),
		TaskCenterTasks:        q.TaskCenterTasks.WithContext(ctx),
		TaskCenterUserProgress: q.TaskCenterUserProgress.WithContext(ctx),
		UserAddresses:          q.UserAddresses.WithContext(ctx),
		UserCouponLedger:       q.UserCouponLedger.WithContext(ctx),
		UserCoupons:            q.UserCoupons.WithContext(ctx),
		UserGamePasses:         q.UserGamePasses.WithContext(ctx),
		UserGameTickets:        q.UserGameTickets.WithContext(ctx),
		UserInventory:          q.UserInventory.WithContext(ctx),
		UserInventoryTransfers: q.UserInventoryTransfers.WithContext(ctx),
		UserInvites:            q.UserInvites.WithContext(ctx),
		UserItemCards:          q.UserItemCards.WithContext(ctx),
		UserPoints:             q.UserPoints.WithContext(ctx),
		UserPointsLedger:       q.UserPointsLedger.WithContext(ctx),
		UserTitleEffectClaims:  q.UserTitleEffectClaims.WithContext(ctx),
		UserTitles:             q.UserTitles.WithContext(ctx),
		Users:                  q.Users.WithContext(ctx),
	}
}

func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error {
	return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...)
}

func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx {
	tx := q.db.Begin(opts...)
	return &QueryTx{Query: q.clone(tx), Error: tx.Error}
}

type QueryTx struct {
	*Query
	Error error
}

func (q *QueryTx) Commit() error {
	return q.db.Commit().Error
}

func (q *QueryTx) Rollback() error {
	return q.db.Rollback().Error
}

func (q *QueryTx) SavePoint(name string) error {
	return q.db.SavePoint(name).Error
}

func (q *QueryTx) RollbackTo(name string) error {
	return q.db.RollbackTo(name).Error
}
