// 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" "gadmin/internal/gorm/model" ) func newUserChapterLog(db *gorm.DB, opts ...gen.DOOption) userChapterLog { _userChapterLog := userChapterLog{} _userChapterLog.userChapterLogDo.UseDB(db, opts...) _userChapterLog.userChapterLogDo.UseModel(&model.UserChapterLog{}) tableName := _userChapterLog.userChapterLogDo.TableName() _userChapterLog.ALL = field.NewAsterisk(tableName) _userChapterLog.ID = field.NewInt64(tableName, "id") _userChapterLog.UserID = field.NewInt64(tableName, "user_id") _userChapterLog.ServerID = field.NewInt32(tableName, "server_id") _userChapterLog.UserCreatedAt = field.NewInt32(tableName, "user_created_at") _userChapterLog.ChapterID = field.NewInt32(tableName, "chapter_id") _userChapterLog.RoomID = field.NewInt32(tableName, "room_id") _userChapterLog.Difficulty = field.NewInt32(tableName, "difficulty") _userChapterLog.UpdatedAt = field.NewInt32(tableName, "updated_at") _userChapterLog.SettleRoomID = field.NewInt32(tableName, "settle_room_id") _userChapterLog.fillFieldMap() return _userChapterLog } type userChapterLog struct { userChapterLogDo ALL field.Asterisk ID field.Int64 UserID field.Int64 ServerID field.Int32 // 服务器ID UserCreatedAt field.Int32 ChapterID field.Int32 // 当前关卡id,如果有新的关卡,则更新 RoomID field.Int32 // 进入房间id Difficulty field.Int32 // 困难度 UpdatedAt field.Int32 // 更新时间 SettleRoomID field.Int32 // 结算房间id fieldMap map[string]field.Expr } func (u userChapterLog) Table(newTableName string) *userChapterLog { u.userChapterLogDo.UseTable(newTableName) return u.updateTableName(newTableName) } func (u userChapterLog) As(alias string) *userChapterLog { u.userChapterLogDo.DO = *(u.userChapterLogDo.As(alias).(*gen.DO)) return u.updateTableName(alias) } func (u *userChapterLog) updateTableName(table string) *userChapterLog { u.ALL = field.NewAsterisk(table) u.ID = field.NewInt64(table, "id") u.UserID = field.NewInt64(table, "user_id") u.ServerID = field.NewInt32(table, "server_id") u.UserCreatedAt = field.NewInt32(table, "user_created_at") u.ChapterID = field.NewInt32(table, "chapter_id") u.RoomID = field.NewInt32(table, "room_id") u.Difficulty = field.NewInt32(table, "difficulty") u.UpdatedAt = field.NewInt32(table, "updated_at") u.SettleRoomID = field.NewInt32(table, "settle_room_id") u.fillFieldMap() return u } func (u *userChapterLog) 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 *userChapterLog) fillFieldMap() { u.fieldMap = make(map[string]field.Expr, 9) u.fieldMap["id"] = u.ID u.fieldMap["user_id"] = u.UserID u.fieldMap["server_id"] = u.ServerID u.fieldMap["user_created_at"] = u.UserCreatedAt u.fieldMap["chapter_id"] = u.ChapterID u.fieldMap["room_id"] = u.RoomID u.fieldMap["difficulty"] = u.Difficulty u.fieldMap["updated_at"] = u.UpdatedAt u.fieldMap["settle_room_id"] = u.SettleRoomID } func (u userChapterLog) clone(db *gorm.DB) userChapterLog { u.userChapterLogDo.ReplaceConnPool(db.Statement.ConnPool) return u } func (u userChapterLog) replaceDB(db *gorm.DB) userChapterLog { u.userChapterLogDo.ReplaceDB(db) return u } type userChapterLogDo struct{ gen.DO } func (u userChapterLogDo) Debug() *userChapterLogDo { return u.withDO(u.DO.Debug()) } func (u userChapterLogDo) WithContext(ctx context.Context) *userChapterLogDo { return u.withDO(u.DO.WithContext(ctx)) } func (u userChapterLogDo) ReadDB() *userChapterLogDo { return u.Clauses(dbresolver.Read) } func (u userChapterLogDo) WriteDB() *userChapterLogDo { return u.Clauses(dbresolver.Write) } func (u userChapterLogDo) Session(config *gorm.Session) *userChapterLogDo { return u.withDO(u.DO.Session(config)) } func (u userChapterLogDo) Clauses(conds ...clause.Expression) *userChapterLogDo { return u.withDO(u.DO.Clauses(conds...)) } func (u userChapterLogDo) Returning(value interface{}, columns ...string) *userChapterLogDo { return u.withDO(u.DO.Returning(value, columns...)) } func (u userChapterLogDo) Not(conds ...gen.Condition) *userChapterLogDo { return u.withDO(u.DO.Not(conds...)) } func (u userChapterLogDo) Or(conds ...gen.Condition) *userChapterLogDo { return u.withDO(u.DO.Or(conds...)) } func (u userChapterLogDo) Select(conds ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Select(conds...)) } func (u userChapterLogDo) Where(conds ...gen.Condition) *userChapterLogDo { return u.withDO(u.DO.Where(conds...)) } func (u userChapterLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *userChapterLogDo { return u.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (u userChapterLogDo) Order(conds ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Order(conds...)) } func (u userChapterLogDo) Distinct(cols ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Distinct(cols...)) } func (u userChapterLogDo) Omit(cols ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Omit(cols...)) } func (u userChapterLogDo) Join(table schema.Tabler, on ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Join(table, on...)) } func (u userChapterLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.LeftJoin(table, on...)) } func (u userChapterLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.RightJoin(table, on...)) } func (u userChapterLogDo) Group(cols ...field.Expr) *userChapterLogDo { return u.withDO(u.DO.Group(cols...)) } func (u userChapterLogDo) Having(conds ...gen.Condition) *userChapterLogDo { return u.withDO(u.DO.Having(conds...)) } func (u userChapterLogDo) Limit(limit int) *userChapterLogDo { return u.withDO(u.DO.Limit(limit)) } func (u userChapterLogDo) Offset(offset int) *userChapterLogDo { return u.withDO(u.DO.Offset(offset)) } func (u userChapterLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *userChapterLogDo { return u.withDO(u.DO.Scopes(funcs...)) } func (u userChapterLogDo) Unscoped() *userChapterLogDo { return u.withDO(u.DO.Unscoped()) } func (u userChapterLogDo) Create(values ...*model.UserChapterLog) error { if len(values) == 0 { return nil } return u.DO.Create(values) } func (u userChapterLogDo) CreateInBatches(values []*model.UserChapterLog, 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 userChapterLogDo) Save(values ...*model.UserChapterLog) error { if len(values) == 0 { return nil } return u.DO.Save(values) } func (u userChapterLogDo) First() (*model.UserChapterLog, error) { if result, err := u.DO.First(); err != nil { return nil, err } else { return result.(*model.UserChapterLog), nil } } func (u userChapterLogDo) Take() (*model.UserChapterLog, error) { if result, err := u.DO.Take(); err != nil { return nil, err } else { return result.(*model.UserChapterLog), nil } } func (u userChapterLogDo) Last() (*model.UserChapterLog, error) { if result, err := u.DO.Last(); err != nil { return nil, err } else { return result.(*model.UserChapterLog), nil } } func (u userChapterLogDo) Find() ([]*model.UserChapterLog, error) { result, err := u.DO.Find() return result.([]*model.UserChapterLog), err } func (u userChapterLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.UserChapterLog, err error) { buf := make([]*model.UserChapterLog, 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 userChapterLogDo) FindInBatches(result *[]*model.UserChapterLog, batchSize int, fc func(tx gen.Dao, batch int) error) error { return u.DO.FindInBatches(result, batchSize, fc) } func (u userChapterLogDo) Attrs(attrs ...field.AssignExpr) *userChapterLogDo { return u.withDO(u.DO.Attrs(attrs...)) } func (u userChapterLogDo) Assign(attrs ...field.AssignExpr) *userChapterLogDo { return u.withDO(u.DO.Assign(attrs...)) } func (u userChapterLogDo) Joins(fields ...field.RelationField) *userChapterLogDo { for _, _f := range fields { u = *u.withDO(u.DO.Joins(_f)) } return &u } func (u userChapterLogDo) Preload(fields ...field.RelationField) *userChapterLogDo { for _, _f := range fields { u = *u.withDO(u.DO.Preload(_f)) } return &u } func (u userChapterLogDo) FirstOrInit() (*model.UserChapterLog, error) { if result, err := u.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.UserChapterLog), nil } } func (u userChapterLogDo) FirstOrCreate() (*model.UserChapterLog, error) { if result, err := u.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.UserChapterLog), nil } } func (u userChapterLogDo) FindByPage(offset int, limit int) (result []*model.UserChapterLog, 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 userChapterLogDo) 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 userChapterLogDo) Scan(result interface{}) (err error) { return u.DO.Scan(result) } func (u userChapterLogDo) Delete(models ...*model.UserChapterLog) (result gen.ResultInfo, err error) { return u.DO.Delete(models) } func (u *userChapterLogDo) withDO(do gen.Dao) *userChapterLogDo { u.DO = *do.(*gen.DO) return u }