// 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 query

import (
	"context"
	"database/sql"

	"gorm.io/gorm"

	"gorm.io/gen"

	"gorm.io/plugin/dbresolver"
)

func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
	return &Query{
		db:                        db,
		AdminMenu:     newAdminMenu(db, opts...),
		AdminRoleMenu: newAdminRoleMenu(db, opts...),
		AdminRolePermission: newAdminRolePermission(db, opts...),
		AdminPermission: newAdminPermission(db, opts...),
		AdminOperation: newAdminOperation(db, opts...),
		AdminSystem:         newAdminSystem(db, opts...),
		AdminEmail:                newAdminEmail(db, opts...),
		AdminLog:                  newAdminLog(db, opts...),
		AdminNotice:               newAdminNotice(db, opts...),
		AdminRole:                 newAdminRole(db, opts...),
		AdminUser:                 newAdminUser(db, opts...),
		AdvOriginLog:              newAdvOriginLog(db, opts...),
		AdvertisementLog:          newAdvertisementLog(db, opts...),
		AdvertisementSpace:        newAdvertisementSpace(db, opts...),
		BossLog:                   newBossLog(db, opts...),
		Bosswar:                   newBosswar(db, opts...),
		BuyStamina:                newBuyStamina(db, opts...),
		Cache:                     newCache(db, opts...),
		ChangedLog:                newChangedLog(db, opts...),
		ChangedPlayer:             newChangedPlayer(db, opts...),
		ChangedStatistic:          newChangedStatistic(db, opts...),
		ChangedSync:               newChangedSync(db, opts...),
		Channel:                   newChannel(db, opts...),
		Chapter:                   newChapter(db, opts...),
		ChapterLog:                newChapterLog(db, opts...),
		ChapterLogsUserDetail:     newChapterLogsUserDetail(db, opts...),
		ChapterSync:               newChapterSync(db, opts...),
		ClientDatum:               newClientDatum(db, opts...),
		Climbfloor:                newClimbfloor(db, opts...),
		Config:                    newConfig(db, opts...),
		Curiomake:                 newCuriomake(db, opts...),
		CustomerServiceChatLog:    newCustomerServiceChatLog(db, opts...),
		DisconnectLog:             newDisconnectLog(db, opts...),
		DuelLog:                   newDuelLog(db, opts...),
		EventConfig:               newEventConfig(db, opts...),
		ExpeditionLog:             newExpeditionLog(db, opts...),
		FirstAdvLog:               newFirstAdvLog(db, opts...),
		GameAlarmCombatLog:        newGameAlarmCombatLog(db, opts...),
		GameCharacterDataAnomaly:  newGameCharacterDataAnomaly(db, opts...),
		GameDataAlarm:             newGameDataAlarm(db, opts...),
		GemLog:                    newGemLog(db, opts...),
		GemPlayer:                 newGemPlayer(db, opts...),
		GemStat:                   newGemStat(db, opts...),
		Globalletter:              newGloballetter(db, opts...),
		GoodsLog:                  newGoodsLog(db, opts...),
		Grandmaster:               newGrandmaster(db, opts...),
		GrandmasterLog:            newGrandmasterLog(db, opts...),
		GrandmasterMatch:          newGrandmasterMatch(db, opts...),
		GudongLog:                 newGudongLog(db, opts...),
		IdiomLog:                  newIdiomLog(db, opts...),
		Idiommatch:                newIdiommatch(db, opts...),
		Lady38rank2:               newLady38rank2(db, opts...),
		LimitgiftLog:              newLimitgiftLog(db, opts...),
		LoginLog:                  newLoginLog(db, opts...),
		Menu:                      newMenu(db, opts...),
		NewConvLog:                newNewConvLog(db, opts...),
		OnlineDurationLog:         newOnlineDurationLog(db, opts...),
		OnlineNumsLog:             newOnlineNumsLog(db, opts...),
		Order:                     newOrder(db, opts...),
		OrdersRegStat:             newOrdersRegStat(db, opts...),
		OrdersSettle:              newOrdersSettle(db, opts...),
		OrdersSync:                newOrdersSync(db, opts...),
		PayOrderAndriod:           newPayOrderAndriod(db, opts...),
		PayOrderIos:               newPayOrderIos(db, opts...),
		PlayerAttr:                newPlayerAttr(db, opts...),
		PlayerBanLog:              newPlayerBanLog(db, opts...),
		PlayerBattleDp:            newPlayerBattleDp(db, opts...),
		PlayerCache:               newPlayerCache(db, opts...),
		PlayerChannel:             newPlayerChannel(db, opts...),
		PlayerDayTask:             newPlayerDayTask(db, opts...),
		PlayerDivination:          newPlayerDivination(db, opts...),
		PlayerDp:                  newPlayerDp(db, opts...),
		PlayerLetter:              newPlayerLetter(db, opts...),
		PlayerLogin:               newPlayerLogin(db, opts...),
		PlayerMailbox:             newPlayerMailbox(db, opts...),
		PlayerMaterial:            newPlayerMaterial(db, opts...),
		PlayerPatrol:              newPlayerPatrol(db, opts...),
		PlayerTask:                newPlayerTask(db, opts...),
		Processaward:              newProcessaward(db, opts...),
		RedeemCode:                newRedeemCode(db, opts...),
		RedeemPeripheralsReceived: newRedeemPeripheralsReceived(db, opts...),
		RedeemReceived:            newRedeemReceived(db, opts...),
		ReportDayAdvBasic:         newReportDayAdvBasic(db, opts...),
		ReportDayAdvSumm:          newReportDayAdvSumm(db, opts...),
		ReportDayBasic:            newReportDayBasic(db, opts...),
		ReportDayBoss:             newReportDayBoss(db, opts...),
		ReportDayChapterPass:      newReportDayChapterPass(db, opts...),
		ReportDayDisconnect:       newReportDayDisconnect(db, opts...),
		ReportDayDuel:             newReportDayDuel(db, opts...),
		ReportDayEventBasic:       newReportDayEventBasic(db, opts...),
		ReportDayExpedition:       newReportDayExpedition(db, opts...),
		ReportDayFirstAdv:         newReportDayFirstAdv(db, opts...),
		ReportDayGem:              newReportDayGem(db, opts...),
		ReportDayGoodsBasic:       newReportDayGoodsBasic(db, opts...),
		ReportDayGrandmaster:      newReportDayGrandmaster(db, opts...),
		ReportDayGudong:           newReportDayGudong(db, opts...),
		ReportDayHaveRole:         newReportDayHaveRole(db, opts...),
		ReportDayIdiom:            newReportDayIdiom(db, opts...),
		ReportDayLimitgift:        newReportDayLimitgift(db, opts...),
		ReportDayNewConv:          newReportDayNewConv(db, opts...),
		ReportDaySeven:            newReportDaySeven(db, opts...),
		ReportDayTreasure:         newReportDayTreasure(db, opts...),
		ReportDayTreasureChest:    newReportDayTreasureChest(db, opts...),
		ReportEvent:               newReportEvent(db, opts...),
		ReportLevelOutput:         newReportLevelOutput(db, opts...),
		Retrofit:                  newRetrofit(db, opts...),
		RetrofitGroup:             newRetrofitGroup(db, opts...),
		Role:                      newRole(db, opts...),
		RolesLog:                  newRolesLog(db, opts...),
		ServerDeploy:              newServerDeploy(db, opts...),
		ServerDeployLog:           newServerDeployLog(db, opts...),
		ServerDeployStat:          newServerDeployStat(db, opts...),
		ServerOption:              newServerOption(db, opts...),
		SevenLog:                  newSevenLog(db, opts...),
		Signin:                    newSignin(db, opts...),
		ToolsRestartLog:           newToolsRestartLog(db, opts...),
		TreasureChestLog:          newTreasureChestLog(db, opts...),
		TreasureLog:               newTreasureLog(db, opts...),
		UserAccount:               newUserAccount(db, opts...),
		UserChapterLog:            newUserChapterLog(db, opts...),
		WxpayOrder:                newWxpayOrder(db, opts...),
		WxpayPlayer:               newWxpayPlayer(db, opts...),
		ZoneActivity:              newZoneActivity(db, opts...),
		Chat: 					   newChat(db, opts...),
		AdminBanUserLog:   		   newAdminBanUserLog(db, opts...),
		ChatReportLog: 			   newChatReportLog(db, opts...),
		ChatMsgLog: 			   newChatMsgLog(db, opts...),
	}
}

