youtu_ecpm/dao/query/game_score.gen.go

338 lines
8.5 KiB
Go
Raw Normal View History

2025-01-18 17:56:36 +08:00
// 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"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
2025-01-20 00:11:11 +08:00
"gitea.youtukeji.com.cn/xiabin/youtu_ecpm/dao/model"
2025-01-18 17:56:36 +08:00
)
func newGameScore(db *gorm.DB, opts ...gen.DOOption) gameScore {
_gameScore := gameScore{}
_gameScore.gameScoreDo.UseDB(db, opts...)
_gameScore.gameScoreDo.UseModel(&model.GameScore{})
tableName := _gameScore.gameScoreDo.TableName()
_gameScore.ALL = field.NewAsterisk(tableName)
_gameScore.AppUserID = field.NewUint64(tableName, "app_user_id")
_gameScore.AppAccount = field.NewUint32(tableName, "app_account")
_gameScore.Score = field.NewUint32(tableName, "score")
_gameScore.fillFieldMap()
return _gameScore
}
type gameScore struct {
gameScoreDo gameScoreDo
ALL field.Asterisk
AppUserID field.Uint64
AppAccount field.Uint32
Score field.Uint32
fieldMap map[string]field.Expr
}
func (g gameScore) Table(newTableName string) *gameScore {
g.gameScoreDo.UseTable(newTableName)
return g.updateTableName(newTableName)
}
func (g gameScore) As(alias string) *gameScore {
g.gameScoreDo.DO = *(g.gameScoreDo.As(alias).(*gen.DO))
return g.updateTableName(alias)
}
func (g *gameScore) updateTableName(table string) *gameScore {
g.ALL = field.NewAsterisk(table)
g.AppUserID = field.NewUint64(table, "app_user_id")
g.AppAccount = field.NewUint32(table, "app_account")
g.Score = field.NewUint32(table, "score")
g.fillFieldMap()
return g
}
func (g *gameScore) WithContext(ctx context.Context) *gameScoreDo {
return g.gameScoreDo.WithContext(ctx)
}
func (g gameScore) TableName() string { return g.gameScoreDo.TableName() }
func (g gameScore) Alias() string { return g.gameScoreDo.Alias() }
func (g gameScore) Columns(cols ...field.Expr) gen.Columns { return g.gameScoreDo.Columns(cols...) }
func (g *gameScore) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := g.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (g *gameScore) fillFieldMap() {
g.fieldMap = make(map[string]field.Expr, 3)
g.fieldMap["app_user_id"] = g.AppUserID
g.fieldMap["app_account"] = g.AppAccount
g.fieldMap["score"] = g.Score
}
func (g gameScore) clone(db *gorm.DB) gameScore {
g.gameScoreDo.ReplaceConnPool(db.Statement.ConnPool)
return g
}
func (g gameScore) replaceDB(db *gorm.DB) gameScore {
g.gameScoreDo.ReplaceDB(db)
return g
}
type gameScoreDo struct{ gen.DO }
func (g gameScoreDo) Debug() *gameScoreDo {
return g.withDO(g.DO.Debug())
}
func (g gameScoreDo) WithContext(ctx context.Context) *gameScoreDo {
return g.withDO(g.DO.WithContext(ctx))
}
func (g gameScoreDo) ReadDB() *gameScoreDo {
return g.Clauses(dbresolver.Read)
}
func (g gameScoreDo) WriteDB() *gameScoreDo {
return g.Clauses(dbresolver.Write)
}
func (g gameScoreDo) Session(config *gorm.Session) *gameScoreDo {
return g.withDO(g.DO.Session(config))
}
func (g gameScoreDo) Clauses(conds ...clause.Expression) *gameScoreDo {
return g.withDO(g.DO.Clauses(conds...))
}
func (g gameScoreDo) Returning(value interface{}, columns ...string) *gameScoreDo {
return g.withDO(g.DO.Returning(value, columns...))
}
func (g gameScoreDo) Not(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Not(conds...))
}
func (g gameScoreDo) Or(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Or(conds...))
}
func (g gameScoreDo) Select(conds ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Select(conds...))
}
func (g gameScoreDo) Where(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Where(conds...))
}
func (g gameScoreDo) Order(conds ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Order(conds...))
}
func (g gameScoreDo) Distinct(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Distinct(cols...))
}
func (g gameScoreDo) Omit(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Omit(cols...))
}
func (g gameScoreDo) Join(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Join(table, on...))
}
func (g gameScoreDo) LeftJoin(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.LeftJoin(table, on...))
}
func (g gameScoreDo) RightJoin(table schema.Tabler, on ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.RightJoin(table, on...))
}
func (g gameScoreDo) Group(cols ...field.Expr) *gameScoreDo {
return g.withDO(g.DO.Group(cols...))
}
func (g gameScoreDo) Having(conds ...gen.Condition) *gameScoreDo {
return g.withDO(g.DO.Having(conds...))
}
func (g gameScoreDo) Limit(limit int) *gameScoreDo {
return g.withDO(g.DO.Limit(limit))
}
func (g gameScoreDo) Offset(offset int) *gameScoreDo {
return g.withDO(g.DO.Offset(offset))
}
func (g gameScoreDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *gameScoreDo {
return g.withDO(g.DO.Scopes(funcs...))
}
func (g gameScoreDo) Unscoped() *gameScoreDo {
return g.withDO(g.DO.Unscoped())
}
func (g gameScoreDo) Create(values ...*model.GameScore) error {
if len(values) == 0 {
return nil
}
return g.DO.Create(values)
}
func (g gameScoreDo) CreateInBatches(values []*model.GameScore, batchSize int) error {
return g.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 (g gameScoreDo) Save(values ...*model.GameScore) error {
if len(values) == 0 {
return nil
}
return g.DO.Save(values)
}
func (g gameScoreDo) First() (*model.GameScore, error) {
if result, err := g.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Take() (*model.GameScore, error) {
if result, err := g.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Last() (*model.GameScore, error) {
if result, err := g.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) Find() ([]*model.GameScore, error) {
result, err := g.DO.Find()
return result.([]*model.GameScore), err
}
func (g gameScoreDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.GameScore, err error) {
buf := make([]*model.GameScore, 0, batchSize)
err = g.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 (g gameScoreDo) FindInBatches(result *[]*model.GameScore, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return g.DO.FindInBatches(result, batchSize, fc)
}
func (g gameScoreDo) Attrs(attrs ...field.AssignExpr) *gameScoreDo {
return g.withDO(g.DO.Attrs(attrs...))
}
func (g gameScoreDo) Assign(attrs ...field.AssignExpr) *gameScoreDo {
return g.withDO(g.DO.Assign(attrs...))
}
func (g gameScoreDo) Joins(fields ...field.RelationField) *gameScoreDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Joins(_f))
}
return &g
}
func (g gameScoreDo) Preload(fields ...field.RelationField) *gameScoreDo {
for _, _f := range fields {
g = *g.withDO(g.DO.Preload(_f))
}
return &g
}
func (g gameScoreDo) FirstOrInit() (*model.GameScore, error) {
if result, err := g.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) FirstOrCreate() (*model.GameScore, error) {
if result, err := g.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.GameScore), nil
}
}
func (g gameScoreDo) FindByPage(offset int, limit int) (result []*model.GameScore, count int64, err error) {
result, err = g.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 = g.Offset(-1).Limit(-1).Count()
return
}
func (g gameScoreDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = g.Count()
if err != nil {
return
}
err = g.Offset(offset).Limit(limit).Scan(result)
return
}
func (g gameScoreDo) Scan(result interface{}) (err error) {
return g.DO.Scan(result)
}
func (g gameScoreDo) Delete(models ...*model.GameScore) (result gen.ResultInfo, err error) {
return g.DO.Delete(models)
}
func (g *gameScoreDo) withDO(do gen.Dao) *gameScoreDo {
g.DO = *do.(*gen.DO)
return g
}