Files
servicebase/pkg/repo/gen.go
2025-11-18 17:48:20 +08:00

184 lines
5.3 KiB
Go

// 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 repo
import (
"context"
"database/sql"
"gorm.io/gorm"
"gorm.io/gen"
"gorm.io/plugin/dbresolver"
)
var (
Q = new(Query)
AdminPrivilege *adminPrivilege
AdminRole *adminRole
AdminRolePrivilege *adminRolePrivilege
AdminUser *adminUser
AdminUserRole *adminUserRole
DataAttach *dataAttach
Game *game
TradeCommodity *tradeCommodity
User *user
UserGameRole *userGameRole
UserGameRoleProp *userGameRoleProp
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
AdminPrivilege = &Q.AdminPrivilege
AdminRole = &Q.AdminRole
AdminRolePrivilege = &Q.AdminRolePrivilege
AdminUser = &Q.AdminUser
AdminUserRole = &Q.AdminUserRole
DataAttach = &Q.DataAttach
Game = &Q.Game
TradeCommodity = &Q.TradeCommodity
User = &Q.User
UserGameRole = &Q.UserGameRole
UserGameRoleProp = &Q.UserGameRoleProp
}
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
AdminPrivilege: newAdminPrivilege(db, opts...),
AdminRole: newAdminRole(db, opts...),
AdminRolePrivilege: newAdminRolePrivilege(db, opts...),
AdminUser: newAdminUser(db, opts...),
AdminUserRole: newAdminUserRole(db, opts...),
DataAttach: newDataAttach(db, opts...),
Game: newGame(db, opts...),
TradeCommodity: newTradeCommodity(db, opts...),
User: newUser(db, opts...),
UserGameRole: newUserGameRole(db, opts...),
UserGameRoleProp: newUserGameRoleProp(db, opts...),
}
}
type Query struct {
db *gorm.DB
AdminPrivilege adminPrivilege
AdminRole adminRole
AdminRolePrivilege adminRolePrivilege
AdminUser adminUser
AdminUserRole adminUserRole
DataAttach dataAttach
Game game
TradeCommodity tradeCommodity
User user
UserGameRole userGameRole
UserGameRoleProp userGameRoleProp
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
AdminPrivilege: q.AdminPrivilege.clone(db),
AdminRole: q.AdminRole.clone(db),
AdminRolePrivilege: q.AdminRolePrivilege.clone(db),
AdminUser: q.AdminUser.clone(db),
AdminUserRole: q.AdminUserRole.clone(db),
DataAttach: q.DataAttach.clone(db),
Game: q.Game.clone(db),
TradeCommodity: q.TradeCommodity.clone(db),
User: q.User.clone(db),
UserGameRole: q.UserGameRole.clone(db),
UserGameRoleProp: q.UserGameRoleProp.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,
AdminPrivilege: q.AdminPrivilege.replaceDB(db),
AdminRole: q.AdminRole.replaceDB(db),
AdminRolePrivilege: q.AdminRolePrivilege.replaceDB(db),
AdminUser: q.AdminUser.replaceDB(db),
AdminUserRole: q.AdminUserRole.replaceDB(db),
DataAttach: q.DataAttach.replaceDB(db),
Game: q.Game.replaceDB(db),
TradeCommodity: q.TradeCommodity.replaceDB(db),
User: q.User.replaceDB(db),
UserGameRole: q.UserGameRole.replaceDB(db),
UserGameRoleProp: q.UserGameRoleProp.replaceDB(db),
}
}
type queryCtx struct {
AdminPrivilege IAdminPrivilegeDo
AdminRole IAdminRoleDo
AdminRolePrivilege IAdminRolePrivilegeDo
AdminUser IAdminUserDo
AdminUserRole IAdminUserRoleDo
DataAttach IDataAttachDo
Game IGameDo
TradeCommodity ITradeCommodityDo
User IUserDo
UserGameRole IUserGameRoleDo
UserGameRoleProp IUserGameRolePropDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
AdminPrivilege: q.AdminPrivilege.WithContext(ctx),
AdminRole: q.AdminRole.WithContext(ctx),
AdminRolePrivilege: q.AdminRolePrivilege.WithContext(ctx),
AdminUser: q.AdminUser.WithContext(ctx),
AdminUserRole: q.AdminUserRole.WithContext(ctx),
DataAttach: q.DataAttach.WithContext(ctx),
Game: q.Game.WithContext(ctx),
TradeCommodity: q.TradeCommodity.WithContext(ctx),
User: q.User.WithContext(ctx),
UserGameRole: q.UserGameRole.WithContext(ctx),
UserGameRoleProp: q.UserGameRoleProp.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
}