type Query struct {
	db *gorm.DB

	AdminMenu     adminMenu
	AdminRoleMenu adminRoleMenu
	AdminRolePermission adminRolePermission
	AdminPermission adminPermission
	AdminOperation adminOperation
	AdminSystem         adminSystem
	AdminEmail                adminEmail
	AdminLog                  adminLog
	AdminNotice               adminNotice
	AdminRole                 adminRole
	AdminUser                 adminUser
	AdvOriginLog              advOriginLog
	AdvertisementLog          advertisementLog
	AdvertisementSpace        advertisementSpace
	BossLog                   bossLog
	Bosswar                   bosswar
	BuyStamina                buyStamina
	Cache                     cache
	ChangedLog                changedLog
	ChangedPlayer             changedPlayer
	ChangedStatistic          changedStatistic
	ChangedSync               changedSync
	Channel                   channel
	Chapter                   chapter
	ChapterLog                chapterLog
	ChapterLogsUserDetail     chapterLogsUserDetail
	ChapterSync               chapterSync
	ClientDatum               clientDatum
	Climbfloor                climbfloor
	Config                    config
	Curiomake                 curiomake
	CustomerServiceChatLog    customerServiceChatLog
	DisconnectLog             disconnectLog
	DuelLog                   duelLog
	EventConfig               eventConfig
	ExpeditionLog             expeditionLog
	FirstAdvLog               firstAdvLog
	GameAlarmCombatLog        gameAlarmCombatLog
	GameCharacterDataAnomaly  gameCharacterDataAnomaly
	GameDataAlarm             gameDataAlarm
	GemLog                    gemLog
	GemPlayer                 gemPlayer
	GemStat                   gemStat
	Globalletter              globalletter
	GoodsLog                  goodsLog
	Grandmaster               grandmaster
	GrandmasterLog            grandmasterLog
	GrandmasterMatch          grandmasterMatch
	GudongLog                 gudongLog
	IdiomLog                  idiomLog
	Idiommatch                idiommatch
	Lady38rank2               lady38rank2
	LimitgiftLog              limitgiftLog
	LoginLog                  loginLog
	Menu                      menu
	NewConvLog                newConvLog
	OnlineDurationLog         onlineDurationLog
	OnlineNumsLog             onlineNumsLog
	Order                     order
	OrdersRegStat             ordersRegStat
	OrdersSettle              ordersSettle
	OrdersSync                ordersSync
	PayOrderAndriod           payOrderAndriod
	PayOrderIos               payOrderIos
	PlayerAttr                playerAttr
	PlayerBanLog              playerBanLog
	PlayerBattleDp            playerBattleDp
	PlayerCache               playerCache
	PlayerChannel             playerChannel
	PlayerDayTask             playerDayTask
	PlayerDivination          playerDivination
	PlayerDp                  playerDp
	PlayerLetter              playerLetter
	PlayerLogin               playerLogin
	PlayerMailbox             playerMailbox
	PlayerMaterial            playerMaterial
	PlayerPatrol              playerPatrol
	PlayerTask                playerTask
	Processaward              processaward
	RedeemCode                redeemCode
	RedeemPeripheralsReceived redeemPeripheralsReceived
	RedeemReceived            redeemReceived
	ReportDayAdvBasic         reportDayAdvBasic
	ReportDayAdvSumm          reportDayAdvSumm
	ReportDayBasic            reportDayBasic
	ReportDayBoss             reportDayBoss
	ReportDayChapterPass      reportDayChapterPass
	ReportDayDisconnect       reportDayDisconnect
	ReportDayDuel             reportDayDuel
	ReportDayEventBasic       reportDayEventBasic
	ReportDayExpedition       reportDayExpedition
	ReportDayFirstAdv         reportDayFirstAdv
	ReportDayGem              reportDayGem
	ReportDayGoodsBasic       reportDayGoodsBasic
	ReportDayGrandmaster      reportDayGrandmaster
	ReportDayGudong           reportDayGudong
	ReportDayHaveRole         reportDayHaveRole
	ReportDayIdiom            reportDayIdiom
	ReportDayLimitgift        reportDayLimitgift
	ReportDayNewConv          reportDayNewConv
	ReportDaySeven            reportDaySeven
	ReportDayTreasure         reportDayTreasure
	ReportDayTreasureChest    reportDayTreasureChest
	ReportEvent               reportEvent
	ReportLevelOutput         reportLevelOutput
	Retrofit                  retrofit
	RetrofitGroup             retrofitGroup
	Role                      role
	RolesLog                  rolesLog
	ServerDeploy              serverDeploy
	ServerDeployLog           serverDeployLog
	ServerDeployStat          serverDeployStat
	ServerOption              serverOption
	SevenLog                  sevenLog
	Signin                    signin
	ToolsRestartLog           toolsRestartLog
	TreasureChestLog          treasureChestLog
	TreasureLog               treasureLog
	UserAccount               userAccount
	UserChapterLog            userChapterLog
	WxpayOrder                wxpayOrder
	WxpayPlayer               wxpayPlayer
	ZoneActivity              zoneActivity
	Chat 					  chat
	AdminBanUserLog 		  adminBanUserLog
	ChatReportLog 			  chatReportLog
	ChatMsgLog 				  chatMsgLog
}

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

