// 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 newChangedStatistic(db *gorm.DB, opts ...gen.DOOption) changedStatistic { _changedStatistic := changedStatistic{} _changedStatistic.changedStatisticDo.UseDB(db, opts...) _changedStatistic.changedStatisticDo.UseModel(&model.ChangedStatistic{}) tableName := _changedStatistic.changedStatisticDo.TableName() _changedStatistic.ALL = field.NewAsterisk(tableName) _changedStatistic.ID = field.NewInt64(tableName, "id") _changedStatistic.ChannelID = field.NewString(tableName, "channel_id") _changedStatistic.ServerID = field.NewInt32(tableName, "server_id") _changedStatistic.Type = field.NewInt32(tableName, "type") _changedStatistic.Source = field.NewInt32(tableName, "source") _changedStatistic.Amount = field.NewInt64(tableName, "amount") _changedStatistic.Players = field.NewString(tableName, "players") _changedStatistic.Counts = field.NewInt64(tableName, "counts") _changedStatistic.Date = field.NewString(tableName, "date") _changedStatistic.fillFieldMap() return _changedStatistic } type changedStatistic struct { changedStatisticDo ALL field.Asterisk ID field.Int64 ChannelID field.String // 渠道ID ServerID field.Int32 // 服务器ID Type field.Int32 // 消费类型 Source field.Int32 // 消费来源 Amount field.Int64 // 消费金额 Players field.String // 消费玩家ID集合 Counts field.Int64 // 消费次数 Date field.String // 日期 fieldMap map[string]field.Expr } func (c changedStatistic) Table(newTableName string) *changedStatistic { c.changedStatisticDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c changedStatistic) As(alias string) *changedStatistic { c.changedStatisticDo.DO = *(c.changedStatisticDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *changedStatistic) updateTableName(table string) *changedStatistic { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt64(table, "id") c.ChannelID = field.NewString(table, "channel_id") c.ServerID = field.NewInt32(table, "server_id") c.Type = field.NewInt32(table, "type") c.Source = field.NewInt32(table, "source") c.Amount = field.NewInt64(table, "amount") c.Players = field.NewString(table, "players") c.Counts = field.NewInt64(table, "counts") c.Date = field.NewString(table, "date") c.fillFieldMap() return c } func (c *changedStatistic) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (c *changedStatistic) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 9) c.fieldMap["id"] = c.ID c.fieldMap["channel_id"] = c.ChannelID c.fieldMap["server_id"] = c.ServerID c.fieldMap["type"] = c.Type c.fieldMap["source"] = c.Source c.fieldMap["amount"] = c.Amount c.fieldMap["players"] = c.Players c.fieldMap["counts"] = c.Counts c.fieldMap["date"] = c.Date } func (c changedStatistic) clone(db *gorm.DB) changedStatistic { c.changedStatisticDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c changedStatistic) replaceDB(db *gorm.DB) changedStatistic { c.changedStatisticDo.ReplaceDB(db) return c } type changedStatisticDo struct{ gen.DO } func (c changedStatisticDo) Debug() *changedStatisticDo { return c.withDO(c.DO.Debug()) } func (c changedStatisticDo) WithContext(ctx context.Context) *changedStatisticDo { return c.withDO(c.DO.WithContext(ctx)) } func (c changedStatisticDo) ReadDB() *changedStatisticDo { return c.Clauses(dbresolver.Read) } func (c changedStatisticDo) WriteDB() *changedStatisticDo { return c.Clauses(dbresolver.Write) } func (c changedStatisticDo) Session(config *gorm.Session) *changedStatisticDo { return c.withDO(c.DO.Session(config)) } func (c changedStatisticDo) Clauses(conds ...clause.Expression) *changedStatisticDo { return c.withDO(c.DO.Clauses(conds...)) } func (c changedStatisticDo) Returning(value interface{}, columns ...string) *changedStatisticDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c changedStatisticDo) Not(conds ...gen.Condition) *changedStatisticDo { return c.withDO(c.DO.Not(conds...)) } func (c changedStatisticDo) Or(conds ...gen.Condition) *changedStatisticDo { return c.withDO(c.DO.Or(conds...)) } func (c changedStatisticDo) Select(conds ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Select(conds...)) } func (c changedStatisticDo) Where(conds ...gen.Condition) *changedStatisticDo { return c.withDO(c.DO.Where(conds...)) } func (c changedStatisticDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *changedStatisticDo { return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (c changedStatisticDo) Order(conds ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Order(conds...)) } func (c changedStatisticDo) Distinct(cols ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Distinct(cols...)) } func (c changedStatisticDo) Omit(cols ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Omit(cols...)) } func (c changedStatisticDo) Join(table schema.Tabler, on ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Join(table, on...)) } func (c changedStatisticDo) LeftJoin(table schema.Tabler, on ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c changedStatisticDo) RightJoin(table schema.Tabler, on ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c changedStatisticDo) Group(cols ...field.Expr) *changedStatisticDo { return c.withDO(c.DO.Group(cols...)) } func (c changedStatisticDo) Having(conds ...gen.Condition) *changedStatisticDo { return c.withDO(c.DO.Having(conds...)) } func (c changedStatisticDo) Limit(limit int) *changedStatisticDo { return c.withDO(c.DO.Limit(limit)) } func (c changedStatisticDo) Offset(offset int) *changedStatisticDo { return c.withDO(c.DO.Offset(offset)) } func (c changedStatisticDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *changedStatisticDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c changedStatisticDo) Unscoped() *changedStatisticDo { return c.withDO(c.DO.Unscoped()) } func (c changedStatisticDo) Create(values ...*model.ChangedStatistic) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c changedStatisticDo) CreateInBatches(values []*model.ChangedStatistic, batchSize int) error { return c.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 (c changedStatisticDo) Save(values ...*model.ChangedStatistic) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c changedStatisticDo) First() (*model.ChangedStatistic, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.ChangedStatistic), nil } } func (c changedStatisticDo) Take() (*model.ChangedStatistic, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.ChangedStatistic), nil } } func (c changedStatisticDo) Last() (*model.ChangedStatistic, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.ChangedStatistic), nil } } func (c changedStatisticDo) Find() ([]*model.ChangedStatistic, error) { result, err := c.DO.Find() return result.([]*model.ChangedStatistic), err } func (c changedStatisticDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChangedStatistic, err error) { buf := make([]*model.ChangedStatistic, 0, batchSize) err = c.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 (c changedStatisticDo) FindInBatches(result *[]*model.ChangedStatistic, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c changedStatisticDo) Attrs(attrs ...field.AssignExpr) *changedStatisticDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c changedStatisticDo) Assign(attrs ...field.AssignExpr) *changedStatisticDo { return c.withDO(c.DO.Assign(attrs...)) } func (c changedStatisticDo) Joins(fields ...field.RelationField) *changedStatisticDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c changedStatisticDo) Preload(fields ...field.RelationField) *changedStatisticDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c changedStatisticDo) FirstOrInit() (*model.ChangedStatistic, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.ChangedStatistic), nil } } func (c changedStatisticDo) FirstOrCreate() (*model.ChangedStatistic, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.ChangedStatistic), nil } } func (c changedStatisticDo) FindByPage(offset int, limit int) (result []*model.ChangedStatistic, count int64, err error) { result, err = c.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 = c.Offset(-1).Limit(-1).Count() return } func (c changedStatisticDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = c.Count() if err != nil { return } err = c.Offset(offset).Limit(limit).Scan(result) return } func (c changedStatisticDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c changedStatisticDo) Delete(models ...*model.ChangedStatistic) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *changedStatisticDo) withDO(do gen.Dao) *changedStatisticDo { c.DO = *do.(*gen.DO) return c }