// 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" "git.hlsq.asia/mmorpg/service-qgdzs/internal/dao/model" ) func newPointRecord(db *gorm.DB, opts ...gen.DOOption) pointRecord { _pointRecord := pointRecord{} _pointRecord.pointRecordDo.UseDB(db, opts...) _pointRecord.pointRecordDo.UseModel(&model.PointRecord{}) tableName := _pointRecord.pointRecordDo.TableName() _pointRecord.ALL = field.NewAsterisk(tableName) _pointRecord.ID = field.NewUint64(tableName, "id") _pointRecord.Sn = field.NewInt64(tableName, "sn") _pointRecord.UserSn = field.NewInt64(tableName, "user_sn") _pointRecord.Source = field.NewInt32(tableName, "source") _pointRecord.Point = field.NewInt64(tableName, "point") _pointRecord.CreatedAt = field.NewTime(tableName, "created_at") _pointRecord.UpdatedAt = field.NewTime(tableName, "updated_at") _pointRecord.DeletedAt = field.NewField(tableName, "deleted_at") _pointRecord.fillFieldMap() return _pointRecord } type pointRecord struct { pointRecordDo pointRecordDo ALL field.Asterisk ID field.Uint64 Sn field.Int64 // 业务唯一编号 UserSn field.Int64 // 用户-唯一编号 /* 来源: 0. 未知 1. 随机答题 2. 类目答题 3. 限时答题 */ Source field.Int32 Point field.Int64 // 积分 CreatedAt field.Time UpdatedAt field.Time DeletedAt field.Field fieldMap map[string]field.Expr } func (p pointRecord) Table(newTableName string) *pointRecord { p.pointRecordDo.UseTable(newTableName) return p.updateTableName(newTableName) } func (p pointRecord) As(alias string) *pointRecord { p.pointRecordDo.DO = *(p.pointRecordDo.As(alias).(*gen.DO)) return p.updateTableName(alias) } func (p *pointRecord) updateTableName(table string) *pointRecord { p.ALL = field.NewAsterisk(table) p.ID = field.NewUint64(table, "id") p.Sn = field.NewInt64(table, "sn") p.UserSn = field.NewInt64(table, "user_sn") p.Source = field.NewInt32(table, "source") p.Point = field.NewInt64(table, "point") p.CreatedAt = field.NewTime(table, "created_at") p.UpdatedAt = field.NewTime(table, "updated_at") p.DeletedAt = field.NewField(table, "deleted_at") p.fillFieldMap() return p } func (p *pointRecord) WithContext(ctx context.Context) *pointRecordDo { return p.pointRecordDo.WithContext(ctx) } func (p pointRecord) TableName() string { return p.pointRecordDo.TableName() } func (p pointRecord) Alias() string { return p.pointRecordDo.Alias() } func (p pointRecord) Columns(cols ...field.Expr) gen.Columns { return p.pointRecordDo.Columns(cols...) } func (p *pointRecord) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := p.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (p *pointRecord) fillFieldMap() { p.fieldMap = make(map[string]field.Expr, 8) p.fieldMap["id"] = p.ID p.fieldMap["sn"] = p.Sn p.fieldMap["user_sn"] = p.UserSn p.fieldMap["source"] = p.Source p.fieldMap["point"] = p.Point p.fieldMap["created_at"] = p.CreatedAt p.fieldMap["updated_at"] = p.UpdatedAt p.fieldMap["deleted_at"] = p.DeletedAt } func (p pointRecord) clone(db *gorm.DB) pointRecord { p.pointRecordDo.ReplaceConnPool(db.Statement.ConnPool) return p } func (p pointRecord) replaceDB(db *gorm.DB) pointRecord { p.pointRecordDo.ReplaceDB(db) return p } type pointRecordDo struct{ gen.DO } func (p pointRecordDo) Debug() *pointRecordDo { return p.withDO(p.DO.Debug()) } func (p pointRecordDo) WithContext(ctx context.Context) *pointRecordDo { return p.withDO(p.DO.WithContext(ctx)) } func (p pointRecordDo) ReadDB() *pointRecordDo { return p.Clauses(dbresolver.Read) } func (p pointRecordDo) WriteDB() *pointRecordDo { return p.Clauses(dbresolver.Write) } func (p pointRecordDo) Session(config *gorm.Session) *pointRecordDo { return p.withDO(p.DO.Session(config)) } func (p pointRecordDo) Clauses(conds ...clause.Expression) *pointRecordDo { return p.withDO(p.DO.Clauses(conds...)) } func (p pointRecordDo) Returning(value interface{}, columns ...string) *pointRecordDo { return p.withDO(p.DO.Returning(value, columns...)) } func (p pointRecordDo) Not(conds ...gen.Condition) *pointRecordDo { return p.withDO(p.DO.Not(conds...)) } func (p pointRecordDo) Or(conds ...gen.Condition) *pointRecordDo { return p.withDO(p.DO.Or(conds...)) } func (p pointRecordDo) Select(conds ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Select(conds...)) } func (p pointRecordDo) Where(conds ...gen.Condition) *pointRecordDo { return p.withDO(p.DO.Where(conds...)) } func (p pointRecordDo) Order(conds ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Order(conds...)) } func (p pointRecordDo) Distinct(cols ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Distinct(cols...)) } func (p pointRecordDo) Omit(cols ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Omit(cols...)) } func (p pointRecordDo) Join(table schema.Tabler, on ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Join(table, on...)) } func (p pointRecordDo) LeftJoin(table schema.Tabler, on ...field.Expr) *pointRecordDo { return p.withDO(p.DO.LeftJoin(table, on...)) } func (p pointRecordDo) RightJoin(table schema.Tabler, on ...field.Expr) *pointRecordDo { return p.withDO(p.DO.RightJoin(table, on...)) } func (p pointRecordDo) Group(cols ...field.Expr) *pointRecordDo { return p.withDO(p.DO.Group(cols...)) } func (p pointRecordDo) Having(conds ...gen.Condition) *pointRecordDo { return p.withDO(p.DO.Having(conds...)) } func (p pointRecordDo) Limit(limit int) *pointRecordDo { return p.withDO(p.DO.Limit(limit)) } func (p pointRecordDo) Offset(offset int) *pointRecordDo { return p.withDO(p.DO.Offset(offset)) } func (p pointRecordDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *pointRecordDo { return p.withDO(p.DO.Scopes(funcs...)) } func (p pointRecordDo) Unscoped() *pointRecordDo { return p.withDO(p.DO.Unscoped()) } func (p pointRecordDo) Create(values ...*model.PointRecord) error { if len(values) == 0 { return nil } return p.DO.Create(values) } func (p pointRecordDo) CreateInBatches(values []*model.PointRecord, batchSize int) error { return p.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 (p pointRecordDo) Save(values ...*model.PointRecord) error { if len(values) == 0 { return nil } return p.DO.Save(values) } func (p pointRecordDo) First() (*model.PointRecord, error) { if result, err := p.DO.First(); err != nil { return nil, err } else { return result.(*model.PointRecord), nil } } func (p pointRecordDo) Take() (*model.PointRecord, error) { if result, err := p.DO.Take(); err != nil { return nil, err } else { return result.(*model.PointRecord), nil } } func (p pointRecordDo) Last() (*model.PointRecord, error) { if result, err := p.DO.Last(); err != nil { return nil, err } else { return result.(*model.PointRecord), nil } } func (p pointRecordDo) Find() ([]*model.PointRecord, error) { result, err := p.DO.Find() return result.([]*model.PointRecord), err } func (p pointRecordDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PointRecord, err error) { buf := make([]*model.PointRecord, 0, batchSize) err = p.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 (p pointRecordDo) FindInBatches(result *[]*model.PointRecord, batchSize int, fc func(tx gen.Dao, batch int) error) error { return p.DO.FindInBatches(result, batchSize, fc) } func (p pointRecordDo) Attrs(attrs ...field.AssignExpr) *pointRecordDo { return p.withDO(p.DO.Attrs(attrs...)) } func (p pointRecordDo) Assign(attrs ...field.AssignExpr) *pointRecordDo { return p.withDO(p.DO.Assign(attrs...)) } func (p pointRecordDo) Joins(fields ...field.RelationField) *pointRecordDo { for _, _f := range fields { p = *p.withDO(p.DO.Joins(_f)) } return &p } func (p pointRecordDo) Preload(fields ...field.RelationField) *pointRecordDo { for _, _f := range fields { p = *p.withDO(p.DO.Preload(_f)) } return &p } func (p pointRecordDo) FirstOrInit() (*model.PointRecord, error) { if result, err := p.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.PointRecord), nil } } func (p pointRecordDo) FirstOrCreate() (*model.PointRecord, error) { if result, err := p.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.PointRecord), nil } } func (p pointRecordDo) FindByPage(offset int, limit int) (result []*model.PointRecord, count int64, err error) { result, err = p.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 = p.Offset(-1).Limit(-1).Count() return } func (p pointRecordDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = p.Count() if err != nil { return } err = p.Offset(offset).Limit(limit).Scan(result) return } func (p pointRecordDo) Scan(result interface{}) (err error) { return p.DO.Scan(result) } func (p pointRecordDo) Delete(models ...*model.PointRecord) (result gen.ResultInfo, err error) { return p.DO.Delete(models) } func (p *pointRecordDo) withDO(do gen.Dao) *pointRecordDo { p.DO = *do.(*gen.DO) return p }