You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
336 lines
9.1 KiB
Go
336 lines
9.1 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 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 newServerWhitelist(db *gorm.DB, opts ...gen.DOOption) serverWhitelist {
|
|
_serverWhitelist := serverWhitelist{}
|
|
|
|
_serverWhitelist.serverWhitelistDo.UseDB(db, opts...)
|
|
_serverWhitelist.serverWhitelistDo.UseModel(&model.ServerWhitelist{})
|
|
|
|
tableName := _serverWhitelist.serverWhitelistDo.TableName()
|
|
_serverWhitelist.ALL = field.NewAsterisk(tableName)
|
|
_serverWhitelist.ID = field.NewInt64(tableName, "id")
|
|
_serverWhitelist.IP = field.NewString(tableName, "ip")
|
|
|
|
_serverWhitelist.fillFieldMap()
|
|
|
|
return _serverWhitelist
|
|
}
|
|
|
|
type serverWhitelist struct {
|
|
serverWhitelistDo serverWhitelistDo
|
|
|
|
ALL field.Asterisk
|
|
ID field.Int64
|
|
IP field.String
|
|
|
|
fieldMap map[string]field.Expr
|
|
}
|
|
|
|
func (s serverWhitelist) Table(newTableName string) *serverWhitelist {
|
|
s.serverWhitelistDo.UseTable(newTableName)
|
|
return s.updateTableName(newTableName)
|
|
}
|
|
|
|
func (s serverWhitelist) As(alias string) *serverWhitelist {
|
|
s.serverWhitelistDo.DO = *(s.serverWhitelistDo.As(alias).(*gen.DO))
|
|
return s.updateTableName(alias)
|
|
}
|
|
|
|
func (s *serverWhitelist) updateTableName(table string) *serverWhitelist {
|
|
s.ALL = field.NewAsterisk(table)
|
|
s.ID = field.NewInt64(table, "id")
|
|
s.IP = field.NewString(table, "ip")
|
|
|
|
s.fillFieldMap()
|
|
|
|
return s
|
|
}
|
|
|
|
func (s *serverWhitelist) WithContext(ctx context.Context) *serverWhitelistDo {
|
|
return s.serverWhitelistDo.WithContext(ctx)
|
|
}
|
|
|
|
func (s serverWhitelist) TableName() string { return s.serverWhitelistDo.TableName() }
|
|
|
|
func (s serverWhitelist) Alias() string { return s.serverWhitelistDo.Alias() }
|
|
|
|
func (s *serverWhitelist) 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 *serverWhitelist) fillFieldMap() {
|
|
s.fieldMap = make(map[string]field.Expr, 2)
|
|
s.fieldMap["id"] = s.ID
|
|
s.fieldMap["ip"] = s.IP
|
|
}
|
|
|
|
func (s serverWhitelist) clone(db *gorm.DB) serverWhitelist {
|
|
s.serverWhitelistDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
return s
|
|
}
|
|
|
|
func (s serverWhitelist) replaceDB(db *gorm.DB) serverWhitelist {
|
|
s.serverWhitelistDo.ReplaceDB(db)
|
|
return s
|
|
}
|
|
|
|
type serverWhitelistDo struct{ gen.DO }
|
|
|
|
func (s serverWhitelistDo) Debug() *serverWhitelistDo {
|
|
return s.withDO(s.DO.Debug())
|
|
}
|
|
|
|
func (s serverWhitelistDo) WithContext(ctx context.Context) *serverWhitelistDo {
|
|
return s.withDO(s.DO.WithContext(ctx))
|
|
}
|
|
|
|
func (s serverWhitelistDo) ReadDB() *serverWhitelistDo {
|
|
return s.Clauses(dbresolver.Read)
|
|
}
|
|
|
|
func (s serverWhitelistDo) WriteDB() *serverWhitelistDo {
|
|
return s.Clauses(dbresolver.Write)
|
|
}
|
|
|
|
func (s serverWhitelistDo) Session(config *gorm.Session) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Session(config))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Clauses(conds ...clause.Expression) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Clauses(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Returning(value interface{}, columns ...string) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Returning(value, columns...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Not(conds ...gen.Condition) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Not(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Or(conds ...gen.Condition) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Or(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Select(conds ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Select(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Where(conds ...gen.Condition) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Where(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *serverWhitelistDo {
|
|
return s.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Order(conds ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Order(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Distinct(cols ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Distinct(cols...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Omit(cols ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Omit(cols...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Join(table schema.Tabler, on ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Join(table, on...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) LeftJoin(table schema.Tabler, on ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.LeftJoin(table, on...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) RightJoin(table schema.Tabler, on ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.RightJoin(table, on...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Group(cols ...field.Expr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Group(cols...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Having(conds ...gen.Condition) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Having(conds...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Limit(limit int) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Limit(limit))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Offset(offset int) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Offset(offset))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Scopes(funcs...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Unscoped() *serverWhitelistDo {
|
|
return s.withDO(s.DO.Unscoped())
|
|
}
|
|
|
|
func (s serverWhitelistDo) Create(values ...*model.ServerWhitelist) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Create(values)
|
|
}
|
|
|
|
func (s serverWhitelistDo) CreateInBatches(values []*model.ServerWhitelist, 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 serverWhitelistDo) Save(values ...*model.ServerWhitelist) error {
|
|
if len(values) == 0 {
|
|
return nil
|
|
}
|
|
return s.DO.Save(values)
|
|
}
|
|
|
|
func (s serverWhitelistDo) First() (*model.ServerWhitelist, error) {
|
|
if result, err := s.DO.First(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ServerWhitelist), nil
|
|
}
|
|
}
|
|
|
|
func (s serverWhitelistDo) Take() (*model.ServerWhitelist, error) {
|
|
if result, err := s.DO.Take(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ServerWhitelist), nil
|
|
}
|
|
}
|
|
|
|
func (s serverWhitelistDo) Last() (*model.ServerWhitelist, error) {
|
|
if result, err := s.DO.Last(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ServerWhitelist), nil
|
|
}
|
|
}
|
|
|
|
func (s serverWhitelistDo) Find() ([]*model.ServerWhitelist, error) {
|
|
result, err := s.DO.Find()
|
|
return result.([]*model.ServerWhitelist), err
|
|
}
|
|
|
|
func (s serverWhitelistDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ServerWhitelist, err error) {
|
|
buf := make([]*model.ServerWhitelist, 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 serverWhitelistDo) FindInBatches(result *[]*model.ServerWhitelist, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
return s.DO.FindInBatches(result, batchSize, fc)
|
|
}
|
|
|
|
func (s serverWhitelistDo) Attrs(attrs ...field.AssignExpr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Attrs(attrs...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Assign(attrs ...field.AssignExpr) *serverWhitelistDo {
|
|
return s.withDO(s.DO.Assign(attrs...))
|
|
}
|
|
|
|
func (s serverWhitelistDo) Joins(fields ...field.RelationField) *serverWhitelistDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Joins(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s serverWhitelistDo) Preload(fields ...field.RelationField) *serverWhitelistDo {
|
|
for _, _f := range fields {
|
|
s = *s.withDO(s.DO.Preload(_f))
|
|
}
|
|
return &s
|
|
}
|
|
|
|
func (s serverWhitelistDo) FirstOrInit() (*model.ServerWhitelist, error) {
|
|
if result, err := s.DO.FirstOrInit(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ServerWhitelist), nil
|
|
}
|
|
}
|
|
|
|
func (s serverWhitelistDo) FirstOrCreate() (*model.ServerWhitelist, error) {
|
|
if result, err := s.DO.FirstOrCreate(); err != nil {
|
|
return nil, err
|
|
} else {
|
|
return result.(*model.ServerWhitelist), nil
|
|
}
|
|
}
|
|
|
|
func (s serverWhitelistDo) FindByPage(offset int, limit int) (result []*model.ServerWhitelist, 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 serverWhitelistDo) 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 serverWhitelistDo) Scan(result interface{}) (err error) {
|
|
return s.DO.Scan(result)
|
|
}
|
|
|
|
func (s serverWhitelistDo) Delete(models ...*model.ServerWhitelist) (result gen.ResultInfo, err error) {
|
|
return s.DO.Delete(models)
|
|
}
|
|
|
|
func (s *serverWhitelistDo) withDO(do gen.Dao) *serverWhitelistDo {
|
|
s.DO = *do.(*gen.DO)
|
|
return s
|
|
}
|