func (q *Query) clone(db *gorm.DB) *Query {
	return &Query{
		db:                        db,
		AdminMenu:     q.AdminMenu.clone(db),
		AdminRoleMenu: q.AdminRoleMenu.clone(db),
		AdminRolePermission: q.AdminRolePermission.clone(db),
		AdminPermission: q.AdminPermission.clone(db),
		AdminOperation: q.AdminOperation.clone(db),
		AdminSystem:         q.AdminSystem.clone(db),
		AdminEmail:                q.AdminEmail.clone(db),
		AdminLog:                  q.AdminLog.clone(db),
		AdminNotice:               q.AdminNotice.clone(db),
		AdminRole:                 q.AdminRole.clone(db),
		AdminUser:                 q.AdminUser.clone(db),
		AdvOriginLog:              q.AdvOriginLog.clone(db),
		AdvertisementLog:          q.AdvertisementLog.clone(db),
		AdvertisementSpace:        q.AdvertisementSpace.clone(db),
		BossLog:                   q.BossLog.clone(db),
		Bosswar:                   q.Bosswar.clone(db),
		BuyStamina:                q.BuyStamina.clone(db),
		Cache:                     q.Cache.clone(db),
		ChangedLog:                q.ChangedLog.clone(db),
		ChangedPlayer:             q.ChangedPlayer.clone(db),
		ChangedStatistic:          q.ChangedStatistic.clone(db),
		ChangedSync:               q.ChangedSync.clone(db),
		Channel:                   q.Channel.clone(db),
		Chapter:                   q.Chapter.clone(db),
		ChapterLog:                q.ChapterLog.clone(db),
		ChapterLogsUserDetail:     q.ChapterLogsUserDetail.clone(db),
		ChapterSync:               q.ChapterSync.clone(db),
		ClientDatum:               q.ClientDatum.clone(db),
		Climbfloor:                q.Climbfloor.clone(db),
		Config:                    q.Config.clone(db),
		Curiomake:                 q.Curiomake.clone(db),
		CustomerServiceChatLog:    q.CustomerServiceChatLog.clone(db),
		DisconnectLog:             q.DisconnectLog.clone(db),
		DuelLog:                   q.DuelLog.clone(db),
		EventConfig:               q.EventConfig.clone(db),
		ExpeditionLog:             q.ExpeditionLog.clone(db),
		FirstAdvLog:               q.FirstAdvLog.clone(db),
		GameAlarmCombatLog:        q.GameAlarmCombatLog.clone(db),
		GameCharacterDataAnomaly:  q.GameCharacterDataAnomaly.clone(db),
		GameDataAlarm:             q.GameDataAlarm.clone(db),
		GemLog:                    q.GemLog.clone(db),
		GemPlayer:                 q.GemPlayer.clone(db),
		GemStat:                   q.GemStat.clone(db),
		Globalletter:              q.Globalletter.clone(db),
		GoodsLog:                  q.GoodsLog.clone(db),
		Grandmaster:               q.Grandmaster.clone(db),
		GrandmasterLog:            q.GrandmasterLog.clone(db),
		GrandmasterMatch:          q.GrandmasterMatch.clone(db),
		GudongLog:                 q.GudongLog.clone(db),
		IdiomLog:                  q.IdiomLog.clone(db),
		Idiommatch:                q.Idiommatch.clone(db),
		Lady38rank2:               q.Lady38rank2.clone(db),
		LimitgiftLog:              q.LimitgiftLog.clone(db),
		LoginLog:                  q.LoginLog.clone(db),
		Menu:                      q.Menu.clone(db),
		NewConvLog:                q.NewConvLog.clone(db),
		OnlineDurationLog:         q.OnlineDurationLog.clone(db),
		OnlineNumsLog:             q.OnlineNumsLog.clone(db),
		Order:                     q.Order.clone(db),
		OrdersRegStat:             q.OrdersRegStat.clone(db),
		OrdersSettle:              q.OrdersSettle.clone(db),
		OrdersSync:                q.OrdersSync.clone(db),
		PayOrderAndriod:           q.PayOrderAndriod.clone(db),
		PayOrderIos:               q.PayOrderIos.clone(db),
		PlayerAttr:                q.PlayerAttr.clone(db),
		PlayerBanLog:              q.PlayerBanLog.clone(db),
		PlayerBattleDp:            q.PlayerBattleDp.clone(db),
		PlayerCache:               q.PlayerCache.clone(db),
		PlayerChannel:             q.PlayerChannel.clone(db),
		PlayerDayTask:             q.PlayerDayTask.clone(db),
		PlayerDivination:          q.PlayerDivination.clone(db),
		PlayerDp:                  q.PlayerDp.clone(db),
		PlayerLetter:              q.PlayerLetter.clone(db),
		PlayerLogin:               q.PlayerLogin.clone(db),
		PlayerMailbox:             q.PlayerMailbox.clone(db),
		PlayerMaterial:            q.PlayerMaterial.clone(db),
		PlayerPatrol:              q.PlayerPatrol.clone(db),
		PlayerTask:                q.PlayerTask.clone(db),
		Processaward:              q.Processaward.clone(db),
		RedeemCode:                q.RedeemCode.clone(db),
		RedeemPeripheralsReceived: q.RedeemPeripheralsReceived.clone(db),
		RedeemReceived:            q.RedeemReceived.clone(db),
		ReportDayAdvBasic:         q.ReportDayAdvBasic.clone(db),
		ReportDayAdvSumm:          q.ReportDayAdvSumm.clone(db),
		ReportDayBasic:            q.ReportDayBasic.clone(db),
		ReportDayBoss:             q.ReportDayBoss.clone(db),
		ReportDayChapterPass:      q.ReportDayChapterPass.clone(db),
		ReportDayDisconnect:       q.ReportDayDisconnect.clone(db),
		ReportDayDuel:             q.ReportDayDuel.clone(db),
		ReportDayEventBasic:       q.ReportDayEventBasic.clone(db),
		ReportDayExpedition:       q.ReportDayExpedition.clone(db),
		ReportDayFirstAdv:         q.ReportDayFirstAdv.clone(db),
		ReportDayGem:              q.ReportDayGem.clone(db),
		ReportDayGoodsBasic:       q.ReportDayGoodsBasic.clone(db),
		ReportDayGrandmaster:      q.ReportDayGrandmaster.clone(db),
		ReportDayGudong:           q.ReportDayGudong.clone(db),
		ReportDayHaveRole:         q.ReportDayHaveRole.clone(db),
		ReportDayIdiom:            q.ReportDayIdiom.clone(db),
		ReportDayLimitgift:        q.ReportDayLimitgift.clone(db),
		ReportDayNewConv:          q.ReportDayNewConv.clone(db),
		ReportDaySeven:            q.ReportDaySeven.clone(db),
		ReportDayTreasure:         q.ReportDayTreasure.clone(db),
		ReportDayTreasureChest:    q.ReportDayTreasureChest.clone(db),
		ReportEvent:               q.ReportEvent.clone(db),
		ReportLevelOutput:         q.ReportLevelOutput.clone(db),
		Retrofit:                  q.Retrofit.clone(db),
		RetrofitGroup:             q.RetrofitGroup.clone(db),
		Role:                      q.Role.clone(db),
		RolesLog:                  q.RolesLog.clone(db),
		ServerDeploy:              q.ServerDeploy.clone(db),
		ServerDeployLog:           q.ServerDeployLog.clone(db),
		ServerDeployStat:          q.ServerDeployStat.clone(db),
		ServerOption:              q.ServerOption.clone(db),
		SevenLog:                  q.SevenLog.clone(db),
		Signin:                    q.Signin.clone(db),
		ToolsRestartLog:           q.ToolsRestartLog.clone(db),
		TreasureChestLog:          q.TreasureChestLog.clone(db),
		TreasureLog:               q.TreasureLog.clone(db),
		UserAccount:               q.UserAccount.clone(db),
		UserChapterLog:            q.UserChapterLog.clone(db),
		WxpayOrder:                q.WxpayOrder.clone(db),
		WxpayPlayer:               q.WxpayPlayer.clone(db),
		ZoneActivity:              q.ZoneActivity.clone(db),
		Chat: 					   q.Chat.clone(db),
		AdminBanUserLog: 		   q.AdminBanUserLog.clone(db),
		ChatReportLog: 			   q.ChatReportLog.clone(db),
		ChatMsgLog: 			   q.ChatMsgLog.clone(db),
	}
}

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

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

