// 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 newReportDayGudong(db *gorm.DB, opts ...gen.DOOption) reportDayGudong {
	_reportDayGudong := reportDayGudong{}

	_reportDayGudong.reportDayGudongDo.UseDB(db, opts...)
	_reportDayGudong.reportDayGudongDo.UseModel(&model.ReportDayGudong{})

	tableName := _reportDayGudong.reportDayGudongDo.TableName()
	_reportDayGudong.ALL = field.NewAsterisk(tableName)
	_reportDayGudong.ID = field.NewInt64(tableName, "id")
	_reportDayGudong.Date = field.NewString(tableName, "date")
	_reportDayGudong.ChannelID = field.NewString(tableName, "channel_id")
	_reportDayGudong.ServerID = field.NewInt32(tableName, "server_id")
	_reportDayGudong.PlayerCount = field.NewInt64(tableName, "player_count")
	_reportDayGudong.JingliCount = field.NewInt64(tableName, "jingli_count")
	_reportDayGudong.AdJingli = field.NewInt64(tableName, "ad_jingli")
	_reportDayGudong.DiamondJingli = field.NewInt64(tableName, "diamond_jingli")
	_reportDayGudong.AdDiamond = field.NewInt64(tableName, "ad_diamond")
	_reportDayGudong.RmbDiamond = field.NewInt64(tableName, "rmb_diamond")
	_reportDayGudong.SpeedUpBox = field.NewInt64(tableName, "speed_up_box")
	_reportDayGudong.SpeedUpBoxDetail = field.NewString(tableName, "speed_up_box_detail")
	_reportDayGudong.IdentifyGoods = field.NewInt64(tableName, "identify_goods")
	_reportDayGudong.UpgradeGoods = field.NewInt64(tableName, "upgrade_goods")
	_reportDayGudong.ShowRevenue = field.NewInt64(tableName, "show_revenue")
	_reportDayGudong.Ranking = field.NewInt64(tableName, "ranking")
	_reportDayGudong.RankingBenifit = field.NewInt64(tableName, "ranking_benifit")
	_reportDayGudong.ExchangeGoods = field.NewString(tableName, "exchange_goods")
	_reportDayGudong.SellGoods = field.NewInt64(tableName, "sell_goods")
	_reportDayGudong.GetGoods = field.NewInt64(tableName, "get_goods")
	_reportDayGudong.GetGoodsDetail = field.NewString(tableName, "get_goods_detail")

	_reportDayGudong.fillFieldMap()

	return _reportDayGudong
}

type reportDayGudong struct {
	reportDayGudongDo

	ALL              field.Asterisk
	ID               field.Int64
	Date             field.String
	ChannelID        field.String // 渠道ID
	ServerID         field.Int32  // 服务器ID
	PlayerCount      field.Int64  // 参与人数
	JingliCount      field.Int64  // 消耗精力数
	AdJingli         field.Int64  // 看广告获取精力次数
	DiamondJingli    field.Int64  // 钻石获取精力次数
	AdDiamond        field.Int64  // 人民币获取精力次数
	RmbDiamond       field.Int64  // 人民币获取精力次数
	SpeedUpBox       field.Int64  // 加速宝箱次数
	SpeedUpBoxDetail field.String // 加速宝箱明细（宝箱类型，次数）
	IdentifyGoods    field.Int64  // 古玩鉴定次数
	UpgradeGoods     field.Int64  // 古玩升级次数
	ShowRevenue      field.Int64  // 展览收益
	Ranking          field.Int64  // 排行榜
	RankingBenifit   field.Int64  // 排行榜奖励
	ExchangeGoods    field.String // 物品兑换
	SellGoods        field.Int64  // 出售物品
	GetGoods         field.Int64  // 获取物品
	GetGoodsDetail   field.String // 获取物品

	fieldMap map[string]field.Expr
}

func (r reportDayGudong) Table(newTableName string) *reportDayGudong {
	r.reportDayGudongDo.UseTable(newTableName)
	return r.updateTableName(newTableName)
}

func (r reportDayGudong) As(alias string) *reportDayGudong {
	r.reportDayGudongDo.DO = *(r.reportDayGudongDo.As(alias).(*gen.DO))
	return r.updateTableName(alias)
}

