// 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" "joybuywork/internal/repository/model" ) func newLibraryQaGroup(db *gorm.DB, opts ...gen.DOOption) libraryQaGroup { _libraryQaGroup := libraryQaGroup{} _libraryQaGroup.libraryQaGroupDo.UseDB(db, opts...) _libraryQaGroup.libraryQaGroupDo.UseModel(&model.LibraryQaGroup{}) tableName := _libraryQaGroup.libraryQaGroupDo.TableName() _libraryQaGroup.ALL = field.NewAsterisk(tableName) _libraryQaGroup.ID = field.NewInt64(tableName, "id") _libraryQaGroup.CreatedAt = field.NewInt64(tableName, "created_at") _libraryQaGroup.UpdatedAt = field.NewInt64(tableName, "updated_at") _libraryQaGroup.HashID = field.NewString(tableName, "hash_id") _libraryQaGroup.ProjectID = field.NewInt64(tableName, "project_id") _libraryQaGroup.Title = field.NewString(tableName, "title") _libraryQaGroup.DelTime = field.NewInt64(tableName, "del_time") _libraryQaGroup.fillFieldMap() return _libraryQaGroup } type libraryQaGroup struct { libraryQaGroupDo libraryQaGroupDo ALL field.Asterisk ID field.Int64 CreatedAt field.Int64 UpdatedAt field.Int64 HashID field.String // 对外hash_id ProjectID field.Int64 // 项目id(project表) Title field.String // 题库标题 DelTime field.Int64 // 删除时间 fieldMap map[string]field.Expr } func (l libraryQaGroup) Table(newTableName string) *libraryQaGroup { l.libraryQaGroupDo.UseTable(newTableName) return l.updateTableName(newTableName) } func (l libraryQaGroup) As(alias string) *libraryQaGroup { l.libraryQaGroupDo.DO = *(l.libraryQaGroupDo.As(alias).(*gen.DO)) return l.updateTableName(alias) } func (l *libraryQaGroup) updateTableName(table string) *libraryQaGroup { l.ALL = field.NewAsterisk(table) l.ID = field.NewInt64(table, "id") l.CreatedAt = field.NewInt64(table, "created_at") l.UpdatedAt = field.NewInt64(table, "updated_at") l.HashID = field.NewString(table, "hash_id") l.ProjectID = field.NewInt64(table, "project_id") l.Title = field.NewString(table, "title") l.DelTime = field.NewInt64(table, "del_time") l.fillFieldMap() return l } func (l *libraryQaGroup) WithContext(ctx context.Context) *libraryQaGroupDo { return l.libraryQaGroupDo.WithContext(ctx) } func (l libraryQaGroup) TableName() string { return l.libraryQaGroupDo.TableName() } func (l libraryQaGroup) Alias() string { return l.libraryQaGroupDo.Alias() } func (l *libraryQaGroup) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := l.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (l *libraryQaGroup) fillFieldMap() { l.fieldMap = make(map[string]field.Expr, 7) l.fieldMap["id"] = l.ID l.fieldMap["created_at"] = l.CreatedAt l.fieldMap["updated_at"] = l.UpdatedAt l.fieldMap["hash_id"] = l.HashID l.fieldMap["project_id"] = l.ProjectID l.fieldMap["title"] = l.Title l.fieldMap["del_time"] = l.DelTime } func (l libraryQaGroup) clone(db *gorm.DB) libraryQaGroup { l.libraryQaGroupDo.ReplaceConnPool(db.Statement.ConnPool) return l } func (l libraryQaGroup) replaceDB(db *gorm.DB) libraryQaGroup { l.libraryQaGroupDo.ReplaceDB(db) return l } type libraryQaGroupDo struct{ gen.DO } func (l libraryQaGroupDo) Debug() *libraryQaGroupDo { return l.withDO(l.DO.Debug()) } func (l libraryQaGroupDo) WithContext(ctx context.Context) *libraryQaGroupDo { return l.withDO(l.DO.WithContext(ctx)) } func (l libraryQaGroupDo) ReadDB() *libraryQaGroupDo { return l.Clauses(dbresolver.Read) } func (l libraryQaGroupDo) WriteDB() *libraryQaGroupDo { return l.Clauses(dbresolver.Write) } func (l libraryQaGroupDo) Session(config *gorm.Session) *libraryQaGroupDo { return l.withDO(l.DO.Session(config)) } func (l libraryQaGroupDo) Clauses(conds ...clause.Expression) *libraryQaGroupDo { return l.withDO(l.DO.Clauses(conds...)) } func (l libraryQaGroupDo) Returning(value interface{}, columns ...string) *libraryQaGroupDo { return l.withDO(l.DO.Returning(value, columns...)) } func (l libraryQaGroupDo) Not(conds ...gen.Condition) *libraryQaGroupDo { return l.withDO(l.DO.Not(conds...)) } func (l libraryQaGroupDo) Or(conds ...gen.Condition) *libraryQaGroupDo { return l.withDO(l.DO.Or(conds...)) } func (l libraryQaGroupDo) Select(conds ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Select(conds...)) } func (l libraryQaGroupDo) Where(conds ...gen.Condition) *libraryQaGroupDo { return l.withDO(l.DO.Where(conds...)) } func (l libraryQaGroupDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *libraryQaGroupDo { return l.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (l libraryQaGroupDo) Order(conds ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Order(conds...)) } func (l libraryQaGroupDo) Distinct(cols ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Distinct(cols...)) } func (l libraryQaGroupDo) Omit(cols ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Omit(cols...)) } func (l libraryQaGroupDo) Join(table schema.Tabler, on ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Join(table, on...)) } func (l libraryQaGroupDo) LeftJoin(table schema.Tabler, on ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.LeftJoin(table, on...)) } func (l libraryQaGroupDo) RightJoin(table schema.Tabler, on ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.RightJoin(table, on...)) } func (l libraryQaGroupDo) Group(cols ...field.Expr) *libraryQaGroupDo { return l.withDO(l.DO.Group(cols...)) } func (l libraryQaGroupDo) Having(conds ...gen.Condition) *libraryQaGroupDo { return l.withDO(l.DO.Having(conds...)) } func (l libraryQaGroupDo) Limit(limit int) *libraryQaGroupDo { return l.withDO(l.DO.Limit(limit)) } func (l libraryQaGroupDo) Offset(offset int) *libraryQaGroupDo { return l.withDO(l.DO.Offset(offset)) } func (l libraryQaGroupDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *libraryQaGroupDo { return l.withDO(l.DO.Scopes(funcs...)) } func (l libraryQaGroupDo) Unscoped() *libraryQaGroupDo { return l.withDO(l.DO.Unscoped()) } func (l libraryQaGroupDo) Create(values ...*model.LibraryQaGroup) error { if len(values) == 0 { return nil } return l.DO.Create(values) } func (l libraryQaGroupDo) CreateInBatches(values []*model.LibraryQaGroup, batchSize int) error { return l.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 (l libraryQaGroupDo) Save(values ...*model.LibraryQaGroup) error { if len(values) == 0 { return nil } return l.DO.Save(values) } func (l libraryQaGroupDo) First() (*model.LibraryQaGroup, error) { if result, err := l.DO.First(); err != nil { return nil, err } else { return result.(*model.LibraryQaGroup), nil } } func (l libraryQaGroupDo) Take() (*model.LibraryQaGroup, error) { if result, err := l.DO.Take(); err != nil { return nil, err } else { return result.(*model.LibraryQaGroup), nil } } func (l libraryQaGroupDo) Last() (*model.LibraryQaGroup, error) { if result, err := l.DO.Last(); err != nil { return nil, err } else { return result.(*model.LibraryQaGroup), nil } } func (l libraryQaGroupDo) Find() ([]*model.LibraryQaGroup, error) { result, err := l.DO.Find() return result.([]*model.LibraryQaGroup), err } func (l libraryQaGroupDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.LibraryQaGroup, err error) { buf := make([]*model.LibraryQaGroup, 0, batchSize) err = l.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 (l libraryQaGroupDo) FindInBatches(result *[]*model.LibraryQaGroup, batchSize int, fc func(tx gen.Dao, batch int) error) error { return l.DO.FindInBatches(result, batchSize, fc) } func (l libraryQaGroupDo) Attrs(attrs ...field.AssignExpr) *libraryQaGroupDo { return l.withDO(l.DO.Attrs(attrs...)) } func (l libraryQaGroupDo) Assign(attrs ...field.AssignExpr) *libraryQaGroupDo { return l.withDO(l.DO.Assign(attrs...)) } func (l libraryQaGroupDo) Joins(fields ...field.RelationField) *libraryQaGroupDo { for _, _f := range fields { l = *l.withDO(l.DO.Joins(_f)) } return &l } func (l libraryQaGroupDo) Preload(fields ...field.RelationField) *libraryQaGroupDo { for _, _f := range fields { l = *l.withDO(l.DO.Preload(_f)) } return &l } func (l libraryQaGroupDo) FirstOrInit() (*model.LibraryQaGroup, error) { if result, err := l.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.LibraryQaGroup), nil } } func (l libraryQaGroupDo) FirstOrCreate() (*model.LibraryQaGroup, error) { if result, err := l.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.LibraryQaGroup), nil } } func (l libraryQaGroupDo) FindByPage(offset int, limit int) (result []*model.LibraryQaGroup, count int64, err error) { result, err = l.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 = l.Offset(-1).Limit(-1).Count() return } func (l libraryQaGroupDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = l.Count() if err != nil { return } err = l.Offset(offset).Limit(limit).Scan(result) return } func (l libraryQaGroupDo) Scan(result interface{}) (err error) { return l.DO.Scan(result) } func (l libraryQaGroupDo) Delete(models ...*model.LibraryQaGroup) (result gen.ResultInfo, err error) { return l.DO.Delete(models) } func (l *libraryQaGroupDo) withDO(do gen.Dao) *libraryQaGroupDo { l.DO = *do.(*gen.DO) return l }