2024-12-06 15:38:22 +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/Leaf/leaf-library-3/internal/entity"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newDocumentBlock(db *gorm.DB, opts ...gen.DOOption) documentBlock {
|
|
|
|
_documentBlock := documentBlock{}
|
|
|
|
|
|
|
|
_documentBlock.documentBlockDo.UseDB(db, opts...)
|
|
|
|
_documentBlock.documentBlockDo.UseModel(&entity.DocumentBlock{})
|
|
|
|
|
|
|
|
tableName := _documentBlock.documentBlockDo.TableName()
|
|
|
|
_documentBlock.ALL = field.NewAsterisk(tableName)
|
2024-12-06 18:44:32 +00:00
|
|
|
_documentBlock.ID = field.NewUint(tableName, "id")
|
2024-12-06 15:38:22 +00:00
|
|
|
_documentBlock.CreatedAt = field.NewTime(tableName, "created_at")
|
|
|
|
_documentBlock.UpdatedAt = field.NewTime(tableName, "updated_at")
|
|
|
|
_documentBlock.DocumentId = field.NewUint(tableName, "document_id")
|
|
|
|
_documentBlock.Type = field.NewString(tableName, "type")
|
|
|
|
_documentBlock.Content = field.NewString(tableName, "content")
|
|
|
|
_documentBlock.Hash = field.NewString(tableName, "hash")
|
2024-12-06 18:44:32 +00:00
|
|
|
_documentBlock.Order_ = field.NewFloat64(tableName, "order")
|
2024-12-06 15:38:22 +00:00
|
|
|
_documentBlock.Document = documentBlockBelongsToDocument{
|
|
|
|
db: db.Session(&gorm.Session{}),
|
|
|
|
|
|
|
|
RelationField: field.NewRelation("Document", "entity.Document"),
|
|
|
|
Workspace: struct {
|
|
|
|
field.RelationField
|
|
|
|
}{
|
|
|
|
RelationField: field.NewRelation("Document.Workspace", "entity.Workspace"),
|
|
|
|
},
|
|
|
|
Collection: struct {
|
|
|
|
field.RelationField
|
|
|
|
Workspace struct {
|
|
|
|
field.RelationField
|
|
|
|
}
|
|
|
|
}{
|
|
|
|
RelationField: field.NewRelation("Document.Collection", "entity.Collection"),
|
|
|
|
Workspace: struct {
|
|
|
|
field.RelationField
|
|
|
|
}{
|
|
|
|
RelationField: field.NewRelation("Document.Collection.Workspace", "entity.Workspace"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Parent: struct {
|
|
|
|
field.RelationField
|
|
|
|
}{
|
|
|
|
RelationField: field.NewRelation("Document.Parent", "entity.Document"),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
_documentBlock.fillFieldMap()
|
|
|
|
|
|
|
|
return _documentBlock
|
|
|
|
}
|
|
|
|
|
|
|
|
type documentBlock struct {
|
|
|
|
documentBlockDo
|
|
|
|
|
|
|
|
ALL field.Asterisk
|
2024-12-06 18:44:32 +00:00
|
|
|
ID field.Uint
|
2024-12-06 15:38:22 +00:00
|
|
|
CreatedAt field.Time
|
|
|
|
UpdatedAt field.Time
|
|
|
|
DocumentId field.Uint
|
|
|
|
Type field.String
|
|
|
|
Content field.String
|
|
|
|
Hash field.String
|
2024-12-06 18:44:32 +00:00
|
|
|
Order_ field.Float64
|
2024-12-06 15:38:22 +00:00
|
|
|
Document documentBlockBelongsToDocument
|
|
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlock) Table(newTableName string) *documentBlock {
|
|
|
|
d.documentBlockDo.UseTable(newTableName)
|
|
|
|
return d.updateTableName(newTableName)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlock) As(alias string) *documentBlock {
|
|
|
|
d.documentBlockDo.DO = *(d.documentBlockDo.As(alias).(*gen.DO))
|
|
|
|
return d.updateTableName(alias)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *documentBlock) updateTableName(table string) *documentBlock {
|
|
|
|
d.ALL = field.NewAsterisk(table)
|
2024-12-06 18:44:32 +00:00
|
|
|
d.ID = field.NewUint(table, "id")
|
2024-12-06 15:38:22 +00:00
|
|
|
d.CreatedAt = field.NewTime(table, "created_at")
|
|
|
|
d.UpdatedAt = field.NewTime(table, "updated_at")
|
|
|
|
d.DocumentId = field.NewUint(table, "document_id")
|
|
|
|
d.Type = field.NewString(table, "type")
|
|
|
|
d.Content = field.NewString(table, "content")
|
|
|
|
d.Hash = field.NewString(table, "hash")
|
2024-12-06 18:44:32 +00:00
|
|
|
d.Order_ = field.NewFloat64(table, "order")
|
2024-12-06 15:38:22 +00:00
|
|
|
|
|
|
|
d.fillFieldMap()
|
|
|
|
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *documentBlock) 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 *documentBlock) fillFieldMap() {
|
2024-12-06 18:44:32 +00:00
|
|
|
d.fieldMap = make(map[string]field.Expr, 9)
|
|
|
|
d.fieldMap["id"] = d.ID
|
2024-12-06 15:38:22 +00:00
|
|
|
d.fieldMap["created_at"] = d.CreatedAt
|
|
|
|
d.fieldMap["updated_at"] = d.UpdatedAt
|
|
|
|
d.fieldMap["document_id"] = d.DocumentId
|
|
|
|
d.fieldMap["type"] = d.Type
|
|
|
|
d.fieldMap["content"] = d.Content
|
|
|
|
d.fieldMap["hash"] = d.Hash
|
2024-12-06 18:44:32 +00:00
|
|
|
d.fieldMap["order"] = d.Order_
|
2024-12-06 15:38:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlock) clone(db *gorm.DB) documentBlock {
|
|
|
|
d.documentBlockDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlock) replaceDB(db *gorm.DB) documentBlock {
|
|
|
|
d.documentBlockDo.ReplaceDB(db)
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
type documentBlockBelongsToDocument struct {
|
|
|
|
db *gorm.DB
|
|
|
|
|
|
|
|
field.RelationField
|
|
|
|
|
|
|
|
Workspace struct {
|
|
|
|
field.RelationField
|
|
|
|
}
|
|
|
|
Collection struct {
|
|
|
|
field.RelationField
|
|
|
|
Workspace struct {
|
|
|
|
field.RelationField
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Parent struct {
|
|
|
|
field.RelationField
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocument) Where(conds ...field.Expr) *documentBlockBelongsToDocument {
|
|
|
|
if len(conds) == 0 {
|
|
|
|
return &a
|
|
|
|
}
|
|
|
|
|
|
|
|
exprs := make([]clause.Expression, 0, len(conds))
|
|
|
|
for _, cond := range conds {
|
|
|
|
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
|
|
|
}
|
|
|
|
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
|
|
|
return &a
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocument) WithContext(ctx context.Context) *documentBlockBelongsToDocument {
|
|
|
|
a.db = a.db.WithContext(ctx)
|
|
|
|
return &a
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocument) Session(session *gorm.Session) *documentBlockBelongsToDocument {
|
|
|
|
a.db = a.db.Session(session)
|
|
|
|
return &a
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocument) Model(m *entity.DocumentBlock) *documentBlockBelongsToDocumentTx {
|
|
|
|
return &documentBlockBelongsToDocumentTx{a.db.Model(m).Association(a.Name())}
|
|
|
|
}
|
|
|
|
|
|
|
|
type documentBlockBelongsToDocumentTx struct{ tx *gorm.Association }
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Find() (result *entity.Document, err error) {
|
|
|
|
return result, a.tx.Find(&result)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Append(values ...*entity.Document) (err error) {
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
for i, v := range values {
|
|
|
|
targetValues[i] = v
|
|
|
|
}
|
|
|
|
return a.tx.Append(targetValues...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Replace(values ...*entity.Document) (err error) {
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
for i, v := range values {
|
|
|
|
targetValues[i] = v
|
|
|
|
}
|
|
|
|
return a.tx.Replace(targetValues...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Delete(values ...*entity.Document) (err error) {
|
|
|
|
targetValues := make([]interface{}, len(values))
|
|
|
|
for i, v := range values {
|
|
|
|
targetValues[i] = v
|
|
|
|
}
|
|
|
|
return a.tx.Delete(targetValues...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Clear() error {
|
|
|
|
return a.tx.Clear()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a documentBlockBelongsToDocumentTx) Count() int64 {
|
|
|
|
return a.tx.Count()
|
|
|
|
}
|
|
|
|
|
|
|
|
type documentBlockDo struct{ gen.DO }
|
|
|
|
|
|
|
|
type IDocumentBlockDo interface {
|
|
|
|
gen.SubQuery
|
|
|
|
Debug() IDocumentBlockDo
|
|
|
|
WithContext(ctx context.Context) IDocumentBlockDo
|
|
|
|
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
|
|
|
ReplaceDB(db *gorm.DB)
|
|
|
|
ReadDB() IDocumentBlockDo
|
|
|
|
WriteDB() IDocumentBlockDo
|
|
|
|
As(alias string) gen.Dao
|
|
|
|
Session(config *gorm.Session) IDocumentBlockDo
|
|
|
|
Columns(cols ...field.Expr) gen.Columns
|
|
|
|
Clauses(conds ...clause.Expression) IDocumentBlockDo
|
|
|
|
Not(conds ...gen.Condition) IDocumentBlockDo
|
|
|
|
Or(conds ...gen.Condition) IDocumentBlockDo
|
|
|
|
Select(conds ...field.Expr) IDocumentBlockDo
|
|
|
|
Where(conds ...gen.Condition) IDocumentBlockDo
|
|
|
|
Order(conds ...field.Expr) IDocumentBlockDo
|
|
|
|
Distinct(cols ...field.Expr) IDocumentBlockDo
|
|
|
|
Omit(cols ...field.Expr) IDocumentBlockDo
|
|
|
|
Join(table schema.Tabler, on ...field.Expr) IDocumentBlockDo
|
|
|
|
LeftJoin(table schema.Tabler, on ...field.Expr) IDocumentBlockDo
|
|
|
|
RightJoin(table schema.Tabler, on ...field.Expr) IDocumentBlockDo
|
|
|
|
Group(cols ...field.Expr) IDocumentBlockDo
|
|
|
|
Having(conds ...gen.Condition) IDocumentBlockDo
|
|
|
|
Limit(limit int) IDocumentBlockDo
|
|
|
|
Offset(offset int) IDocumentBlockDo
|
|
|
|
Count() (count int64, err error)
|
|
|
|
Scopes(funcs ...func(gen.Dao) gen.Dao) IDocumentBlockDo
|
|
|
|
Unscoped() IDocumentBlockDo
|
|
|
|
Create(values ...*entity.DocumentBlock) error
|
|
|
|
CreateInBatches(values []*entity.DocumentBlock, batchSize int) error
|
|
|
|
Save(values ...*entity.DocumentBlock) error
|
|
|
|
First() (*entity.DocumentBlock, error)
|
|
|
|
Take() (*entity.DocumentBlock, error)
|
|
|
|
Last() (*entity.DocumentBlock, error)
|
|
|
|
Find() ([]*entity.DocumentBlock, error)
|
|
|
|
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.DocumentBlock, err error)
|
|
|
|
FindInBatches(result *[]*entity.DocumentBlock, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
|
|
|
Pluck(column field.Expr, dest interface{}) error
|
|
|
|
Delete(...*entity.DocumentBlock) (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) IDocumentBlockDo
|
|
|
|
Assign(attrs ...field.AssignExpr) IDocumentBlockDo
|
|
|
|
Joins(fields ...field.RelationField) IDocumentBlockDo
|
|
|
|
Preload(fields ...field.RelationField) IDocumentBlockDo
|
|
|
|
FirstOrInit() (*entity.DocumentBlock, error)
|
|
|
|
FirstOrCreate() (*entity.DocumentBlock, error)
|
|
|
|
FindByPage(offset int, limit int) (result []*entity.DocumentBlock, 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) IDocumentBlockDo
|
|
|
|
UnderlyingDB() *gorm.DB
|
|
|
|
schema.Tabler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Debug() IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Debug())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) WithContext(ctx context.Context) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.WithContext(ctx))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) ReadDB() IDocumentBlockDo {
|
|
|
|
return d.Clauses(dbresolver.Read)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) WriteDB() IDocumentBlockDo {
|
|
|
|
return d.Clauses(dbresolver.Write)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Session(config *gorm.Session) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Session(config))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Clauses(conds ...clause.Expression) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Clauses(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Returning(value interface{}, columns ...string) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Returning(value, columns...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Not(conds ...gen.Condition) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Not(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Or(conds ...gen.Condition) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Or(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Select(conds ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Select(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Where(conds ...gen.Condition) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Where(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Order(conds ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Order(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Distinct(cols ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Distinct(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Omit(cols ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Omit(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Join(table schema.Tabler, on ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Join(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) LeftJoin(table schema.Tabler, on ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.LeftJoin(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) RightJoin(table schema.Tabler, on ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.RightJoin(table, on...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Group(cols ...field.Expr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Group(cols...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Having(conds ...gen.Condition) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Having(conds...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Limit(limit int) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Limit(limit))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Offset(offset int) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Offset(offset))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Scopes(funcs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Unscoped() IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Unscoped())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Create(values ...*entity.DocumentBlock) error {
|
|
|
|
if len(values) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return d.DO.Create(values)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) CreateInBatches(values []*entity.DocumentBlock, 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 documentBlockDo) Save(values ...*entity.DocumentBlock) error {
|
|
|
|
if len(values) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return d.DO.Save(values)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) First() (*entity.DocumentBlock, error) {
|
|
|
|
if result, err := d.DO.First(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*entity.DocumentBlock), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Take() (*entity.DocumentBlock, error) {
|
|
|
|
if result, err := d.DO.Take(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*entity.DocumentBlock), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Last() (*entity.DocumentBlock, error) {
|
|
|
|
if result, err := d.DO.Last(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*entity.DocumentBlock), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Find() ([]*entity.DocumentBlock, error) {
|
|
|
|
result, err := d.DO.Find()
|
|
|
|
return result.([]*entity.DocumentBlock), err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.DocumentBlock, err error) {
|
|
|
|
buf := make([]*entity.DocumentBlock, 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 documentBlockDo) FindInBatches(result *[]*entity.DocumentBlock, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
|
return d.DO.FindInBatches(result, batchSize, fc)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Attrs(attrs ...field.AssignExpr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Attrs(attrs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Assign(attrs ...field.AssignExpr) IDocumentBlockDo {
|
|
|
|
return d.withDO(d.DO.Assign(attrs...))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Joins(fields ...field.RelationField) IDocumentBlockDo {
|
|
|
|
for _, _f := range fields {
|
|
|
|
d = *d.withDO(d.DO.Joins(_f))
|
|
|
|
}
|
|
|
|
return &d
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Preload(fields ...field.RelationField) IDocumentBlockDo {
|
|
|
|
for _, _f := range fields {
|
|
|
|
d = *d.withDO(d.DO.Preload(_f))
|
|
|
|
}
|
|
|
|
return &d
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) FirstOrInit() (*entity.DocumentBlock, error) {
|
|
|
|
if result, err := d.DO.FirstOrInit(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*entity.DocumentBlock), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) FirstOrCreate() (*entity.DocumentBlock, error) {
|
|
|
|
if result, err := d.DO.FirstOrCreate(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
return result.(*entity.DocumentBlock), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) FindByPage(offset int, limit int) (result []*entity.DocumentBlock, 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 documentBlockDo) 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 documentBlockDo) Scan(result interface{}) (err error) {
|
|
|
|
return d.DO.Scan(result)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d documentBlockDo) Delete(models ...*entity.DocumentBlock) (result gen.ResultInfo, err error) {
|
|
|
|
return d.DO.Delete(models)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *documentBlockDo) withDO(do gen.Dao) *documentBlockDo {
|
|
|
|
d.DO = *do.(*gen.DO)
|
|
|
|
return d
|
|
|
|
}
|