recommender/internal/dao/applications.gen.go

397 lines
12 KiB
Go
Raw Normal View History

2024-11-07 10:09:13 +00:00
// 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 dao
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"leafdev.top/Ecosystem/recommender/internal/entity"
)
func newApplication(db *gorm.DB, opts ...gen.DOOption) application {
_application := application{}
_application.applicationDo.UseDB(db, opts...)
_application.applicationDo.UseModel(&entity.Application{})
tableName := _application.applicationDo.TableName()
_application.ALL = field.NewAsterisk(tableName)
_application.Id = field.NewUint(tableName, "id")
_application.CreatedAt = field.NewTime(tableName, "created_at")
_application.UpdatedAt = field.NewTime(tableName, "updated_at")
_application.Name = field.NewString(tableName, "name")
_application.UserId = field.NewString(tableName, "user_id")
_application.fillFieldMap()
return _application
}
type application struct {
applicationDo
ALL field.Asterisk
Id field.Uint
CreatedAt field.Time
UpdatedAt field.Time
Name field.String
UserId field.String
fieldMap map[string]field.Expr
}
func (a application) Table(newTableName string) *application {
a.applicationDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a application) As(alias string) *application {
a.applicationDo.DO = *(a.applicationDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *application) updateTableName(table string) *application {
a.ALL = field.NewAsterisk(table)
a.Id = field.NewUint(table, "id")
a.CreatedAt = field.NewTime(table, "created_at")
a.UpdatedAt = field.NewTime(table, "updated_at")
a.Name = field.NewString(table, "name")
a.UserId = field.NewString(table, "user_id")
a.fillFieldMap()
return a
}
func (a *application) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *application) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 5)
a.fieldMap["id"] = a.Id
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["updated_at"] = a.UpdatedAt
a.fieldMap["name"] = a.Name
a.fieldMap["user_id"] = a.UserId
}
func (a application) clone(db *gorm.DB) application {
a.applicationDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a application) replaceDB(db *gorm.DB) application {
a.applicationDo.ReplaceDB(db)
return a
}
type applicationDo struct{ gen.DO }
type IApplicationDo interface {
gen.SubQuery
Debug() IApplicationDo
WithContext(ctx context.Context) IApplicationDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IApplicationDo
WriteDB() IApplicationDo
As(alias string) gen.Dao
Session(config *gorm.Session) IApplicationDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IApplicationDo
Not(conds ...gen.Condition) IApplicationDo
Or(conds ...gen.Condition) IApplicationDo
Select(conds ...field.Expr) IApplicationDo
Where(conds ...gen.Condition) IApplicationDo
Order(conds ...field.Expr) IApplicationDo
Distinct(cols ...field.Expr) IApplicationDo
Omit(cols ...field.Expr) IApplicationDo
Join(table schema.Tabler, on ...field.Expr) IApplicationDo
LeftJoin(table schema.Tabler, on ...field.Expr) IApplicationDo
RightJoin(table schema.Tabler, on ...field.Expr) IApplicationDo
Group(cols ...field.Expr) IApplicationDo
Having(conds ...gen.Condition) IApplicationDo
Limit(limit int) IApplicationDo
Offset(offset int) IApplicationDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IApplicationDo
Unscoped() IApplicationDo
Create(values ...*entity.Application) error
CreateInBatches(values []*entity.Application, batchSize int) error
Save(values ...*entity.Application) error
First() (*entity.Application, error)
Take() (*entity.Application, error)
Last() (*entity.Application, error)
Find() ([]*entity.Application, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Application, err error)
FindInBatches(result *[]*entity.Application, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*entity.Application) (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) IApplicationDo
Assign(attrs ...field.AssignExpr) IApplicationDo
Joins(fields ...field.RelationField) IApplicationDo
Preload(fields ...field.RelationField) IApplicationDo
FirstOrInit() (*entity.Application, error)
FirstOrCreate() (*entity.Application, error)
FindByPage(offset int, limit int) (result []*entity.Application, 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) IApplicationDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a applicationDo) Debug() IApplicationDo {
return a.withDO(a.DO.Debug())
}
func (a applicationDo) WithContext(ctx context.Context) IApplicationDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a applicationDo) ReadDB() IApplicationDo {
return a.Clauses(dbresolver.Read)
}
func (a applicationDo) WriteDB() IApplicationDo {
return a.Clauses(dbresolver.Write)
}
func (a applicationDo) Session(config *gorm.Session) IApplicationDo {
return a.withDO(a.DO.Session(config))
}
func (a applicationDo) Clauses(conds ...clause.Expression) IApplicationDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a applicationDo) Returning(value interface{}, columns ...string) IApplicationDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a applicationDo) Not(conds ...gen.Condition) IApplicationDo {
return a.withDO(a.DO.Not(conds...))
}
func (a applicationDo) Or(conds ...gen.Condition) IApplicationDo {
return a.withDO(a.DO.Or(conds...))
}
func (a applicationDo) Select(conds ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Select(conds...))
}
func (a applicationDo) Where(conds ...gen.Condition) IApplicationDo {
return a.withDO(a.DO.Where(conds...))
}
func (a applicationDo) Order(conds ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Order(conds...))
}
func (a applicationDo) Distinct(cols ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a applicationDo) Omit(cols ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a applicationDo) Join(table schema.Tabler, on ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a applicationDo) LeftJoin(table schema.Tabler, on ...field.Expr) IApplicationDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a applicationDo) RightJoin(table schema.Tabler, on ...field.Expr) IApplicationDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a applicationDo) Group(cols ...field.Expr) IApplicationDo {
return a.withDO(a.DO.Group(cols...))
}
func (a applicationDo) Having(conds ...gen.Condition) IApplicationDo {
return a.withDO(a.DO.Having(conds...))
}
func (a applicationDo) Limit(limit int) IApplicationDo {
return a.withDO(a.DO.Limit(limit))
}
func (a applicationDo) Offset(offset int) IApplicationDo {
return a.withDO(a.DO.Offset(offset))
}
func (a applicationDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IApplicationDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a applicationDo) Unscoped() IApplicationDo {
return a.withDO(a.DO.Unscoped())
}
func (a applicationDo) Create(values ...*entity.Application) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a applicationDo) CreateInBatches(values []*entity.Application, batchSize int) error {
return a.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 (a applicationDo) Save(values ...*entity.Application) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a applicationDo) First() (*entity.Application, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*entity.Application), nil
}
}
func (a applicationDo) Take() (*entity.Application, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*entity.Application), nil
}
}
func (a applicationDo) Last() (*entity.Application, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*entity.Application), nil
}
}
func (a applicationDo) Find() ([]*entity.Application, error) {
result, err := a.DO.Find()
return result.([]*entity.Application), err
}
func (a applicationDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Application, err error) {
buf := make([]*entity.Application, 0, batchSize)
err = a.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 (a applicationDo) FindInBatches(result *[]*entity.Application, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a applicationDo) Attrs(attrs ...field.AssignExpr) IApplicationDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a applicationDo) Assign(attrs ...field.AssignExpr) IApplicationDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a applicationDo) Joins(fields ...field.RelationField) IApplicationDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a applicationDo) Preload(fields ...field.RelationField) IApplicationDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a applicationDo) FirstOrInit() (*entity.Application, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*entity.Application), nil
}
}
func (a applicationDo) FirstOrCreate() (*entity.Application, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*entity.Application), nil
}
}
func (a applicationDo) FindByPage(offset int, limit int) (result []*entity.Application, count int64, err error) {
result, err = a.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 = a.Offset(-1).Limit(-1).Count()
return
}
func (a applicationDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a applicationDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a applicationDo) Delete(models ...*entity.Application) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *applicationDo) withDO(do gen.Dao) *applicationDo {
a.DO = *do.(*gen.DO)
return a
}