func (q *Query) ReplaceDB(db *gorm.DB) *Query {
	return &Query{
		db:                        db,
		AdminMenu:     q.AdminMenu.replaceDB(db),
		AdminRoleMenu: q.AdminRoleMenu.replaceDB(db),
		AdminRolePermission: q.AdminRolePermission.replaceDB(db),
		AdminPermission: q.AdminPermission.replaceDB(db),
		AdminOperation: q.AdminOperation.replaceDB(db),
		AdminSystem:         q.AdminSystem.replaceDB(db),
		AdminEmail:                q.AdminEmail.replaceDB(db),
		AdminLog:                  q.AdminLog.replaceDB(db),
		AdminNotice:               q.AdminNotice.replaceDB(db),
		AdminRole:                 q.AdminRole.replaceDB(db),
		AdminUser:                 q.AdminUser.replaceDB(db),
		AdvOriginLog:              q.AdvOriginLog.replaceDB(db),
		AdvertisementLog:          q.AdvertisementLog.replaceDB(db),
		AdvertisementSpace:        q.AdvertisementSpace.replaceDB(db),
		BossLog:                   q.BossLog.replaceDB(db),
		Bosswar:                   q.Bosswar.replaceDB(db),
		BuyStamina:                q.BuyStamina.replaceDB(db),
		Cache:                     q.Cache.replaceDB(db),
		ChangedLog:                q.ChangedLog.replaceDB(db),
		ChangedPlayer:             q.ChangedPlayer.replaceDB(db),
		ChangedStatistic:          q.ChangedStatistic.replaceDB(db),
		ChangedSync:               q.ChangedSync.replaceDB(db),
		Channel:                   q.Channel.replaceDB(db),
		Chapter:                   q.Chapter.replaceDB(db),
		ChapterLog:                q.ChapterLog.replaceDB(db),
		ChapterLogsUserDetail:     q.ChapterLogsUserDetail.replaceDB(db),
		ChapterSync:               q.ChapterSync.replaceDB(db),
		ClientDatum:               q.ClientDatum.replaceDB(db),
		Climbfloor:                q.Climbfloor.replaceDB(db),
		Config:                    q.Config.replaceDB(db),
		Curiomake:                 q.Curiomake.replaceDB(db),
		CustomerServiceChatLog:    q.CustomerServiceChatLog.replaceDB(db),
		DisconnectLog:             q.DisconnectLog.replaceDB(db),
		DuelLog:                   q.DuelLog.replaceDB(db),
		EventConfig:               q.EventConfig.replaceDB(db),
		ExpeditionLog:             q.ExpeditionLog.replaceDB(db),
		FirstAdvLog:               q.FirstAdvLog.replaceDB(db),
		GameAlarmCombatLog:        q.GameAlarmCombatLog.replaceDB(db),
		GameCharacterDataAnomaly:  q.GameCharacterDataAnomaly.replaceDB(db),
		GameDataAlarm:             q.GameDataAlarm.replaceDB(db),
		GemLog:                    q.GemLog.replaceDB(db),
		GemPlayer:                 q.GemPlayer.replaceDB(db),
		GemStat:                   q.GemStat.replaceDB(db),
		Globalletter:              q.Globalletter.replaceDB(db),
		GoodsLog:                  q.GoodsLog.replaceDB(db),
		Grandmaster:               q.Grandmaster.replaceDB(db),
		GrandmasterLog:            q.GrandmasterLog.replaceDB(db),
		GrandmasterMatch:          q.GrandmasterMatch.replaceDB(db),
		GudongLog:                 q.GudongLog.replaceDB(db),
		IdiomLog:                  q.IdiomLog.replaceDB(db),
		Idiommatch:                q.Idiommatch.replaceDB(db),
		Lady38rank2:               q.Lady38rank2.replaceDB(db),
		LimitgiftLog:              q.LimitgiftLog.replaceDB(db),
		LoginLog:                  q.LoginLog.replaceDB(db),
		Menu:                      q.Menu.replaceDB(db),
		NewConvLog:                q.NewConvLog.replaceDB(db),
		OnlineDurationLog:         q.OnlineDurationLog.replaceDB(db),
		OnlineNumsLog:             q.OnlineNumsLog.replaceDB(db),
		Order:                     q.Order.replaceDB(db),
		OrdersRegStat:             q.OrdersRegStat.replaceDB(db),
		OrdersSettle:              q.OrdersSettle.replaceDB(db),
		OrdersSync:                q.OrdersSync.replaceDB(db),
		PayOrderAndriod:           q.PayOrderAndriod.replaceDB(db),
		PayOrderIos:               q.PayOrderIos.replaceDB(db),
		PlayerAttr:                q.PlayerAttr.replaceDB(db),
		PlayerBanLog:              q.PlayerBanLog.replaceDB(db),
		PlayerBattleDp:            q.PlayerBattleDp.replaceDB(db),
		PlayerCache:               q.PlayerCache.replaceDB(db),
		PlayerChannel:             q.PlayerChannel.replaceDB(db),
		PlayerDayTask:             q.PlayerDayTask.replaceDB(db),
		PlayerDivination:          q.PlayerDivination.replaceDB(db),
		PlayerDp:                  q.PlayerDp.replaceDB(db),
		PlayerLetter:              q.PlayerLetter.replaceDB(db),
		PlayerLogin:               q.PlayerLogin.replaceDB(db),
		PlayerMailbox:             q.PlayerMailbox.replaceDB(db),
		PlayerMaterial:            q.PlayerMaterial.replaceDB(db),
		PlayerPatrol:              q.PlayerPatrol.replaceDB(db),
		PlayerTask:                q.PlayerTask.replaceDB(db),
		Processaward:              q.Processaward.replaceDB(db),
		RedeemCode:                q.RedeemCode.replaceDB(db),
		RedeemPeripheralsReceived: q.RedeemPeripheralsReceived.replaceDB(db),
		RedeemReceived:            q.RedeemReceived.replaceDB(db),
		ReportDayAdvBasic:         q.ReportDayAdvBasic.replaceDB(db),
		ReportDayAdvSumm:          q.ReportDayAdvSumm.replaceDB(db),
		ReportDayBasic:            q.ReportDayBasic.replaceDB(db),
		ReportDayBoss:             q.ReportDayBoss.replaceDB(db),
		ReportDayChapterPass:      q.ReportDayChapterPass.replaceDB(db),
		ReportDayDisconnect:       q.ReportDayDisconnect.replaceDB(db),
		ReportDayDuel:             q.ReportDayDuel.replaceDB(db),
		ReportDayEventBasic:       q.ReportDayEventBasic.replaceDB(db),
		ReportDayExpedition:       q.ReportDayExpedition.replaceDB(db),
		ReportDayFirstAdv:         q.ReportDayFirstAdv.replaceDB(db),
		ReportDayGem:              q.ReportDayGem.replaceDB(db),
		ReportDayGoodsBasic:       q.ReportDayGoodsBasic.replaceDB(db),
		ReportDayGrandmaster:      q.ReportDayGrandmaster.replaceDB(db),
		ReportDayGudong:           q.ReportDayGudong.replaceDB(db),
		ReportDayHaveRole:         q.ReportDayHaveRole.replaceDB(db),
		ReportDayIdiom:            q.ReportDayIdiom.replaceDB(db),
		ReportDayLimitgift:        q.ReportDayLimitgift.replaceDB(db),
		ReportDayNewConv:          q.ReportDayNewConv.replaceDB(db),
		ReportDaySeven:            q.ReportDaySeven.replaceDB(db),
		ReportDayTreasure:         q.ReportDayTreasure.replaceDB(db),
		ReportDayTreasureChest:    q.ReportDayTreasureChest.replaceDB(db),
		ReportEvent:               q.ReportEvent.replaceDB(db),
		ReportLevelOutput:         q.ReportLevelOutput.replaceDB(db),
		Retrofit:                  q.Retrofit.replaceDB(db),
		RetrofitGroup:             q.RetrofitGroup.replaceDB(db),
		Role:                      q.Role.replaceDB(db),
		RolesLog:                  q.RolesLog.replaceDB(db),
		ServerDeploy:              q.ServerDeploy.replaceDB(db),
		ServerDeployLog:           q.ServerDeployLog.replaceDB(db),
		ServerDeployStat:          q.ServerDeployStat.replaceDB(db),
		ServerOption:              q.ServerOption.replaceDB(db),
		SevenLog:                  q.SevenLog.replaceDB(db),
		Signin:                    q.Signin.replaceDB(db),
		ToolsRestartLog:           q.ToolsRestartLog.replaceDB(db),
		TreasureChestLog:          q.TreasureChestLog.replaceDB(db),
		TreasureLog:               q.TreasureLog.replaceDB(db),
		UserAccount:               q.UserAccount.replaceDB(db),
		UserChapterLog:            q.UserChapterLog.replaceDB(db),
		WxpayOrder:                q.WxpayOrder.replaceDB(db),
		WxpayPlayer:               q.WxpayPlayer.replaceDB(db),
		ZoneActivity:              q.ZoneActivity.replaceDB(db),
		Chat: 					   q.Chat.replaceDB(db),
		AdminBanUserLog: 		   q.AdminBanUserLog.replaceDB(db),
		ChatReportLog: 			   q.ChatReportLog.replaceDB(db),
		ChatMsgLog: 			   q.ChatMsgLog.replaceDB(db),
	}
}

