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.
sonic/dal/log.gen.go

352 lines
8.3 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 dal
import (
"context"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/plugin/dbresolver"
"github.com/go-sonic/sonic/model/entity"
)
func newLog(db *gorm.DB, opts ...gen.DOOption) log {
_log := log{}
_log.logDo.UseDB(db, opts...)
_log.logDo.UseModel(&entity.Log{})
tableName := _log.logDo.TableName()
_log.ALL = field.NewAsterisk(tableName)
_log.ID = field.NewInt64(tableName, "id")
_log.CreateTime = field.NewTime(tableName, "create_time")
_log.UpdateTime = field.NewTime(tableName, "update_time")
_log.Content = field.NewString(tableName, "content")
_log.IPAddress = field.NewString(tableName, "ip_address")
_log.LogKey = field.NewString(tableName, "log_key")
_log.Type = field.NewField(tableName, "type")
_log.fillFieldMap()
return _log
}
type log struct {
logDo logDo
ALL field.Asterisk
ID field.Int64
CreateTime field.Time
UpdateTime field.Time
Content field.String
IPAddress field.String
LogKey field.String
Type field.Field
fieldMap map[string]field.Expr
}
func (l log) Table(newTableName string) *log {
l.logDo.UseTable(newTableName)
return l.updateTableName(newTableName)
}
func (l log) As(alias string) *log {
l.logDo.DO = *(l.logDo.As(alias).(*gen.DO))
return l.updateTableName(alias)
}
func (l *log) updateTableName(table string) *log {
l.ALL = field.NewAsterisk(table)
l.ID = field.NewInt64(table, "id")
l.CreateTime = field.NewTime(table, "create_time")
l.UpdateTime = field.NewTime(table, "update_time")
l.Content = field.NewString(table, "content")
l.IPAddress = field.NewString(table, "ip_address")
l.LogKey = field.NewString(table, "log_key")
l.Type = field.NewField(table, "type")
l.fillFieldMap()
return l
}
func (l *log) WithContext(ctx context.Context) *logDo { return l.logDo.WithContext(ctx) }
func (l log) TableName() string { return l.logDo.TableName() }
func (l log) Alias() string { return l.logDo.Alias() }
func (l *log) 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 *log) fillFieldMap() {
l.fieldMap = make(map[string]field.Expr, 7)
l.fieldMap["id"] = l.ID
l.fieldMap["create_time"] = l.CreateTime
l.fieldMap["update_time"] = l.UpdateTime
l.fieldMap["content"] = l.Content
l.fieldMap["ip_address"] = l.IPAddress
l.fieldMap["log_key"] = l.LogKey
l.fieldMap["type"] = l.Type
}
func (l log) clone(db *gorm.DB) log {
l.logDo.ReplaceConnPool(db.Statement.ConnPool)
return l
}
func (l log) replaceDB(db *gorm.DB) log {
l.logDo.ReplaceDB(db)
return l
}
type logDo struct{ gen.DO }
func (l logDo) Debug() *logDo {
return l.withDO(l.DO.Debug())
}
func (l logDo) WithContext(ctx context.Context) *logDo {
return l.withDO(l.DO.WithContext(ctx))
}
func (l logDo) ReadDB() *logDo {
return l.Clauses(dbresolver.Read)
}
func (l logDo) WriteDB() *logDo {
return l.Clauses(dbresolver.Write)
}
func (l logDo) Session(config *gorm.Session) *logDo {
return l.withDO(l.DO.Session(config))
}
func (l logDo) Clauses(conds ...clause.Expression) *logDo {
return l.withDO(l.DO.Clauses(conds...))
}
func (l logDo) Returning(value interface{}, columns ...string) *logDo {
return l.withDO(l.DO.Returning(value, columns...))
}
func (l logDo) Not(conds ...gen.Condition) *logDo {
return l.withDO(l.DO.Not(conds...))
}
func (l logDo) Or(conds ...gen.Condition) *logDo {
return l.withDO(l.DO.Or(conds...))
}
func (l logDo) Select(conds ...field.Expr) *logDo {
return l.withDO(l.DO.Select(conds...))
}
func (l logDo) Where(conds ...gen.Condition) *logDo {
return l.withDO(l.DO.Where(conds...))
}
func (l logDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *logDo {
return l.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
}
func (l logDo) Order(conds ...field.Expr) *logDo {
return l.withDO(l.DO.Order(conds...))
}
func (l logDo) Distinct(cols ...field.Expr) *logDo {
return l.withDO(l.DO.Distinct(cols...))
}
func (l logDo) Omit(cols ...field.Expr) *logDo {
return l.withDO(l.DO.Omit(cols...))
}
func (l logDo) Join(table schema.Tabler, on ...field.Expr) *logDo {
return l.withDO(l.DO.Join(table, on...))
}
func (l logDo) LeftJoin(table schema.Tabler, on ...field.Expr) *logDo {
return l.withDO(l.DO.LeftJoin(table, on...))
}
func (l logDo) RightJoin(table schema.Tabler, on ...field.Expr) *logDo {
return l.withDO(l.DO.RightJoin(table, on...))
}
func (l logDo) Group(cols ...field.Expr) *logDo {
return l.withDO(l.DO.Group(cols...))
}
func (l logDo) Having(conds ...gen.Condition) *logDo {
return l.withDO(l.DO.Having(conds...))
}
func (l logDo) Limit(limit int) *logDo {
return l.withDO(l.DO.Limit(limit))
}
func (l logDo) Offset(offset int) *logDo {
return l.withDO(l.DO.Offset(offset))
}
func (l logDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *logDo {
return l.withDO(l.DO.Scopes(funcs...))
}
func (l logDo) Unscoped() *logDo {
return l.withDO(l.DO.Unscoped())
}
func (l logDo) Create(values ...*entity.Log) error {
if len(values) == 0 {
return nil
}
return l.DO.Create(values)
}
func (l logDo) CreateInBatches(values []*entity.Log, 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 logDo) Save(values ...*entity.Log) error {
if len(values) == 0 {
return nil
}
return l.DO.Save(values)
}
func (l logDo) First() (*entity.Log, error) {
if result, err := l.DO.First(); err != nil {
return nil, err
} else {
return result.(*entity.Log), nil
}
}
func (l logDo) Take() (*entity.Log, error) {
if result, err := l.DO.Take(); err != nil {
return nil, err
} else {
return result.(*entity.Log), nil
}
}
func (l logDo) Last() (*entity.Log, error) {
if result, err := l.DO.Last(); err != nil {
return nil, err
} else {
return result.(*entity.Log), nil
}
}
func (l logDo) Find() ([]*entity.Log, error) {
result, err := l.DO.Find()
return result.([]*entity.Log), err
}
func (l logDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*entity.Log, err error) {
buf := make([]*entity.Log, 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 logDo) FindInBatches(result *[]*entity.Log, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return l.DO.FindInBatches(result, batchSize, fc)
}
func (l logDo) Attrs(attrs ...field.AssignExpr) *logDo {
return l.withDO(l.DO.Attrs(attrs...))
}
func (l logDo) Assign(attrs ...field.AssignExpr) *logDo {
return l.withDO(l.DO.Assign(attrs...))
}
func (l logDo) Joins(fields ...field.RelationField) *logDo {
for _, _f := range fields {
l = *l.withDO(l.DO.Joins(_f))
}
return &l
}
func (l logDo) Preload(fields ...field.RelationField) *logDo {
for _, _f := range fields {
l = *l.withDO(l.DO.Preload(_f))
}
return &l
}
func (l logDo) FirstOrInit() (*entity.Log, error) {
if result, err := l.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*entity.Log), nil
}
}
func (l logDo) FirstOrCreate() (*entity.Log, error) {
if result, err := l.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*entity.Log), nil
}
}
func (l logDo) FindByPage(offset int, limit int) (result []*entity.Log, 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 logDo) 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 logDo) Scan(result interface{}) (err error) {
return l.DO.Scan(result)
}
func (l logDo) Delete(models ...*entity.Log) (result gen.ResultInfo, err error) {
return l.DO.Delete(models)
}
func (l *logDo) withDO(do gen.Dao) *logDo {
l.DO = *do.(*gen.DO)
return l
}