func (r *reportDayGudong) updateTableName(table string) *reportDayGudong {
	r.ALL = field.NewAsterisk(table)
	r.ID = field.NewInt64(table, "id")
	r.Date = field.NewString(table, "date")
	r.ChannelID = field.NewString(table, "channel_id")
	r.ServerID = field.NewInt32(table, "server_id")
	r.PlayerCount = field.NewInt64(table, "player_count")
	r.JingliCount = field.NewInt64(table, "jingli_count")
	r.AdJingli = field.NewInt64(table, "ad_jingli")
	r.DiamondJingli = field.NewInt64(table, "diamond_jingli")
	r.AdDiamond = field.NewInt64(table, "ad_diamond")
	r.RmbDiamond = field.NewInt64(table, "rmb_diamond")
	r.SpeedUpBox = field.NewInt64(table, "speed_up_box")
	r.SpeedUpBoxDetail = field.NewString(table, "speed_up_box_detail")
	r.IdentifyGoods = field.NewInt64(table, "identify_goods")
	r.UpgradeGoods = field.NewInt64(table, "upgrade_goods")
	r.ShowRevenue = field.NewInt64(table, "show_revenue")
	r.Ranking = field.NewInt64(table, "ranking")
	r.RankingBenifit = field.NewInt64(table, "ranking_benifit")
	r.ExchangeGoods = field.NewString(table, "exchange_goods")
	r.SellGoods = field.NewInt64(table, "sell_goods")
	r.GetGoods = field.NewInt64(table, "get_goods")
	r.GetGoodsDetail = field.NewString(table, "get_goods_detail")

	r.fillFieldMap()

	return r
}

func (r *reportDayGudong) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
	_f, ok := r.fieldMap[fieldName]
	if !ok || _f == nil {
		return nil, false
	}
	_oe, ok := _f.(field.OrderExpr)
	return _oe, ok
}

func (r *reportDayGudong) fillFieldMap() {
	r.fieldMap = make(map[string]field.Expr, 21)
	r.fieldMap["id"] = r.ID
	r.fieldMap["date"] = r.Date
	r.fieldMap["channel_id"] = r.ChannelID
	r.fieldMap["server_id"] = r.ServerID
	r.fieldMap["player_count"] = r.PlayerCount
	r.fieldMap["jingli_count"] = r.JingliCount
	r.fieldMap["ad_jingli"] = r.AdJingli
	r.fieldMap["diamond_jingli"] = r.DiamondJingli
	r.fieldMap["ad_diamond"] = r.AdDiamond
	r.fieldMap["rmb_diamond"] = r.RmbDiamond
	r.fieldMap["speed_up_box"] = r.SpeedUpBox
	r.fieldMap["speed_up_box_detail"] = r.SpeedUpBoxDetail
	r.fieldMap["identify_goods"] = r.IdentifyGoods
	r.fieldMap["upgrade_goods"] = r.UpgradeGoods
	r.fieldMap["show_revenue"] = r.ShowRevenue
	r.fieldMap["ranking"] = r.Ranking
	r.fieldMap["ranking_benifit"] = r.RankingBenifit
	r.fieldMap["exchange_goods"] = r.ExchangeGoods
	r.fieldMap["sell_goods"] = r.SellGoods
	r.fieldMap["get_goods"] = r.GetGoods
	r.fieldMap["get_goods_detail"] = r.GetGoodsDetail
}

func (r reportDayGudong) clone(db *gorm.DB) reportDayGudong {
	r.reportDayGudongDo.ReplaceConnPool(db.Statement.ConnPool)
	return r
}

func (r reportDayGudong) replaceDB(db *gorm.DB) reportDayGudong {
	r.reportDayGudongDo.ReplaceDB(db)
	return r
}

type reportDayGudongDo struct{ gen.DO }

func (r reportDayGudongDo) Debug() *reportDayGudongDo {
	return r.withDO(r.DO.Debug())
}

func (r reportDayGudongDo) WithContext(ctx context.Context) *reportDayGudongDo {
	return r.withDO(r.DO.WithContext(ctx))
}

func (r reportDayGudongDo) ReadDB() *reportDayGudongDo {
	return r.Clauses(dbresolver.Read)
}

func (r reportDayGudongDo) WriteDB() *reportDayGudongDo {
	return r.Clauses(dbresolver.Write)
}

func (r reportDayGudongDo) Session(config *gorm.Session) *reportDayGudongDo {
	return r.withDO(r.DO.Session(config))
}

func (r reportDayGudongDo) Clauses(conds ...clause.Expression) *reportDayGudongDo {
	return r.withDO(r.DO.Clauses(conds...))
}

func (r reportDayGudongDo) Returning(value interface{}, columns ...string) *reportDayGudongDo {
	return r.withDO(r.DO.Returning(value, columns...))
}

func (r reportDayGudongDo) Not(conds ...gen.Condition) *reportDayGudongDo {
	return r.withDO(r.DO.Not(conds...))
}

func (r reportDayGudongDo) Or(conds ...gen.Condition) *reportDayGudongDo {
	return r.withDO(r.DO.Or(conds...))
}

func (r reportDayGudongDo) Select(conds ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Select(conds...))
}

func (r reportDayGudongDo) Where(conds ...gen.Condition) *reportDayGudongDo {
	return r.withDO(r.DO.Where(conds...))
}

func (r reportDayGudongDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *reportDayGudongDo {
	return r.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}

func (r reportDayGudongDo) Order(conds ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Order(conds...))
}

func (r reportDayGudongDo) Distinct(cols ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Distinct(cols...))
}

func (r reportDayGudongDo) Omit(cols ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Omit(cols...))
}

