// 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" "gorm.io/gorm" "gorm.io/gorm/clause" "gorm.io/gorm/schema" "gorm.io/gen" "gorm.io/gen/field" "gorm.io/plugin/dbresolver" "gadmin/internal/gorm/model" ) func newServerOption(db *gorm.DB, opts ...gen.DOOption) serverOption { _serverOption := serverOption{} _serverOption.serverOptionDo.UseDB(db, opts...) _serverOption.serverOptionDo.UseModel(&model.ServerOption{}) tableName := _serverOption.serverOptionDo.TableName() _serverOption.ALL = field.NewAsterisk(tableName) _serverOption.ID = field.NewInt64(tableName, "id") _serverOption.Name = field.NewString(tableName, "name") _serverOption.ServerID = field.NewInt32(tableName, "server_id") _serverOption.DbID = field.NewInt32(tableName, "db_id") _serverOption.fillFieldMap() return _serverOption } type serverOption struct { serverOptionDo ALL field.Asterisk ID field.Int64 Name field.String // 服务器名称 ServerID field.Int32 // 服务器ID DbID field.Int32 fieldMap map[string]field.Expr } func (s serverOption) Table(newTableName string) *serverOption { s.serverOptionDo.UseTable(newTableName) return s.updateTableName(newTableName) } func (s serverOption) As(alias string) *serverOption { s.serverOptionDo.DO = *(s.serverOptionDo.As(alias).(*gen.DO)) return s.updateTableName(alias) } func (s *serverOption) updateTableName(table string) *serverOption { s.ALL = field.NewAsterisk(table) s.ID = field.NewInt64(table, "id") s.Name = field.NewString(table, "name") s.ServerID = field.NewInt32(table, "server_id") s.DbID = field.NewInt32(table, "db_id") s.fillFieldMap() return s } func (s *serverOption) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := s.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (s *serverOption) fillFieldMap() { s.fieldMap = make(map[string]field.Expr, 4) s.fieldMap["id"] = s.ID s.fieldMap["name"] = s.Name s.fieldMap["server_id"] = s.ServerID s.fieldMap["db_id"] = s.DbID } func (s serverOption) clone(db *gorm.DB) serverOption { s.serverOptionDo.ReplaceConnPool(db.Statement.ConnPool) return s } func (s serverOption) replaceDB(db *gorm.DB) serverOption { s.serverOptionDo.ReplaceDB(db) return s } type serverOptionDo struct{ gen.DO } func (s serverOptionDo) Debug() *serverOptionDo { return s.withDO(s.DO.Debug()) } func (s serverOptionDo) WithContext(ctx context.Context) *serverOptionDo { return s.withDO(s.DO.WithContext(ctx)) } func (s serverOptionDo) ReadDB() *serverOptionDo { return s.Clauses(dbresolver.Read) } func (s serverOptionDo) WriteDB() *serverOptionDo { return s.Clauses(dbresolver.Write) } func (s serverOptionDo) Session(config *gorm.Session) *serverOptionDo { return s.withDO(s.DO.Session(config)) } func (s serverOptionDo) Clauses(conds ...clause.Expression) *serverOptionDo { return s.withDO(s.DO.Clauses(conds...)) } func (s serverOptionDo) Returning(value interface{}, columns ...string) *serverOptionDo { return s.withDO(s.DO.Returning(value, columns...)) } func (s serverOptionDo) Not(conds ...gen.Condition) *serverOptionDo { return s.withDO(s.DO.Not(conds...)) } func (s serverOptionDo) Or(conds ...gen.Condition) *serverOptionDo { return s.withDO(s.DO.Or(conds...)) } func (s serverOptionDo) Select(conds ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Select(conds...)) } func (s serverOptionDo) Where(conds ...gen.Condition) *serverOptionDo { return s.withDO(s.DO.Where(conds...)) } func (s serverOptionDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *serverOptionDo { return s.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (s serverOptionDo) Order(conds ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Order(conds...)) } func (s serverOptionDo) Distinct(cols ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Distinct(cols...)) } func (s serverOptionDo) Omit(cols ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Omit(cols...)) } func (s serverOptionDo) Join(table schema.Tabler, on ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Join(table, on...)) } func (s serverOptionDo) LeftJoin(table schema.Tabler, on ...field.Expr) *serverOptionDo { return s.withDO(s.DO.LeftJoin(table, on...)) } func (s serverOptionDo) RightJoin(table schema.Tabler, on ...field.Expr) *serverOptionDo { return s.withDO(s.DO.RightJoin(table, on...)) } func (s serverOptionDo) Group(cols ...field.Expr) *serverOptionDo { return s.withDO(s.DO.Group(cols...)) } func (s serverOptionDo) Having(conds ...gen.Condition) *serverOptionDo { return s.withDO(s.DO.Having(conds...)) } func (s serverOptionDo) Limit(limit int) *serverOptionDo { return s.withDO(s.DO.Limit(limit)) } func (s serverOptionDo) Offset(offset int) *serverOptionDo { return s.withDO(s.DO.Offset(offset)) } func (s serverOptionDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *serverOptionDo { return s.withDO(s.DO.Scopes(funcs...)) } func (s serverOptionDo) Unscoped() *serverOptionDo { return s.withDO(s.DO.Unscoped()) } func (s serverOptionDo) Create(values ...*model.ServerOption) error { if len(values) == 0 { return nil } return s.DO.Create(values) } func (s serverOptionDo) CreateInBatches(values []*model.ServerOption, batchSize int) error { return s.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 (s serverOptionDo) Save(values ...*model.ServerOption) error { if len(values) == 0 { return nil } return s.DO.Save(values) } func (s serverOptionDo) First() (*model.ServerOption, error) { if result, err := s.DO.First(); err != nil { return nil, err } else { return result.(*model.ServerOption), nil } } func (s serverOptionDo) Take() (*model.ServerOption, error) { if result, err := s.DO.Take(); err != nil { return nil, err } else { return result.(*model.ServerOption), nil } } func (s serverOptionDo) Last() (*model.ServerOption, error) { if result, err := s.DO.Last(); err != nil { return nil, err } else { return result.(*model.ServerOption), nil } } func (s serverOptionDo) Find() ([]*model.ServerOption, error) { result, err := s.DO.Find() return result.([]*model.ServerOption), err } func (s serverOptionDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ServerOption, err error) { buf := make([]*model.ServerOption, 0, batchSize) err = s.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 (s serverOptionDo) FindInBatches(result *[]*model.ServerOption, batchSize int, fc func(tx gen.Dao, batch int) error) error { return s.DO.FindInBatches(result, batchSize, fc) } func (s serverOptionDo) Attrs(attrs ...field.AssignExpr) *serverOptionDo { return s.withDO(s.DO.Attrs(attrs...)) } func (s serverOptionDo) Assign(attrs ...field.AssignExpr) *serverOptionDo { return s.withDO(s.DO.Assign(attrs...)) } func (s serverOptionDo) Joins(fields ...field.RelationField) *serverOptionDo { for _, _f := range fields { s = *s.withDO(s.DO.Joins(_f)) } return &s } func (s serverOptionDo) Preload(fields ...field.RelationField) *serverOptionDo { for _, _f := range fields { s = *s.withDO(s.DO.Preload(_f)) } return &s } func (s serverOptionDo) FirstOrInit() (*model.ServerOption, error) { if result, err := s.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.ServerOption), nil } } func (s serverOptionDo) FirstOrCreate() (*model.ServerOption, error) { if result, err := s.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.ServerOption), nil } } func (s serverOptionDo) FindByPage(offset int, limit int) (result []*model.ServerOption, count int64, err error) { result, err = s.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 = s.Offset(-1).Limit(-1).Count() return } func (s serverOptionDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = s.Count() if err != nil { return } err = s.Offset(offset).Limit(limit).Scan(result) return } func (s serverOptionDo) Scan(result interface{}) (err error) { return s.DO.Scan(result) } func (s serverOptionDo) Delete(models ...*model.ServerOption) (result gen.ResultInfo, err error) { return s.DO.Delete(models) } func (s *serverOptionDo) withDO(do gen.Dao) *serverOptionDo { s.DO = *do.(*gen.DO) return s }