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

442 lines
14 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"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"servicebase/pkg/model"
)
func newUserGameRole(db *gorm.DB, opts ...gen.DOOption) userGameRole {
_userGameRole := userGameRole{}
_userGameRole.userGameRoleDo.UseDB(db, opts...)
_userGameRole.userGameRoleDo.UseModel(&model.UserGameRole{})
tableName := _userGameRole.userGameRoleDo.TableName()
_userGameRole.ALL = field.NewAsterisk(tableName)
_userGameRole.ID = field.NewString(tableName, "id")
_userGameRole.GameID = field.NewString(tableName, "game_id")
_userGameRole.GameRoleName = field.NewString(tableName, "game_role_name")
_userGameRole.GameRoleID = field.NewString(tableName, "game_role_id")
_userGameRole.Desc = field.NewString(tableName, "desc")
_userGameRole.Icon = field.NewString(tableName, "icon")
_userGameRole.Logo = field.NewString(tableName, "logo")
_userGameRole.State = field.NewInt32(tableName, "state")
_userGameRole.DeleteAt = field.NewField(tableName, "delete_at")
_userGameRole.CreateAt = field.NewTime(tableName, "create_at")
_userGameRole.CreateBy = field.NewString(tableName, "create_by")
_userGameRole.UpdateAt = field.NewTime(tableName, "update_at")
_userGameRole.UpdateBy = field.NewString(tableName, "update_by")
_userGameRole.fillFieldMap()
return _userGameRole
}
// userGameRole 用户的游戏角色
type userGameRole struct {
userGameRoleDo userGameRoleDo
ALL field.Asterisk
ID field.String // 业务ID
GameID field.String // 游戏
GameRoleName field.String // 角色名称
GameRoleID field.String // 角色ID
Desc field.String // 描述
Icon field.String // 图标
Logo field.String // logo
State field.Int32 // 状态1=启用 2=禁用
DeleteAt field.Field // del标志
CreateAt field.Time // 创建时间
CreateBy field.String // 创建人
UpdateAt field.Time // 更新时间
UpdateBy field.String // 更新人
fieldMap map[string]field.Expr
}
func (u userGameRole) Table(newTableName string) *userGameRole {
u.userGameRoleDo.UseTable(newTableName)
return u.updateTableName(newTableName)
}
func (u userGameRole) As(alias string) *userGameRole {
u.userGameRoleDo.DO = *(u.userGameRoleDo.As(alias).(*gen.DO))
return u.updateTableName(alias)
}
func (u *userGameRole) updateTableName(table string) *userGameRole {
u.ALL = field.NewAsterisk(table)
u.ID = field.NewString(table, "id")
u.GameID = field.NewString(table, "game_id")
u.GameRoleName = field.NewString(table, "game_role_name")
u.GameRoleID = field.NewString(table, "game_role_id")
u.Desc = field.NewString(table, "desc")
u.Icon = field.NewString(table, "icon")
u.Logo = field.NewString(table, "logo")
u.State = field.NewInt32(table, "state")
u.DeleteAt = field.NewField(table, "delete_at")
u.CreateAt = field.NewTime(table, "create_at")
u.CreateBy = field.NewString(table, "create_by")
u.UpdateAt = field.NewTime(table, "update_at")
u.UpdateBy = field.NewString(table, "update_by")
u.fillFieldMap()
return u
}
func (u *userGameRole) WithContext(ctx context.Context) IUserGameRoleDo {
return u.userGameRoleDo.WithContext(ctx)
}
func (u userGameRole) TableName() string { return u.userGameRoleDo.TableName() }
func (u userGameRole) Alias() string { return u.userGameRoleDo.Alias() }
func (u userGameRole) Columns(cols ...field.Expr) gen.Columns {
return u.userGameRoleDo.Columns(cols...)
}
func (u *userGameRole) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := u.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (u *userGameRole) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 13)
u.fieldMap["id"] = u.ID
u.fieldMap["game_id"] = u.GameID
u.fieldMap["game_role_name"] = u.GameRoleName
u.fieldMap["game_role_id"] = u.GameRoleID
u.fieldMap["desc"] = u.Desc
u.fieldMap["icon"] = u.Icon
u.fieldMap["logo"] = u.Logo
u.fieldMap["state"] = u.State
u.fieldMap["delete_at"] = u.DeleteAt
u.fieldMap["create_at"] = u.CreateAt
u.fieldMap["create_by"] = u.CreateBy
u.fieldMap["update_at"] = u.UpdateAt
u.fieldMap["update_by"] = u.UpdateBy
}
func (u userGameRole) clone(db *gorm.DB) userGameRole {
u.userGameRoleDo.ReplaceConnPool(db.Statement.ConnPool)
return u
}
func (u userGameRole) replaceDB(db *gorm.DB) userGameRole {
u.userGameRoleDo.ReplaceDB(db)
return u
}
type userGameRoleDo struct{ gen.DO }
type IUserGameRoleDo interface {
gen.SubQuery
Debug() IUserGameRoleDo
WithContext(ctx context.Context) IUserGameRoleDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IUserGameRoleDo
WriteDB() IUserGameRoleDo
As(alias string) gen.Dao
Session(config *gorm.Session) IUserGameRoleDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IUserGameRoleDo
Not(conds ...gen.Condition) IUserGameRoleDo
Or(conds ...gen.Condition) IUserGameRoleDo
Select(conds ...field.Expr) IUserGameRoleDo
Where(conds ...gen.Condition) IUserGameRoleDo
Order(conds ...field.Expr) IUserGameRoleDo
Distinct(cols ...field.Expr) IUserGameRoleDo
Omit(cols ...field.Expr) IUserGameRoleDo
Join(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo
Group(cols ...field.Expr) IUserGameRoleDo
Having(conds ...gen.Condition) IUserGameRoleDo
Limit(limit int) IUserGameRoleDo
Offset(offset int) IUserGameRoleDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRoleDo
Unscoped() IUserGameRoleDo
Create(values ...*model.UserGameRole) error
CreateInBatches(values []*model.UserGameRole, batchSize int) error
Save(values ...*model.UserGameRole) error
First() (*model.UserGameRole, error)
Take() (*model.UserGameRole, error)
Last() (*model.UserGameRole, error)
Find() ([]*model.UserGameRole, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRole, err error)
FindInBatches(result *[]*model.UserGameRole, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.UserGameRole) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IUserGameRoleDo
Assign(attrs ...field.AssignExpr) IUserGameRoleDo
Joins(fields ...field.RelationField) IUserGameRoleDo
Preload(fields ...field.RelationField) IUserGameRoleDo
FirstOrInit() (*model.UserGameRole, error)
FirstOrCreate() (*model.UserGameRole, error)
FindByPage(offset int, limit int) (result []*model.UserGameRole, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IUserGameRoleDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (u userGameRoleDo) Debug() IUserGameRoleDo {
return u.withDO(u.DO.Debug())
}
func (u userGameRoleDo) WithContext(ctx context.Context) IUserGameRoleDo {
return u.withDO(u.DO.WithContext(ctx))
}
func (u userGameRoleDo) ReadDB() IUserGameRoleDo {
return u.Clauses(dbresolver.Read)
}
func (u userGameRoleDo) WriteDB() IUserGameRoleDo {
return u.Clauses(dbresolver.Write)
}
func (u userGameRoleDo) Session(config *gorm.Session) IUserGameRoleDo {
return u.withDO(u.DO.Session(config))
}
func (u userGameRoleDo) Clauses(conds ...clause.Expression) IUserGameRoleDo {
return u.withDO(u.DO.Clauses(conds...))
}
func (u userGameRoleDo) Returning(value interface{}, columns ...string) IUserGameRoleDo {
return u.withDO(u.DO.Returning(value, columns...))
}
func (u userGameRoleDo) Not(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Not(conds...))
}
func (u userGameRoleDo) Or(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Or(conds...))
}
func (u userGameRoleDo) Select(conds ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Select(conds...))
}
func (u userGameRoleDo) Where(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Where(conds...))
}
func (u userGameRoleDo) Order(conds ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Order(conds...))
}
func (u userGameRoleDo) Distinct(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Distinct(cols...))
}
func (u userGameRoleDo) Omit(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Omit(cols...))
}
func (u userGameRoleDo) Join(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Join(table, on...))
}
func (u userGameRoleDo) LeftJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.LeftJoin(table, on...))
}
func (u userGameRoleDo) RightJoin(table schema.Tabler, on ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.RightJoin(table, on...))
}
func (u userGameRoleDo) Group(cols ...field.Expr) IUserGameRoleDo {
return u.withDO(u.DO.Group(cols...))
}
func (u userGameRoleDo) Having(conds ...gen.Condition) IUserGameRoleDo {
return u.withDO(u.DO.Having(conds...))
}
func (u userGameRoleDo) Limit(limit int) IUserGameRoleDo {
return u.withDO(u.DO.Limit(limit))
}
func (u userGameRoleDo) Offset(offset int) IUserGameRoleDo {
return u.withDO(u.DO.Offset(offset))
}
func (u userGameRoleDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IUserGameRoleDo {
return u.withDO(u.DO.Scopes(funcs...))
}
func (u userGameRoleDo) Unscoped() IUserGameRoleDo {
return u.withDO(u.DO.Unscoped())
}
func (u userGameRoleDo) Create(values ...*model.UserGameRole) error {
if len(values) == 0 {
return nil
}
return u.DO.Create(values)
}
func (u userGameRoleDo) CreateInBatches(values []*model.UserGameRole, batchSize int) error {
return u.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (u userGameRoleDo) Save(values ...*model.UserGameRole) error {
if len(values) == 0 {
return nil
}
return u.DO.Save(values)
}
func (u userGameRoleDo) First() (*model.UserGameRole, error) {
if result, err := u.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Take() (*model.UserGameRole, error) {
if result, err := u.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Last() (*model.UserGameRole, error) {
if result, err := u.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) Find() ([]*model.UserGameRole, error) {
result, err := u.DO.Find()
return result.([]*model.UserGameRole), err
}
func (u userGameRoleDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserGameRole, err error) {
buf := make([]*model.UserGameRole, 0, batchSize)
err = u.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (u userGameRoleDo) FindInBatches(result *[]*model.UserGameRole, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return u.DO.FindInBatches(result, batchSize, fc)
}
func (u userGameRoleDo) Attrs(attrs ...field.AssignExpr) IUserGameRoleDo {
return u.withDO(u.DO.Attrs(attrs...))
}
func (u userGameRoleDo) Assign(attrs ...field.AssignExpr) IUserGameRoleDo {
return u.withDO(u.DO.Assign(attrs...))
}
func (u userGameRoleDo) Joins(fields ...field.RelationField) IUserGameRoleDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Joins(_f))
}
return &u
}
func (u userGameRoleDo) Preload(fields ...field.RelationField) IUserGameRoleDo {
for _, _f := range fields {
u = *u.withDO(u.DO.Preload(_f))
}
return &u
}
func (u userGameRoleDo) FirstOrInit() (*model.UserGameRole, error) {
if result, err := u.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) FirstOrCreate() (*model.UserGameRole, error) {
if result, err := u.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.UserGameRole), nil
}
}
func (u userGameRoleDo) FindByPage(offset int, limit int) (result []*model.UserGameRole, count int64, err error) {
result, err = u.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = u.Offset(-1).Limit(-1).Count()
return
}
func (u userGameRoleDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = u.Count()
if err != nil {
return
}
err = u.Offset(offset).Limit(limit).Scan(result)
return
}
func (u userGameRoleDo) Scan(result interface{}) (err error) {
return u.DO.Scan(result)
}
func (u userGameRoleDo) Delete(models ...*model.UserGameRole) (result gen.ResultInfo, err error) {
return u.DO.Delete(models)
}
func (u *userGameRoleDo) withDO(do gen.Dao) *userGameRoleDo {
u.DO = *do.(*gen.DO)
return u
}