344 lines
9.6 KiB
Go
344 lines
9.6 KiB
Go
// 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"
|
|
|
|
"youtu_ecpm/dao/model"
|
|
)
|
|
|
|
func newDouyinEcpmConfig(db *gorm.DB, opts ...gen.DOOption) douyinEcpmConfig {
|
|
_douyinEcpmConfig := douyinEcpmConfig{}
|
|
|
|
_douyinEcpmConfig.douyinEcpmConfigDo.UseDB(db, opts...)
|
|
_douyinEcpmConfig.douyinEcpmConfigDo.UseModel(&model.DouyinEcpmConfig{})
|
|
|
|
tableName := _douyinEcpmConfig.douyinEcpmConfigDo.TableName()
|
|
_douyinEcpmConfig.ALL = field.NewAsterisk(tableName)
|
|
_douyinEcpmConfig.ID = field.NewUint32(tableName, "id")
|
|
_douyinEcpmConfig.AppAccountID = field.NewUint32(tableName, "app_account_id")
|
|
_douyinEcpmConfig.EcpmValue = field.NewUint32(tableName, "ecpm_value")
|
|
_douyinEcpmConfig.EcpmView = field.NewUint32(tableName, "ecpm_view")
|
|
|
|
_douyinEcpmConfig.fillFieldMap()
|
|
|
|
return _douyinEcpmConfig
|
|
}
|
|
|
|
type douyinEcpmConfig struct {
|
|
douyinEcpmConfigDo douyinEcpmConfigDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Uint32
|
|
AppAccountID field.Uint32
|
|
EcpmValue field.Uint32 // 值
|
|
EcpmView field.Uint32 // 浏览次数
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (d douyinEcpmConfig) Table(newTableName string) *douyinEcpmConfig {
|
|
d.douyinEcpmConfigDo.UseTable(newTableName)
|
|
return d.updateTableName(newTableName)
|
|
}
|
|
|
|
func (d douyinEcpmConfig) As(alias string) *douyinEcpmConfig {
|
|
d.douyinEcpmConfigDo.DO = *(d.douyinEcpmConfigDo.As(alias).(*gen.DO))
|
|
return d.updateTableName(alias)
|
|
}
|
|
|
|
func (d *douyinEcpmConfig) updateTableName(table string) *douyinEcpmConfig {
|
|
d.ALL = field.NewAsterisk(table)
|
|
d.ID = field.NewUint32(table, "id")
|
|
d.AppAccountID = field.NewUint32(table, "app_account_id")
|
|
d.EcpmValue = field.NewUint32(table, "ecpm_value")
|
|
d.EcpmView = field.NewUint32(table, "ecpm_view")
|
|
|
|
d.fillFieldMap()
|
|
|
|
return d
|
|
}
|
|
|
|
func (d *douyinEcpmConfig) WithContext(ctx context.Context) *douyinEcpmConfigDo {
|
|
return d.douyinEcpmConfigDo.WithContext(ctx)
|
|
}
|
|
|
|
func (d douyinEcpmConfig) TableName() string { return d.douyinEcpmConfigDo.TableName() }
|
|
|
|
func (d douyinEcpmConfig) Alias() string { return d.douyinEcpmConfigDo.Alias() }
|
|
|
|
func (d douyinEcpmConfig) Columns(cols ...field.Expr) gen.Columns {
|
|
return d.douyinEcpmConfigDo.Columns(cols...)
|
|
}
|
|
|
|
func (d *douyinEcpmConfig) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := d.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (d *douyinEcpmConfig) fillFieldMap() {
|
|
d.fieldMap = make(map[string]field.Expr, 4)
|
|
d.fieldMap["id"] = d.ID
|
|
d.fieldMap["app_account_id"] = d.AppAccountID
|
|
d.fieldMap["ecpm_value"] = d.EcpmValue
|
|
d.fieldMap["ecpm_view"] = d.EcpmView
|
|
}
|
|
|
|
func (d douyinEcpmConfig) clone(db *gorm.DB) douyinEcpmConfig {
|
|
d.douyinEcpmConfigDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return d
|
|
}
|
|
|
|
func (d douyinEcpmConfig) replaceDB(db *gorm.DB) douyinEcpmConfig {
|
|
d.douyinEcpmConfigDo.ReplaceDB(db)
|
|
return d
|
|
}
|
|
|
|
type douyinEcpmConfigDo struct{ gen.DO }
|
|
|
|
func (d douyinEcpmConfigDo) Debug() *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Debug())
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) WithContext(ctx context.Context) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) ReadDB() *douyinEcpmConfigDo {
|
|
return d.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) WriteDB() *douyinEcpmConfigDo {
|
|
return d.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Session(config *gorm.Session) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Session(config))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Clauses(conds ...clause.Expression) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Returning(value interface{}, columns ...string) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Not(conds ...gen.Condition) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Not(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Or(conds ...gen.Condition) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Or(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Select(conds ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Select(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Where(conds ...gen.Condition) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Where(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Order(conds ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Order(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Distinct(cols ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Omit(cols ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Omit(cols...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Join(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Join(table, on...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Group(cols ...field.Expr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Group(cols...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Having(conds ...gen.Condition) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Having(conds...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Limit(limit int) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Limit(limit))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Offset(offset int) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Offset(offset))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Unscoped() *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Unscoped())
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Create(values ...*model.DouyinEcpmConfig) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return d.DO.Create(values)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) CreateInBatches(values []*model.DouyinEcpmConfig, batchSize int) error {
|
|
return d.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 (d douyinEcpmConfigDo) Save(values ...*model.DouyinEcpmConfig) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return d.DO.Save(values)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) First() (*model.DouyinEcpmConfig, error) {
|
|
if result, err := d.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.DouyinEcpmConfig), nil
|
|
}
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Take() (*model.DouyinEcpmConfig, error) {
|
|
if result, err := d.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.DouyinEcpmConfig), nil
|
|
}
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Last() (*model.DouyinEcpmConfig, error) {
|
|
if result, err := d.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.DouyinEcpmConfig), nil
|
|
}
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Find() ([]*model.DouyinEcpmConfig, error) {
|
|
result, err := d.DO.Find()
|
|
return result.([]*model.DouyinEcpmConfig), err
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DouyinEcpmConfig, err error) {
|
|
buf := make([]*model.DouyinEcpmConfig, 0, batchSize)
|
|
err = d.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 (d douyinEcpmConfigDo) FindInBatches(result *[]*model.DouyinEcpmConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return d.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Attrs(attrs ...field.AssignExpr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Assign(attrs ...field.AssignExpr) *douyinEcpmConfigDo {
|
|
return d.withDO(d.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Joins(fields ...field.RelationField) *douyinEcpmConfigDo {
|
|
for _, _f := range fields {
|
|
d = *d.withDO(d.DO.Joins(_f))
|
|
}
|
|
return &d
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Preload(fields ...field.RelationField) *douyinEcpmConfigDo {
|
|
for _, _f := range fields {
|
|
d = *d.withDO(d.DO.Preload(_f))
|
|
}
|
|
return &d
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) FirstOrInit() (*model.DouyinEcpmConfig, error) {
|
|
if result, err := d.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.DouyinEcpmConfig), nil
|
|
}
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) FirstOrCreate() (*model.DouyinEcpmConfig, error) {
|
|
if result, err := d.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.DouyinEcpmConfig), nil
|
|
}
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) FindByPage(offset int, limit int) (result []*model.DouyinEcpmConfig, count int64, err error) {
|
|
result, err = d.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 = d.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = d.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = d.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Scan(result interface{}) (err error) {
|
|
return d.DO.Scan(result)
|
|
}
|
|
|
|
func (d douyinEcpmConfigDo) Delete(models ...*model.DouyinEcpmConfig) (result gen.ResultInfo, err error) {
|
|
return d.DO.Delete(models)
|
|
}
|
|
|
|
func (d *douyinEcpmConfigDo) withDO(do gen.Dao) *douyinEcpmConfigDo {
|
|
d.DO = *do.(*gen.DO)
|
|
return d
|
|
}
|