123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- // 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
- }
|