type queryCtx struct {
	AdminMenu     *adminMenuDo
	AdminRoleMenu *adminRoleMenuDo
	AdminRolePermission *adminRolePermissionDo
	AdminPermission *adminPermissionDo
	AdminOperation *adminOperationDo
	AdminSystem         *adminSystemDo
	AdminEmail                *adminEmailDo
	AdminLog                  *adminLogDo
	AdminNotice               *adminNoticeDo
	AdminRole                 *adminRoleDo
	AdminUser                 *adminUserDo
	AdvOriginLog              *advOriginLogDo
	AdvertisementLog          *advertisementLogDo
	AdvertisementSpace        *advertisementSpaceDo
	BossLog                   *bossLogDo
	Bosswar                   *bosswarDo
	BuyStamina                *buyStaminaDo
	Cache                     *cacheDo
	ChangedLog                *changedLogDo
	ChangedPlayer             *changedPlayerDo
	ChangedStatistic          *changedStatisticDo
	ChangedSync               *changedSyncDo
	Channel                   *channelDo
	Chapter                   *chapterDo
	ChapterLog                *chapterLogDo
	ChapterLogsUserDetail     *chapterLogsUserDetailDo
	ChapterSync               *chapterSyncDo
	ClientDatum               *clientDatumDo
	Climbfloor                *climbfloorDo
	Config                    *configDo
	Curiomake                 *curiomakeDo
	CustomerServiceChatLog    *customerServiceChatLogDo
	DisconnectLog             *disconnectLogDo
	DuelLog                   *duelLogDo
	EventConfig               *eventConfigDo
	ExpeditionLog             *expeditionLogDo
	FirstAdvLog               *firstAdvLogDo
	GameAlarmCombatLog        *gameAlarmCombatLogDo
	GameCharacterDataAnomaly  *gameCharacterDataAnomalyDo
	GameDataAlarm             *gameDataAlarmDo
	GemLog                    *gemLogDo
	GemPlayer                 *gemPlayerDo
	GemStat                   *gemStatDo
	Globalletter              *globalletterDo
	GoodsLog                  *goodsLogDo
	Grandmaster               *grandmasterDo
	GrandmasterLog            *grandmasterLogDo
	GrandmasterMatch          *grandmasterMatchDo
	GudongLog                 *gudongLogDo
	IdiomLog                  *idiomLogDo
	Idiommatch                *idiommatchDo
	Lady38rank2               *lady38rank2Do
	LimitgiftLog              *limitgiftLogDo
	LoginLog                  *loginLogDo
	Menu                      *menuDo
	NewConvLog                *newConvLogDo
	OnlineDurationLog         *onlineDurationLogDo
	OnlineNumsLog             *onlineNumsLogDo
	Order                     *orderDo
	OrdersRegStat             *ordersRegStatDo
	OrdersSettle              *ordersSettleDo
	OrdersSync                *ordersSyncDo
	PayOrderAndriod           *payOrderAndriodDo
	PayOrderIos               *payOrderIosDo
	PlayerAttr                *playerAttrDo
	PlayerBanLog              *playerBanLogDo
	PlayerBattleDp            *playerBattleDpDo
	PlayerCache               *playerCacheDo
	PlayerChannel             *playerChannelDo
	PlayerDayTask             *playerDayTaskDo
	PlayerDivination          *playerDivinationDo
	PlayerDp                  *playerDpDo
	PlayerLetter              *playerLetterDo
	PlayerLogin               *playerLoginDo
	PlayerMailbox             *playerMailboxDo
	PlayerMaterial            *playerMaterialDo
	PlayerPatrol              *playerPatrolDo
	PlayerTask                *playerTaskDo
	Processaward              *processawardDo
	RedeemCode                *redeemCodeDo
	RedeemPeripheralsReceived *redeemPeripheralsReceivedDo
	RedeemReceived            *redeemReceivedDo
	ReportDayAdvBasic         *reportDayAdvBasicDo
	ReportDayAdvSumm          *reportDayAdvSummDo
	ReportDayBasic            *reportDayBasicDo
	ReportDayBoss             *reportDayBossDo
	ReportDayChapterPass      *reportDayChapterPassDo
	ReportDayDisconnect       *reportDayDisconnectDo
	ReportDayDuel             *reportDayDuelDo
	ReportDayEventBasic       *reportDayEventBasicDo
	ReportDayExpedition       *reportDayExpeditionDo
	ReportDayFirstAdv         *reportDayFirstAdvDo
	ReportDayGem              *reportDayGemDo
	ReportDayGoodsBasic       *reportDayGoodsBasicDo
	ReportDayGrandmaster      *reportDayGrandmasterDo
	ReportDayGudong           *reportDayGudongDo
	ReportDayHaveRole         *reportDayHaveRoleDo
	ReportDayIdiom            *reportDayIdiomDo
	ReportDayLimitgift        *reportDayLimitgiftDo
	ReportDayNewConv          *reportDayNewConvDo
	ReportDaySeven            *reportDaySevenDo
	ReportDayTreasure         *reportDayTreasureDo
	ReportDayTreasureChest    *reportDayTreasureChestDo
	ReportEvent               *reportEventDo
	ReportLevelOutput         *reportLevelOutputDo
	Retrofit                  *retrofitDo
	RetrofitGroup             *retrofitGroupDo
	Role                      *roleDo
	RolesLog                  *rolesLogDo
	ServerDeploy              *serverDeployDo
	ServerDeployLog           *serverDeployLogDo
	ServerDeployStat          *serverDeployStatDo
	ServerOption              *serverOptionDo
	SevenLog                  *sevenLogDo
	Signin                    *signinDo
	ToolsRestartLog           *toolsRestartLogDo
	TreasureChestLog          *treasureChestLogDo
	TreasureLog               *treasureLogDo
	UserAccount               *userAccountDo
	UserChapterLog            *userChapterLogDo
	WxpayOrder                *wxpayOrderDo
	WxpayPlayer               *wxpayPlayerDo
	ZoneActivity              *zoneActivityDo
	Chat 					  *chatDo
	AdminBanUserLog 		  *adminBanUserLogDo
	ChatReportLog 			  *chatReportLogDo
	ChatMsgLog 				  *chatMsgLogDo
}

