You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

396 lines
12 KiB

// 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"
"github.com/TremblingV5/DouTok/applications/relation/dal/model"
)
func newFollowCount(db *gorm.DB, opts ...gen.DOOption) followCount {
_followCount := followCount{}
_followCount.followCountDo.UseDB(db, opts...)
_followCount.followCountDo.UseModel(&model.FollowCount{})
tableName := _followCount.followCountDo.TableName()
_followCount.ALL = field.NewAsterisk(tableName)
_followCount.UserId = field.NewInt64(tableName, "user_id")
_followCount.Number = field.NewInt64(tableName, "number")
_followCount.CreatedAt = field.NewTime(tableName, "created_at")
_followCount.UpdatedAt = field.NewTime(tableName, "updated_at")
_followCount.fillFieldMap()
return _followCount
}
type followCount struct {
followCountDo
ALL field.Asterisk
UserId field.Int64
Number field.Int64
CreatedAt field.Time
UpdatedAt field.Time
fieldMap map[string]field.Expr
}
func (f followCount) Table(newTableName string) *followCount {
f.followCountDo.UseTable(newTableName)
return f.updateTableName(newTableName)
}
func (f followCount) As(alias string) *followCount {
f.followCountDo.DO = *(f.followCountDo.As(alias).(*gen.DO))
return f.updateTableName(alias)
}
func (f *followCount) updateTableName(table string) *followCount {
f.ALL = field.NewAsterisk(table)
f.UserId = field.NewInt64(table, "user_id")
f.Number = field.NewInt64(table, "number")
f.CreatedAt = field.NewTime(table, "created_at")
f.UpdatedAt = field.NewTime(table, "updated_at")
f.fillFieldMap()
return f
}
func (f *followCount) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := f.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (f *followCount) fillFieldMap() {
f.fieldMap = make(map[string]field.Expr, 4)
f.fieldMap["user_id"] = f.UserId
f.fieldMap["number"] = f.Number
f.fieldMap["created_at"] = f.CreatedAt
f.fieldMap["updated_at"] = f.UpdatedAt
}
func (f followCount) clone(db *gorm.DB) followCount {
f.followCountDo.ReplaceConnPool(db.Statement.ConnPool)
return f
}
func (f followCount) replaceDB(db *gorm.DB) followCount {
f.followCountDo.ReplaceDB(db)
return f
}
type followCountDo struct{ gen.DO }
type IFollowCountDo interface {
gen.SubQuery
Debug() IFollowCountDo
WithContext(ctx context.Context) IFollowCountDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IFollowCountDo
WriteDB() IFollowCountDo
As(alias string) gen.Dao
Session(config *gorm.Session) IFollowCountDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IFollowCountDo
Not(conds ...gen.Condition) IFollowCountDo
Or(conds ...gen.Condition) IFollowCountDo
Select(conds ...field.Expr) IFollowCountDo
Where(conds ...gen.Condition) IFollowCountDo
Order(conds ...field.Expr) IFollowCountDo
Distinct(cols ...field.Expr) IFollowCountDo
Omit(cols ...field.Expr) IFollowCountDo
Join(table schema.Tabler, on ...field.Expr) IFollowCountDo
LeftJoin(table schema.Tabler, on ...field.Expr) IFollowCountDo
RightJoin(table schema.Tabler, on ...field.Expr) IFollowCountDo
Group(cols ...field.Expr) IFollowCountDo
Having(conds ...gen.Condition) IFollowCountDo
Limit(limit int) IFollowCountDo
Offset(offset int) IFollowCountDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IFollowCountDo
Unscoped() IFollowCountDo
Create(values ...*model.FollowCount) error
CreateInBatches(values []*model.FollowCount, batchSize int) error
Save(values ...*model.FollowCount) error
First() (*model.FollowCount, error)
Take() (*model.FollowCount, error)
Last() (*model.FollowCount, error)
Find() ([]*model.FollowCount, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FollowCount, err error)
FindInBatches(result *[]*model.FollowCount, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.FollowCount) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IFollowCountDo
Assign(attrs ...field.AssignExpr) IFollowCountDo
Joins(fields ...field.RelationField) IFollowCountDo
Preload(fields ...field.RelationField) IFollowCountDo
FirstOrInit() (*model.FollowCount, error)
FirstOrCreate() (*model.FollowCount, error)
FindByPage(offset int, limit int) (result []*model.FollowCount, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IFollowCountDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (f followCountDo) Debug() IFollowCountDo {
return f.withDO(f.DO.Debug())
}
func (f followCountDo) WithContext(ctx context.Context) IFollowCountDo {
return f.withDO(f.DO.WithContext(ctx))
}
func (f followCountDo) ReadDB() IFollowCountDo {
return f.Clauses(dbresolver.Read)
}
func (f followCountDo) WriteDB() IFollowCountDo {
return f.Clauses(dbresolver.Write)
}
func (f followCountDo) Session(config *gorm.Session) IFollowCountDo {
return f.withDO(f.DO.Session(config))
}
func (f followCountDo) Clauses(conds ...clause.Expression) IFollowCountDo {
return f.withDO(f.DO.Clauses(conds...))
}
func (f followCountDo) Returning(value interface{}, columns ...string) IFollowCountDo {
return f.withDO(f.DO.Returning(value, columns...))
}
func (f followCountDo) Not(conds ...gen.Condition) IFollowCountDo {
return f.withDO(f.DO.Not(conds...))
}
func (f followCountDo) Or(conds ...gen.Condition) IFollowCountDo {
return f.withDO(f.DO.Or(conds...))
}
func (f followCountDo) Select(conds ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Select(conds...))
}
func (f followCountDo) Where(conds ...gen.Condition) IFollowCountDo {
return f.withDO(f.DO.Where(conds...))
}
func (f followCountDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IFollowCountDo {
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (f followCountDo) Order(conds ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Order(conds...))
}
func (f followCountDo) Distinct(cols ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Distinct(cols...))
}
func (f followCountDo) Omit(cols ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Omit(cols...))
}
func (f followCountDo) Join(table schema.Tabler, on ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Join(table, on...))
}
func (f followCountDo) LeftJoin(table schema.Tabler, on ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.LeftJoin(table, on...))
}
func (f followCountDo) RightJoin(table schema.Tabler, on ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.RightJoin(table, on...))
}
func (f followCountDo) Group(cols ...field.Expr) IFollowCountDo {
return f.withDO(f.DO.Group(cols...))
}
func (f followCountDo) Having(conds ...gen.Condition) IFollowCountDo {
return f.withDO(f.DO.Having(conds...))
}
func (f followCountDo) Limit(limit int) IFollowCountDo {
return f.withDO(f.DO.Limit(limit))
}
func (f followCountDo) Offset(offset int) IFollowCountDo {
return f.withDO(f.DO.Offset(offset))
}
func (f followCountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IFollowCountDo {
return f.withDO(f.DO.Scopes(funcs...))
}
func (f followCountDo) Unscoped() IFollowCountDo {
return f.withDO(f.DO.Unscoped())
}
func (f followCountDo) Create(values ...*model.FollowCount) error {
if len(values) == 0 {
return nil
}
return f.DO.Create(values)
}
func (f followCountDo) CreateInBatches(values []*model.FollowCount, batchSize int) error {
return f.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 (f followCountDo) Save(values ...*model.FollowCount) error {
if len(values) == 0 {
return nil
}
return f.DO.Save(values)
}
func (f followCountDo) First() (*model.FollowCount, error) {
if result, err := f.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.FollowCount), nil
}
}
func (f followCountDo) Take() (*model.FollowCount, error) {
if result, err := f.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.FollowCount), nil
}
}
func (f followCountDo) Last() (*model.FollowCount, error) {
if result, err := f.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.FollowCount), nil
}
}
func (f followCountDo) Find() ([]*model.FollowCount, error) {
result, err := f.DO.Find()
return result.([]*model.FollowCount), err
}
func (f followCountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FollowCount, err error) {
buf := make([]*model.FollowCount, 0, batchSize)
err = f.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 (f followCountDo) FindInBatches(result *[]*model.FollowCount, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return f.DO.FindInBatches(result, batchSize, fc)
}
func (f followCountDo) Attrs(attrs ...field.AssignExpr) IFollowCountDo {
return f.withDO(f.DO.Attrs(attrs...))
}
func (f followCountDo) Assign(attrs ...field.AssignExpr) IFollowCountDo {
return f.withDO(f.DO.Assign(attrs...))
}
func (f followCountDo) Joins(fields ...field.RelationField) IFollowCountDo {
for _, _f := range fields {
f = *f.withDO(f.DO.Joins(_f))
}
return &f
}
func (f followCountDo) Preload(fields ...field.RelationField) IFollowCountDo {
for _, _f := range fields {
f = *f.withDO(f.DO.Preload(_f))
}
return &f
}
func (f followCountDo) FirstOrInit() (*model.FollowCount, error) {
if result, err := f.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.FollowCount), nil
}
}
func (f followCountDo) FirstOrCreate() (*model.FollowCount, error) {
if result, err := f.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.FollowCount), nil
}
}
func (f followCountDo) FindByPage(offset int, limit int) (result []*model.FollowCount, count int64, err error) {
result, err = f.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 = f.Offset(-1).Limit(-1).Count()
return
}
func (f followCountDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = f.Count()
if err != nil {
return
}
err = f.Offset(offset).Limit(limit).Scan(result)
return
}
func (f followCountDo) Scan(result interface{}) (err error) {
return f.DO.Scan(result)
}
func (f followCountDo) Delete(models ...*model.FollowCount) (result gen.ResultInfo, err error) {
return f.DO.Delete(models)
}
func (f *followCountDo) withDO(do gen.Dao) *followCountDo {
f.DO = *do.(*gen.DO)
return f
}