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