// 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/api-platform/internal/entity" ) func newApiDocument(db *gorm.DB, opts ...gen.DOOption) apiDocument { _apiDocument := apiDocument{} _apiDocument.apiDocumentDo.UseDB(db, opts...) _apiDocument.apiDocumentDo.UseModel(&entity.ApiDocument{}) tableName := _apiDocument.apiDocumentDo.TableName() _apiDocument.ALL = field.NewAsterisk(tableName) _apiDocument.Id = field.NewUint(tableName, "id") _apiDocument.CreatedAt = field.NewTime(tableName, "created_at") _apiDocument.UpdatedAt = field.NewTime(tableName, "updated_at") _apiDocument.ApiId = field.NewUint(tableName, "api_id") _apiDocument.OpenAPIUrl = field.NewString(tableName, "openapi_url") _apiDocument.Content = field.NewString(tableName, "content") _apiDocument.Api = apiDocumentBelongsToApi{ db: db.Session(&gorm.Session{}), RelationField: field.NewRelation("Api", "entity.Api"), } _apiDocument.fillFieldMap() return _apiDocument } type apiDocument struct { apiDocumentDo ALL field.Asterisk Id field.Uint CreatedAt field.Time UpdatedAt field.Time ApiId field.Uint OpenAPIUrl field.String Content field.String Api apiDocumentBelongsToApi fieldMap map[string]field.Expr } func (a apiDocument) Table(newTableName string) *apiDocument { a.apiDocumentDo.UseTable(newTableName) return a.updateTableName(newTableName) } func (a apiDocument) As(alias string) *apiDocument { a.apiDocumentDo.DO = *(a.apiDocumentDo.As(alias).(*gen.DO)) return a.updateTableName(alias) } func (a *apiDocument) updateTableName(table string) *apiDocument { 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.ApiId = field.NewUint(table, "api_id") a.OpenAPIUrl = field.NewString(table, "openapi_url") a.Content = field.NewString(table, "content") a.fillFieldMap() return a } func (a *apiDocument) 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 *apiDocument) fillFieldMap() { a.fieldMap = make(map[string]field.Expr, 7) a.fieldMap["id"] = a.Id a.fieldMap["created_at"] = a.CreatedAt a.fieldMap["updated_at"] = a.UpdatedAt a.fieldMap["api_id"] = a.ApiId a.fieldMap["openapi_url"] = a.OpenAPIUrl a.fieldMap["content"] = a.Content } func (a apiDocument) clone(db *gorm.DB) apiDocument { a.apiDocumentDo.ReplaceConnPool(db.Statement.ConnPool) return a } func (a apiDocument) replaceDB(db *gorm.DB) apiDocument { a.apiDocumentDo.ReplaceDB(db) return a } type apiDocumentBelongsToApi struct { db *gorm.DB field.RelationField } func (a apiDocumentBelongsToApi) Where(conds ...field.Expr) *apiDocumentBelongsToApi { 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 apiDocumentBelongsToApi) WithContext(ctx context.Context) *apiDocumentBelongsToApi { a.db = a.db.WithContext(ctx) return &a } func (a apiDocumentBelongsToApi) Session(session *gorm.Session) *apiDocumentBelongsToApi { a.db = a.db.Session(session) return &a } func (a apiDocumentBelongsToApi) Model(m *entity.ApiDocument) *apiDocumentBelongsToApiTx { return &apiDocumentBelongsToApiTx{a.db.Model(m).Association(a.Name())} } type apiDocumentBelongsToApiTx struct{ tx *gorm.Association } func (a apiDocumentBelongsToApiTx) Find() (result *entity.Api, err error) { return result, a.tx.Find(&result) } func (a apiDocumentBelongsToApiTx) Append(values ...*entity.Api) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Append(targetValues...) } func (a apiDocumentBelongsToApiTx) Replace(values ...*entity.Api) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Replace(targetValues...) } func (a apiDocumentBelongsToApiTx) Delete(values ...*entity.Api) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v } return a.tx.Delete(targetValues...) } func (a apiDocumentBelongsToApiTx) Clear() error { return a.tx.Clear() } func (a apiDocumentBelongsToApiTx) Count() int64 { return a.tx.Count() } type apiDocumentDo struct{ gen.DO } type IApiDocumentDo interface { gen.SubQuery Debug() IApiDocumentDo WithContext(ctx context.Context) IApiDocumentDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IApiDocumentDo WriteDB() IApiDocumentDo As(alias string) gen.Dao Session(config *gorm.Session) IApiDocumentDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IApiDocumentDo Not(conds ...gen.Condition) IApiDocumentDo Or(conds ...gen.Condition) IApiDocumentDo Select(conds ...field.Expr) IApiDocumentDo Where(conds ...gen.Condition) IApiDocumentDo Order(conds ...field.Expr) IApiDocumentDo Distinct(cols ...field.Expr) IApiDocumentDo Omit(cols ...field.Expr) IApiDocumentDo Join(table schema.Tabler, on ...field.Expr) IApiDocumentDo LeftJoin(table schema.Tabler, on ...field.Expr) IApiDocumentDo RightJoin(table schema.Tabler, on ...field.Expr) IApiDocumentDo Group(cols ...field.Expr) IApiDocumentDo Having(conds ...gen.Condition) IApiDocumentDo Limit(limit int) IApiDocumentDo Offset(offset int) IApiDocumentDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IApiDocumentDo Unscoped() IApiDocumentDo Create(values ...*entity.ApiDocument) error CreateInBatches(values []*entity.ApiDocument, batchSize int) error Save(values ...*entity.ApiDocument) error First() (*entity.ApiDocument, error) Take() (*entity.ApiDocument, error) Last() (*entity.ApiDocument, error) Find() ([]*entity.ApiDocument, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.ApiDocument, err error) FindInBatches(result *[]*entity.ApiDocument, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*entity.ApiDocument) (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) IApiDocumentDo Assign(attrs ...field.AssignExpr) IApiDocumentDo Joins(fields ...field.RelationField) IApiDocumentDo Preload(fields ...field.RelationField) IApiDocumentDo FirstOrInit() (*entity.ApiDocument, error) FirstOrCreate() (*entity.ApiDocument, error) FindByPage(offset int, limit int) (result []*entity.ApiDocument, 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) IApiDocumentDo UnderlyingDB() *gorm.DB schema.Tabler } func (a apiDocumentDo) Debug() IApiDocumentDo { return a.withDO(a.DO.Debug()) } func (a apiDocumentDo) WithContext(ctx context.Context) IApiDocumentDo { return a.withDO(a.DO.WithContext(ctx)) } func (a apiDocumentDo) ReadDB() IApiDocumentDo { return a.Clauses(dbresolver.Read) } func (a apiDocumentDo) WriteDB() IApiDocumentDo { return a.Clauses(dbresolver.Write) } func (a apiDocumentDo) Session(config *gorm.Session) IApiDocumentDo { return a.withDO(a.DO.Session(config)) } func (a apiDocumentDo) Clauses(conds ...clause.Expression) IApiDocumentDo { return a.withDO(a.DO.Clauses(conds...)) } func (a apiDocumentDo) Returning(value interface{}, columns ...string) IApiDocumentDo { return a.withDO(a.DO.Returning(value, columns...)) } func (a apiDocumentDo) Not(conds ...gen.Condition) IApiDocumentDo { return a.withDO(a.DO.Not(conds...)) } func (a apiDocumentDo) Or(conds ...gen.Condition) IApiDocumentDo { return a.withDO(a.DO.Or(conds...)) } func (a apiDocumentDo) Select(conds ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Select(conds...)) } func (a apiDocumentDo) Where(conds ...gen.Condition) IApiDocumentDo { return a.withDO(a.DO.Where(conds...)) } func (a apiDocumentDo) Order(conds ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Order(conds...)) } func (a apiDocumentDo) Distinct(cols ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Distinct(cols...)) } func (a apiDocumentDo) Omit(cols ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Omit(cols...)) } func (a apiDocumentDo) Join(table schema.Tabler, on ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Join(table, on...)) } func (a apiDocumentDo) LeftJoin(table schema.Tabler, on ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.LeftJoin(table, on...)) } func (a apiDocumentDo) RightJoin(table schema.Tabler, on ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.RightJoin(table, on...)) } func (a apiDocumentDo) Group(cols ...field.Expr) IApiDocumentDo { return a.withDO(a.DO.Group(cols...)) } func (a apiDocumentDo) Having(conds ...gen.Condition) IApiDocumentDo { return a.withDO(a.DO.Having(conds...)) } func (a apiDocumentDo) Limit(limit int) IApiDocumentDo { return a.withDO(a.DO.Limit(limit)) } func (a apiDocumentDo) Offset(offset int) IApiDocumentDo { return a.withDO(a.DO.Offset(offset)) } func (a apiDocumentDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IApiDocumentDo { return a.withDO(a.DO.Scopes(funcs...)) } func (a apiDocumentDo) Unscoped() IApiDocumentDo { return a.withDO(a.DO.Unscoped()) } func (a apiDocumentDo) Create(values ...*entity.ApiDocument) error { if len(values) == 0 { return nil } return a.DO.Create(values) } func (a apiDocumentDo) CreateInBatches(values []*entity.ApiDocument, 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 apiDocumentDo) Save(values ...*entity.ApiDocument) error { if len(values) == 0 { return nil } return a.DO.Save(values) } func (a apiDocumentDo) First() (*entity.ApiDocument, error) { if result, err := a.DO.First(); err != nil { return nil, err } else { return result.(*entity.ApiDocument), nil } } func (a apiDocumentDo) Take() (*entity.ApiDocument, error) { if result, err := a.DO.Take(); err != nil { return nil, err } else { return result.(*entity.ApiDocument), nil } } func (a apiDocumentDo) Last() (*entity.ApiDocument, error) { if result, err := a.DO.Last(); err != nil { return nil, err } else { return result.(*entity.ApiDocument), nil } } func (a apiDocumentDo) Find() ([]*entity.ApiDocument, error) { result, err := a.DO.Find() return result.([]*entity.ApiDocument), err } func (a apiDocumentDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.ApiDocument, err error) { buf := make([]*entity.ApiDocument, 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 apiDocumentDo) FindInBatches(result *[]*entity.ApiDocument, batchSize int, fc func(tx gen.Dao, batch int) error) error { return a.DO.FindInBatches(result, batchSize, fc) } func (a apiDocumentDo) Attrs(attrs ...field.AssignExpr) IApiDocumentDo { return a.withDO(a.DO.Attrs(attrs...)) } func (a apiDocumentDo) Assign(attrs ...field.AssignExpr) IApiDocumentDo { return a.withDO(a.DO.Assign(attrs...)) } func (a apiDocumentDo) Joins(fields ...field.RelationField) IApiDocumentDo { for _, _f := range fields { a = *a.withDO(a.DO.Joins(_f)) } return &a } func (a apiDocumentDo) Preload(fields ...field.RelationField) IApiDocumentDo { for _, _f := range fields { a = *a.withDO(a.DO.Preload(_f)) } return &a } func (a apiDocumentDo) FirstOrInit() (*entity.ApiDocument, error) { if result, err := a.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*entity.ApiDocument), nil } } func (a apiDocumentDo) FirstOrCreate() (*entity.ApiDocument, error) { if result, err := a.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*entity.ApiDocument), nil } } func (a apiDocumentDo) FindByPage(offset int, limit int) (result []*entity.ApiDocument, 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 apiDocumentDo) 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 apiDocumentDo) Scan(result interface{}) (err error) { return a.DO.Scan(result) } func (a apiDocumentDo) Delete(models ...*entity.ApiDocument) (result gen.ResultInfo, err error) { return a.DO.Delete(models) } func (a *apiDocumentDo) withDO(do gen.Dao) *apiDocumentDo { a.DO = *do.(*gen.DO) return a }