func (q *Query) WithContext(ctx context.Context) *queryCtx {
	return &queryCtx{
		AdminMenu:     q.AdminMenu.WithContext(ctx),
		AdminRoleMenu: q.AdminRoleMenu.WithContext(ctx),
		AdminRolePermission: q.AdminRolePermission.WithContext(ctx),
		AdminPermission: q.AdminPermission.WithContext(ctx),
		AdminOperation: q.AdminOperation.WithContext(ctx),
		AdminSystem:         q.AdminSystem.WithContext(ctx),
		AdminEmail:                q.AdminEmail.WithContext(ctx),
		AdminLog:                  q.AdminLog.WithContext(ctx),
		AdminNotice:               q.AdminNotice.WithContext(ctx),
		AdminRole:                 q.AdminRole.WithContext(ctx),
		AdminUser:                 q.AdminUser.WithContext(ctx),
		AdvOriginLog:              q.AdvOriginLog.WithContext(ctx),
		AdvertisementLog:          q.AdvertisementLog.WithContext(ctx),
		AdvertisementSpace:        q.AdvertisementSpace.WithContext(ctx),
		BossLog:                   q.BossLog.WithContext(ctx),
		Bosswar:                   q.Bosswar.WithContext(ctx),
		BuyStamina:                q.BuyStamina.WithContext(ctx),
		Cache:                     q.Cache.WithContext(ctx),
		ChangedLog:                q.ChangedLog.WithContext(ctx),
		ChangedPlayer:             q.ChangedPlayer.WithContext(ctx),
		ChangedStatistic:          q.ChangedStatistic.WithContext(ctx),
		ChangedSync:               q.ChangedSync.WithContext(ctx),
		Channel:                   q.Channel.WithContext(ctx),
		Chapter:                   q.Chapter.WithContext(ctx),
		ChapterLog:                q.ChapterLog.WithContext(ctx),
		ChapterLogsUserDetail:     q.ChapterLogsUserDetail.WithContext(ctx),
		ChapterSync:               q.ChapterSync.WithContext(ctx),
		ClientDatum:               q.ClientDatum.WithContext(ctx),
		Climbfloor:                q.Climbfloor.WithContext(ctx),
		Config:                    q.Config.WithContext(ctx),
		Curiomake:                 q.Curiomake.WithContext(ctx),
		CustomerServiceChatLog:    q.CustomerServiceChatLog.WithContext(ctx),
		DisconnectLog:             q.DisconnectLog.WithContext(ctx),
		DuelLog:                   q.DuelLog.WithContext(ctx),
		EventConfig:               q.EventConfig.WithContext(ctx),
		ExpeditionLog:             q.ExpeditionLog.WithContext(ctx),
		FirstAdvLog:               q.FirstAdvLog.WithContext(ctx),
		GameAlarmCombatLog:        q.GameAlarmCombatLog.WithContext(ctx),
		GameCharacterDataAnomaly:  q.GameCharacterDataAnomaly.WithContext(ctx),
		GameDataAlarm:             q.GameDataAlarm.WithContext(ctx),
		GemLog:                    q.GemLog.WithContext(ctx),
		GemPlayer:                 q.GemPlayer.WithContext(ctx),
		GemStat:                   q.GemStat.WithContext(ctx),
		Globalletter:              q.Globalletter.WithContext(ctx),
		GoodsLog:                  q.GoodsLog.WithContext(ctx),
		Grandmaster:               q.Grandmaster.WithContext(ctx),
		GrandmasterLog:            q.GrandmasterLog.WithContext(ctx),
		GrandmasterMatch:          q.GrandmasterMatch.WithContext(ctx),
		GudongLog:                 q.GudongLog.WithContext(ctx),
		IdiomLog:                  q.IdiomLog.WithContext(ctx),
		Idiommatch:                q.Idiommatch.WithContext(ctx),
		Lady38rank2:               q.Lady38rank2.WithContext(ctx),
		LimitgiftLog:              q.LimitgiftLog.WithContext(ctx),
		LoginLog:                  q.LoginLog.WithContext(ctx),
		Menu:                      q.Menu.WithContext(ctx),
		NewConvLog:                q.NewConvLog.WithContext(ctx),
		OnlineDurationLog:         q.OnlineDurationLog.WithContext(ctx),
		OnlineNumsLog:             q.OnlineNumsLog.WithContext(ctx),
		Order:                     q.Order.WithContext(ctx),
		OrdersRegStat:             q.OrdersRegStat.WithContext(ctx),
		OrdersSettle:              q.OrdersSettle.WithContext(ctx),
		OrdersSync:                q.OrdersSync.WithContext(ctx),
		PayOrderAndriod:           q.PayOrderAndriod.WithContext(ctx),
		PayOrderIos:               q.PayOrderIos.WithContext(ctx),
		PlayerAttr:                q.PlayerAttr.WithContext(ctx),
		PlayerBanLog:              q.PlayerBanLog.WithContext(ctx),
		PlayerBattleDp:            q.PlayerBattleDp.WithContext(ctx),
		PlayerCache:               q.PlayerCache.WithContext(ctx),
		PlayerChannel:             q.PlayerChannel.WithContext(ctx),
		PlayerDayTask:             q.PlayerDayTask.WithContext(ctx),
		PlayerDivination:          q.PlayerDivination.WithContext(ctx),
		PlayerDp:                  q.PlayerDp.WithContext(ctx),
		PlayerLetter:              q.PlayerLetter.WithContext(ctx),
		PlayerLogin:               q.PlayerLogin.WithContext(ctx),
		PlayerMailbox:             q.PlayerMailbox.WithContext(ctx),
		PlayerMaterial:            q.PlayerMaterial.WithContext(ctx),
		PlayerPatrol:              q.PlayerPatrol.WithContext(ctx),
		PlayerTask:                q.PlayerTask.WithContext(ctx),
		Processaward:              q.Processaward.WithContext(ctx),
		RedeemCode:                q.RedeemCode.WithContext(ctx),
		RedeemPeripheralsReceived: q.RedeemPeripheralsReceived.WithContext(ctx),
		RedeemReceived:            q.RedeemReceived.WithContext(ctx),
		ReportDayAdvBasic:         q.ReportDayAdvBasic.WithContext(ctx),
		ReportDayAdvSumm:          q.ReportDayAdvSumm.WithContext(ctx),
		ReportDayBasic:            q.ReportDayBasic.WithContext(ctx),
		ReportDayBoss:             q.ReportDayBoss.WithContext(ctx),
		ReportDayChapterPass:      q.ReportDayChapterPass.WithContext(ctx),
		ReportDayDisconnect:       q.ReportDayDisconnect.WithContext(ctx),
		ReportDayDuel:             q.ReportDayDuel.WithContext(ctx),
		ReportDayEventBasic:       q.ReportDayEventBasic.WithContext(ctx),
		ReportDayExpedition:       q.ReportDayExpedition.WithContext(ctx),
		ReportDayFirstAdv:         q.ReportDayFirstAdv.WithContext(ctx),
		ReportDayGem:              q.ReportDayGem.WithContext(ctx),
		ReportDayGoodsBasic:       q.ReportDayGoodsBasic.WithContext(ctx),
		ReportDayGrandmaster:      q.ReportDayGrandmaster.WithContext(ctx),
		ReportDayGudong:           q.ReportDayGudong.WithContext(ctx),
		ReportDayHaveRole:         q.ReportDayHaveRole.WithContext(ctx),
		ReportDayIdiom:            q.ReportDayIdiom.WithContext(ctx),
		ReportDayLimitgift:        q.ReportDayLimitgift.WithContext(ctx),
		ReportDayNewConv:          q.ReportDayNewConv.WithContext(ctx),
		ReportDaySeven:            q.ReportDaySeven.WithContext(ctx),
		ReportDayTreasure:         q.ReportDayTreasure.WithContext(ctx),
		ReportDayTreasureChest:    q.ReportDayTreasureChest.WithContext(ctx),
		ReportEvent:               q.ReportEvent.WithContext(ctx),
		ReportLevelOutput:         q.ReportLevelOutput.WithContext(ctx),
		Retrofit:                  q.Retrofit.WithContext(ctx),
		RetrofitGroup:             q.RetrofitGroup.WithContext(ctx),
		Role:                      q.Role.WithContext(ctx),
		RolesLog:                  q.RolesLog.WithContext(ctx),
		ServerDeploy:              q.ServerDeploy.WithContext(ctx),
		ServerDeployLog:           q.ServerDeployLog.WithContext(ctx),
		ServerDeployStat:          q.ServerDeployStat.WithContext(ctx),
		ServerOption:              q.ServerOption.WithContext(ctx),
		SevenLog:                  q.SevenLog.WithContext(ctx),
		Signin:                    q.Signin.WithContext(ctx),
		ToolsRestartLog:           q.ToolsRestartLog.WithContext(ctx),
		TreasureChestLog:          q.TreasureChestLog.WithContext(ctx),
		TreasureLog:               q.TreasureLog.WithContext(ctx),
		UserAccount:               q.UserAccount.WithContext(ctx),
		UserChapterLog:            q.UserChapterLog.WithContext(ctx),
		WxpayOrder:                q.WxpayOrder.WithContext(ctx),
		WxpayPlayer:               q.WxpayPlayer.WithContext(ctx),
		ZoneActivity:              q.ZoneActivity.WithContext(ctx),
		Chat: 					   q.Chat.WithContext(ctx),
		AdminBanUserLog:    	   q.AdminBanUserLog.WithContext(ctx),
		ChatReportLog: 			   q.ChatReportLog.WithContext(ctx),
		ChatMsgLog: 			   q.ChatMsgLog.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 {
	return &QueryTx{q.clone(q.db.Begin(opts...))}
}

type QueryTx struct{ *Query }

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
}