func (r reportDayGudongDo) Join(table schema.Tabler, on ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Join(table, on...))
}

func (r reportDayGudongDo) LeftJoin(table schema.Tabler, on ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.LeftJoin(table, on...))
}

func (r reportDayGudongDo) RightJoin(table schema.Tabler, on ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.RightJoin(table, on...))
}

func (r reportDayGudongDo) Group(cols ...field.Expr) *reportDayGudongDo {
	return r.withDO(r.DO.Group(cols...))
}

func (r reportDayGudongDo) Having(conds ...gen.Condition) *reportDayGudongDo {
	return r.withDO(r.DO.Having(conds...))
}

func (r reportDayGudongDo) Limit(limit int) *reportDayGudongDo {
	return r.withDO(r.DO.Limit(limit))
}

func (r reportDayGudongDo) Offset(offset int) *reportDayGudongDo {
	return r.withDO(r.DO.Offset(offset))
}

func (r reportDayGudongDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *reportDayGudongDo {
	return r.withDO(r.DO.Scopes(funcs...))
}

func (r reportDayGudongDo) Unscoped() *reportDayGudongDo {
	return r.withDO(r.DO.Unscoped())
}

func (r reportDayGudongDo) Create(values ...*model.ReportDayGudong) error {
	if len(values) == 0 {
		return nil
	}
	return r.DO.Create(values)
}

func (r reportDayGudongDo) CreateInBatches(values []*model.ReportDayGudong, batchSize int) error {
	return r.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 (r reportDayGudongDo) Save(values ...*model.ReportDayGudong) error {
	if len(values) == 0 {
		return nil
	}
	return r.DO.Save(values)
}

func (r reportDayGudongDo) First() (*model.ReportDayGudong, error) {
	if result, err := r.DO.First(); err != nil {
		return nil, err
	} else {
		return result.(*model.ReportDayGudong), nil
	}
}

func (r reportDayGudongDo) Take() (*model.ReportDayGudong, error) {
	if result, err := r.DO.Take(); err != nil {
		return nil, err
	} else {
		return result.(*model.ReportDayGudong), nil
	}
}

func (r reportDayGudongDo) Last() (*model.ReportDayGudong, error) {
	if result, err := r.DO.Last(); err != nil {
		return nil, err
	} else {
		return result.(*model.ReportDayGudong), nil
	}
}

func (r reportDayGudongDo) Find() ([]*model.ReportDayGudong, error) {
	result, err := r.DO.Find()
	return result.([]*model.ReportDayGudong), err
}

func (r reportDayGudongDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ReportDayGudong, err error) {
	buf := make([]*model.ReportDayGudong, 0, batchSize)
	err = r.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 (r reportDayGudongDo) FindInBatches(result *[]*model.ReportDayGudong, batchSize int, fc func(tx gen.Dao, batch int) error) error {
	return r.DO.FindInBatches(result, batchSize, fc)
}

func (r reportDayGudongDo) Attrs(attrs ...field.AssignExpr) *reportDayGudongDo {
	return r.withDO(r.DO.Attrs(attrs...))
}

func (r reportDayGudongDo) Assign(attrs ...field.AssignExpr) *reportDayGudongDo {
	return r.withDO(r.DO.Assign(attrs...))
}

func (r reportDayGudongDo) Joins(fields ...field.RelationField) *reportDayGudongDo {
	for _, _f := range fields {
		r = *r.withDO(r.DO.Joins(_f))
	}
	return &r
}

func (r reportDayGudongDo) Preload(fields ...field.RelationField) *reportDayGudongDo {
	for _, _f := range fields {
		r = *r.withDO(r.DO.Preload(_f))
	}
	return &r
}

func (r reportDayGudongDo) FirstOrInit() (*model.ReportDayGudong, error) {
	if result, err := r.DO.FirstOrInit(); err != nil {
		return nil, err
	} else {
		return result.(*model.ReportDayGudong), nil
	}
}

func (r reportDayGudongDo) FirstOrCreate() (*model.ReportDayGudong, error) {
	if result, err := r.DO.FirstOrCreate(); err != nil {
		return nil, err
	} else {
		return result.(*model.ReportDayGudong), nil
	}
}

func (r reportDayGudongDo) FindByPage(offset int, limit int) (result []*model.ReportDayGudong, count int64, err error) {
	result, err = r.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 = r.Offset(-1).Limit(-1).Count()
	return
}

func (r reportDayGudongDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
	count, err = r.Count()
	if err != nil {
		return
	}

	err = r.Offset(offset).Limit(limit).Scan(result)
	return
}

func (r reportDayGudongDo) Scan(result interface{}) (err error) {
	return r.DO.Scan(result)
}

func (r reportDayGudongDo) Delete(models ...*model.ReportDayGudong) (result gen.ResultInfo, err error) {
	return r.DO.Delete(models)
}

func (r *reportDayGudongDo) withDO(do gen.Dao) *reportDayGudongDo {
	r.DO = *do.(*gen.DO)
	return r
}
