424 lines
12 KiB
Go
424 lines
12 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"
|
|
"database/sql"
|
|
|
|
"gorm.io/gorm"
|
|
"gorm.io/gorm/clause"
|
|
"gorm.io/gorm/schema"
|
|
|
|
"gorm.io/gen"
|
|
"gorm.io/gen/field"
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
"kra/internal/data/model"
|
|
)
|
|
|
|
func newExaFile(db *gorm.DB, opts ...gen.DOOption) exaFile {
|
|
_exaFile := exaFile{}
|
|
|
|
_exaFile.exaFileDo.UseDB(db, opts...)
|
|
_exaFile.exaFileDo.UseModel(&model.ExaFile{})
|
|
|
|
tableName := _exaFile.exaFileDo.TableName()
|
|
_exaFile.ALL = field.NewAsterisk(tableName)
|
|
_exaFile.ID = field.NewInt64(tableName, "id")
|
|
_exaFile.CreatedAt = field.NewTime(tableName, "created_at")
|
|
_exaFile.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
_exaFile.DeletedAt = field.NewField(tableName, "deleted_at")
|
|
_exaFile.FileName = field.NewString(tableName, "file_name")
|
|
_exaFile.FileMd5 = field.NewString(tableName, "file_md5")
|
|
_exaFile.FilePath = field.NewString(tableName, "file_path")
|
|
_exaFile.ChunkTotal = field.NewInt64(tableName, "chunk_total")
|
|
_exaFile.IsFinish = field.NewBool(tableName, "is_finish")
|
|
|
|
_exaFile.fillFieldMap()
|
|
|
|
return _exaFile
|
|
}
|
|
|
|
type exaFile struct {
|
|
exaFileDo exaFileDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
CreatedAt field.Time
|
|
UpdatedAt field.Time
|
|
DeletedAt field.Field
|
|
FileName field.String
|
|
FileMd5 field.String
|
|
FilePath field.String
|
|
ChunkTotal field.Int64
|
|
IsFinish field.Bool
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (e exaFile) Table(newTableName string) *exaFile {
|
|
e.exaFileDo.UseTable(newTableName)
|
|
return e.updateTableName(newTableName)
|
|
}
|
|
|
|
func (e exaFile) As(alias string) *exaFile {
|
|
e.exaFileDo.DO = *(e.exaFileDo.As(alias).(*gen.DO))
|
|
return e.updateTableName(alias)
|
|
}
|
|
|
|
func (e *exaFile) updateTableName(table string) *exaFile {
|
|
e.ALL = field.NewAsterisk(table)
|
|
e.ID = field.NewInt64(table, "id")
|
|
e.CreatedAt = field.NewTime(table, "created_at")
|
|
e.UpdatedAt = field.NewTime(table, "updated_at")
|
|
e.DeletedAt = field.NewField(table, "deleted_at")
|
|
e.FileName = field.NewString(table, "file_name")
|
|
e.FileMd5 = field.NewString(table, "file_md5")
|
|
e.FilePath = field.NewString(table, "file_path")
|
|
e.ChunkTotal = field.NewInt64(table, "chunk_total")
|
|
e.IsFinish = field.NewBool(table, "is_finish")
|
|
|
|
e.fillFieldMap()
|
|
|
|
return e
|
|
}
|
|
|
|
func (e *exaFile) WithContext(ctx context.Context) IExaFileDo { return e.exaFileDo.WithContext(ctx) }
|
|
|
|
func (e exaFile) TableName() string { return e.exaFileDo.TableName() }
|
|
|
|
func (e exaFile) Alias() string { return e.exaFileDo.Alias() }
|
|
|
|
func (e exaFile) Columns(cols ...field.Expr) gen.Columns { return e.exaFileDo.Columns(cols...) }
|
|
|
|
func (e *exaFile) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
_f, ok := e.fieldMap[fieldName]
|
|
if !ok || _f == nil {
|
|
return nil, false
|
|
}
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
return _oe, ok
|
|
}
|
|
|
|
func (e *exaFile) fillFieldMap() {
|
|
e.fieldMap = make(map[string]field.Expr, 9)
|
|
e.fieldMap["id"] = e.ID
|
|
e.fieldMap["created_at"] = e.CreatedAt
|
|
e.fieldMap["updated_at"] = e.UpdatedAt
|
|
e.fieldMap["deleted_at"] = e.DeletedAt
|
|
e.fieldMap["file_name"] = e.FileName
|
|
e.fieldMap["file_md5"] = e.FileMd5
|
|
e.fieldMap["file_path"] = e.FilePath
|
|
e.fieldMap["chunk_total"] = e.ChunkTotal
|
|
e.fieldMap["is_finish"] = e.IsFinish
|
|
}
|
|
|
|
func (e exaFile) clone(db *gorm.DB) exaFile {
|
|
e.exaFileDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return e
|
|
}
|
|
|
|
func (e exaFile) replaceDB(db *gorm.DB) exaFile {
|
|
e.exaFileDo.ReplaceDB(db)
|
|
return e
|
|
}
|
|
|
|
type exaFileDo struct{ gen.DO }
|
|
|
|
type IExaFileDo interface {
|
|
gen.SubQuery
|
|
Debug() IExaFileDo
|
|
WithContext(ctx context.Context) IExaFileDo
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
ReplaceDB(db *gorm.DB)
|
|
ReadDB() IExaFileDo
|
|
WriteDB() IExaFileDo
|
|
As(alias string) gen.Dao
|
|
Session(config *gorm.Session) IExaFileDo
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
Clauses(conds ...clause.Expression) IExaFileDo
|
|
Not(conds ...gen.Condition) IExaFileDo
|
|
Or(conds ...gen.Condition) IExaFileDo
|
|
Select(conds ...field.Expr) IExaFileDo
|
|
Where(conds ...gen.Condition) IExaFileDo
|
|
Order(conds ...field.Expr) IExaFileDo
|
|
Distinct(cols ...field.Expr) IExaFileDo
|
|
Omit(cols ...field.Expr) IExaFileDo
|
|
Join(table schema.Tabler, on ...field.Expr) IExaFileDo
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IExaFileDo
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IExaFileDo
|
|
Group(cols ...field.Expr) IExaFileDo
|
|
Having(conds ...gen.Condition) IExaFileDo
|
|
Limit(limit int) IExaFileDo
|
|
Offset(offset int) IExaFileDo
|
|
Count() (count int64, err error)
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IExaFileDo
|
|
Unscoped() IExaFileDo
|
|
Create(values ...*model.ExaFile) error
|
|
CreateInBatches(values []*model.ExaFile, batchSize int) error
|
|
Save(values ...*model.ExaFile) error
|
|
First() (*model.ExaFile, error)
|
|
Take() (*model.ExaFile, error)
|
|
Last() (*model.ExaFile, error)
|
|
Find() ([]*model.ExaFile, error)
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaFile, err error)
|
|
FindInBatches(result *[]*model.ExaFile, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
Delete(...*model.ExaFile) (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) IExaFileDo
|
|
Assign(attrs ...field.AssignExpr) IExaFileDo
|
|
Joins(fields ...field.RelationField) IExaFileDo
|
|
Preload(fields ...field.RelationField) IExaFileDo
|
|
FirstOrInit() (*model.ExaFile, error)
|
|
FirstOrCreate() (*model.ExaFile, error)
|
|
FindByPage(offset int, limit int) (result []*model.ExaFile, count int64, err error)
|
|
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
|
Rows() (*sql.Rows, error)
|
|
Row() *sql.Row
|
|
Scan(result interface{}) (err error)
|
|
Returning(value interface{}, columns ...string) IExaFileDo
|
|
UnderlyingDB() *gorm.DB
|
|
schema.Tabler
|
|
}
|
|
|
|
func (e exaFileDo) Debug() IExaFileDo {
|
|
return e.withDO(e.DO.Debug())
|
|
}
|
|
|
|
func (e exaFileDo) WithContext(ctx context.Context) IExaFileDo {
|
|
return e.withDO(e.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (e exaFileDo) ReadDB() IExaFileDo {
|
|
return e.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (e exaFileDo) WriteDB() IExaFileDo {
|
|
return e.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (e exaFileDo) Session(config *gorm.Session) IExaFileDo {
|
|
return e.withDO(e.DO.Session(config))
|
|
}
|
|
|
|
func (e exaFileDo) Clauses(conds ...clause.Expression) IExaFileDo {
|
|
return e.withDO(e.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Returning(value interface{}, columns ...string) IExaFileDo {
|
|
return e.withDO(e.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (e exaFileDo) Not(conds ...gen.Condition) IExaFileDo {
|
|
return e.withDO(e.DO.Not(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Or(conds ...gen.Condition) IExaFileDo {
|
|
return e.withDO(e.DO.Or(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Select(conds ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Select(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Where(conds ...gen.Condition) IExaFileDo {
|
|
return e.withDO(e.DO.Where(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Order(conds ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Order(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Distinct(cols ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (e exaFileDo) Omit(cols ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Omit(cols...))
|
|
}
|
|
|
|
func (e exaFileDo) Join(table schema.Tabler, on ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Join(table, on...))
|
|
}
|
|
|
|
func (e exaFileDo) LeftJoin(table schema.Tabler, on ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (e exaFileDo) RightJoin(table schema.Tabler, on ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (e exaFileDo) Group(cols ...field.Expr) IExaFileDo {
|
|
return e.withDO(e.DO.Group(cols...))
|
|
}
|
|
|
|
func (e exaFileDo) Having(conds ...gen.Condition) IExaFileDo {
|
|
return e.withDO(e.DO.Having(conds...))
|
|
}
|
|
|
|
func (e exaFileDo) Limit(limit int) IExaFileDo {
|
|
return e.withDO(e.DO.Limit(limit))
|
|
}
|
|
|
|
func (e exaFileDo) Offset(offset int) IExaFileDo {
|
|
return e.withDO(e.DO.Offset(offset))
|
|
}
|
|
|
|
func (e exaFileDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IExaFileDo {
|
|
return e.withDO(e.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (e exaFileDo) Unscoped() IExaFileDo {
|
|
return e.withDO(e.DO.Unscoped())
|
|
}
|
|
|
|
func (e exaFileDo) Create(values ...*model.ExaFile) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return e.DO.Create(values)
|
|
}
|
|
|
|
func (e exaFileDo) CreateInBatches(values []*model.ExaFile, batchSize int) error {
|
|
return e.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 (e exaFileDo) Save(values ...*model.ExaFile) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return e.DO.Save(values)
|
|
}
|
|
|
|
func (e exaFileDo) First() (*model.ExaFile, error) {
|
|
if result, err := e.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFile), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileDo) Take() (*model.ExaFile, error) {
|
|
if result, err := e.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFile), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileDo) Last() (*model.ExaFile, error) {
|
|
if result, err := e.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFile), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileDo) Find() ([]*model.ExaFile, error) {
|
|
result, err := e.DO.Find()
|
|
return result.([]*model.ExaFile), err
|
|
}
|
|
|
|
func (e exaFileDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ExaFile, err error) {
|
|
buf := make([]*model.ExaFile, 0, batchSize)
|
|
err = e.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 (e exaFileDo) FindInBatches(result *[]*model.ExaFile, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return e.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (e exaFileDo) Attrs(attrs ...field.AssignExpr) IExaFileDo {
|
|
return e.withDO(e.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (e exaFileDo) Assign(attrs ...field.AssignExpr) IExaFileDo {
|
|
return e.withDO(e.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (e exaFileDo) Joins(fields ...field.RelationField) IExaFileDo {
|
|
for _, _f := range fields {
|
|
e = *e.withDO(e.DO.Joins(_f))
|
|
}
|
|
return &e
|
|
}
|
|
|
|
func (e exaFileDo) Preload(fields ...field.RelationField) IExaFileDo {
|
|
for _, _f := range fields {
|
|
e = *e.withDO(e.DO.Preload(_f))
|
|
}
|
|
return &e
|
|
}
|
|
|
|
func (e exaFileDo) FirstOrInit() (*model.ExaFile, error) {
|
|
if result, err := e.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFile), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileDo) FirstOrCreate() (*model.ExaFile, error) {
|
|
if result, err := e.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ExaFile), nil
|
|
}
|
|
}
|
|
|
|
func (e exaFileDo) FindByPage(offset int, limit int) (result []*model.ExaFile, count int64, err error) {
|
|
result, err = e.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 = e.Offset(-1).Limit(-1).Count()
|
|
return
|
|
}
|
|
|
|
func (e exaFileDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
count, err = e.Count()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = e.Offset(offset).Limit(limit).Scan(result)
|
|
return
|
|
}
|
|
|
|
func (e exaFileDo) Scan(result interface{}) (err error) {
|
|
return e.DO.Scan(result)
|
|
}
|
|
|
|
func (e exaFileDo) Delete(models ...*model.ExaFile) (result gen.ResultInfo, err error) {
|
|
return e.DO.Delete(models)
|
|
}
|
|
|
|
func (e *exaFileDo) withDO(do gen.Dao) *exaFileDo {
|
|
e.DO = *do.(*gen.DO)
|
|
return e
|
|
}
|