123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- // 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 newDisconnectLog(db *gorm.DB, opts ...gen.DOOption) disconnectLog {
- _disconnectLog := disconnectLog{}
- _disconnectLog.disconnectLogDo.UseDB(db, opts...)
- _disconnectLog.disconnectLogDo.UseModel(&model.DisconnectLog{})
- tableName := _disconnectLog.disconnectLogDo.TableName()
- _disconnectLog.ALL = field.NewAsterisk(tableName)
- _disconnectLog.ID = field.NewInt64(tableName, "id")
- _disconnectLog.Userid = field.NewInt64(tableName, "userid")
- _disconnectLog.ServerID = field.NewInt32(tableName, "server_id")
- _disconnectLog.EventID = field.NewInt32(tableName, "event_id")
- _disconnectLog.UserCreatedAt = field.NewInt32(tableName, "user_created_at")
- _disconnectLog.Scene = field.NewString(tableName, "scene")
- _disconnectLog.NetType = field.NewInt64(tableName, "net_type")
- _disconnectLog.SignalStrength = field.NewInt64(tableName, "signal_strength")
- _disconnectLog.Time = field.NewInt64(tableName, "time")
- _disconnectLog.Date = field.NewString(tableName, "date")
- _disconnectLog.EventAt = field.NewInt32(tableName, "event_at")
- _disconnectLog.EventAtNs = field.NewInt64(tableName, "event_at_ns")
- _disconnectLog.fillFieldMap()
- return _disconnectLog
- }
- type disconnectLog struct {
- disconnectLogDo
- ALL field.Asterisk
- ID field.Int64
- Userid field.Int64 // 用户ID
- ServerID field.Int32 // 服务器ID
- EventID field.Int32 // 事件ID
- UserCreatedAt field.Int32 // 用户注册时间
- Scene field.String // 场景值
- NetType field.Int64 // 网络类型
- SignalStrength field.Int64 // 信号强度
- Time field.Int64 // 重连耗时
- Date field.String // 触发日期 2005-01-02
- EventAt field.Int32 // 触发时间戳
- EventAtNs field.Int64 // 发生时间ns
- fieldMap map[string]field.Expr
- }
- func (d disconnectLog) Table(newTableName string) *disconnectLog {
- d.disconnectLogDo.UseTable(newTableName)
- return d.updateTableName(newTableName)
- }
- func (d disconnectLog) As(alias string) *disconnectLog {
- d.disconnectLogDo.DO = *(d.disconnectLogDo.As(alias).(*gen.DO))
- return d.updateTableName(alias)
- }
- func (d *disconnectLog) updateTableName(table string) *disconnectLog {
- d.ALL = field.NewAsterisk(table)
- d.ID = field.NewInt64(table, "id")
- d.Userid = field.NewInt64(table, "userid")
- d.ServerID = field.NewInt32(table, "server_id")
- d.EventID = field.NewInt32(table, "event_id")
- d.UserCreatedAt = field.NewInt32(table, "user_created_at")
- d.Scene = field.NewString(table, "scene")
- d.NetType = field.NewInt64(table, "net_type")
- d.SignalStrength = field.NewInt64(table, "signal_strength")
- d.Time = field.NewInt64(table, "time")
- d.Date = field.NewString(table, "date")
- d.EventAt = field.NewInt32(table, "event_at")
- d.EventAtNs = field.NewInt64(table, "event_at_ns")
- d.fillFieldMap()
- return d
- }
- func (d *disconnectLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := d.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (d *disconnectLog) fillFieldMap() {
- d.fieldMap = make(map[string]field.Expr, 12)
- d.fieldMap["id"] = d.ID
- d.fieldMap["userid"] = d.Userid
- d.fieldMap["server_id"] = d.ServerID
- d.fieldMap["event_id"] = d.EventID
- d.fieldMap["user_created_at"] = d.UserCreatedAt
- d.fieldMap["scene"] = d.Scene
- d.fieldMap["net_type"] = d.NetType
- d.fieldMap["signal_strength"] = d.SignalStrength
- d.fieldMap["time"] = d.Time
- d.fieldMap["date"] = d.Date
- d.fieldMap["event_at"] = d.EventAt
- d.fieldMap["event_at_ns"] = d.EventAtNs
- }
- func (d disconnectLog) clone(db *gorm.DB) disconnectLog {
- d.disconnectLogDo.ReplaceConnPool(db.Statement.ConnPool)
- return d
- }
- func (d disconnectLog) replaceDB(db *gorm.DB) disconnectLog {
- d.disconnectLogDo.ReplaceDB(db)
- return d
- }
- type disconnectLogDo struct{ gen.DO }
- func (d disconnectLogDo) Debug() *disconnectLogDo {
- return d.withDO(d.DO.Debug())
- }
- func (d disconnectLogDo) WithContext(ctx context.Context) *disconnectLogDo {
- return d.withDO(d.DO.WithContext(ctx))
- }
- func (d disconnectLogDo) ReadDB() *disconnectLogDo {
- return d.Clauses(dbresolver.Read)
- }
- func (d disconnectLogDo) WriteDB() *disconnectLogDo {
- return d.Clauses(dbresolver.Write)
- }
- func (d disconnectLogDo) Session(config *gorm.Session) *disconnectLogDo {
- return d.withDO(d.DO.Session(config))
- }
- func (d disconnectLogDo) Clauses(conds ...clause.Expression) *disconnectLogDo {
- return d.withDO(d.DO.Clauses(conds...))
- }
- func (d disconnectLogDo) Returning(value interface{}, columns ...string) *disconnectLogDo {
- return d.withDO(d.DO.Returning(value, columns...))
- }
- func (d disconnectLogDo) Not(conds ...gen.Condition) *disconnectLogDo {
- return d.withDO(d.DO.Not(conds...))
- }
- func (d disconnectLogDo) Or(conds ...gen.Condition) *disconnectLogDo {
- return d.withDO(d.DO.Or(conds...))
- }
- func (d disconnectLogDo) Select(conds ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Select(conds...))
- }
- func (d disconnectLogDo) Where(conds ...gen.Condition) *disconnectLogDo {
- return d.withDO(d.DO.Where(conds...))
- }
- func (d disconnectLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *disconnectLogDo {
- return d.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (d disconnectLogDo) Order(conds ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Order(conds...))
- }
- func (d disconnectLogDo) Distinct(cols ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Distinct(cols...))
- }
- func (d disconnectLogDo) Omit(cols ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Omit(cols...))
- }
- func (d disconnectLogDo) Join(table schema.Tabler, on ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Join(table, on...))
- }
- func (d disconnectLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.LeftJoin(table, on...))
- }
- func (d disconnectLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.RightJoin(table, on...))
- }
- func (d disconnectLogDo) Group(cols ...field.Expr) *disconnectLogDo {
- return d.withDO(d.DO.Group(cols...))
- }
- func (d disconnectLogDo) Having(conds ...gen.Condition) *disconnectLogDo {
- return d.withDO(d.DO.Having(conds...))
- }
- func (d disconnectLogDo) Limit(limit int) *disconnectLogDo {
- return d.withDO(d.DO.Limit(limit))
- }
- func (d disconnectLogDo) Offset(offset int) *disconnectLogDo {
- return d.withDO(d.DO.Offset(offset))
- }
- func (d disconnectLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *disconnectLogDo {
- return d.withDO(d.DO.Scopes(funcs...))
- }
- func (d disconnectLogDo) Unscoped() *disconnectLogDo {
- return d.withDO(d.DO.Unscoped())
- }
- func (d disconnectLogDo) Create(values ...*model.DisconnectLog) error {
- if len(values) == 0 {
- return nil
- }
- return d.DO.Create(values)
- }
- func (d disconnectLogDo) CreateInBatches(values []*model.DisconnectLog, batchSize int) error {
- return d.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 (d disconnectLogDo) Save(values ...*model.DisconnectLog) error {
- if len(values) == 0 {
- return nil
- }
- return d.DO.Save(values)
- }
- func (d disconnectLogDo) First() (*model.DisconnectLog, error) {
- if result, err := d.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.DisconnectLog), nil
- }
- }
- func (d disconnectLogDo) Take() (*model.DisconnectLog, error) {
- if result, err := d.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.DisconnectLog), nil
- }
- }
- func (d disconnectLogDo) Last() (*model.DisconnectLog, error) {
- if result, err := d.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.DisconnectLog), nil
- }
- }
- func (d disconnectLogDo) Find() ([]*model.DisconnectLog, error) {
- result, err := d.DO.Find()
- return result.([]*model.DisconnectLog), err
- }
- func (d disconnectLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.DisconnectLog, err error) {
- buf := make([]*model.DisconnectLog, 0, batchSize)
- err = d.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 (d disconnectLogDo) FindInBatches(result *[]*model.DisconnectLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return d.DO.FindInBatches(result, batchSize, fc)
- }
- func (d disconnectLogDo) Attrs(attrs ...field.AssignExpr) *disconnectLogDo {
- return d.withDO(d.DO.Attrs(attrs...))
- }
- func (d disconnectLogDo) Assign(attrs ...field.AssignExpr) *disconnectLogDo {
- return d.withDO(d.DO.Assign(attrs...))
- }
- func (d disconnectLogDo) Joins(fields ...field.RelationField) *disconnectLogDo {
- for _, _f := range fields {
- d = *d.withDO(d.DO.Joins(_f))
- }
- return &d
- }
- func (d disconnectLogDo) Preload(fields ...field.RelationField) *disconnectLogDo {
- for _, _f := range fields {
- d = *d.withDO(d.DO.Preload(_f))
- }
- return &d
- }
- func (d disconnectLogDo) FirstOrInit() (*model.DisconnectLog, error) {
- if result, err := d.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.DisconnectLog), nil
- }
- }
- func (d disconnectLogDo) FirstOrCreate() (*model.DisconnectLog, error) {
- if result, err := d.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.DisconnectLog), nil
- }
- }
- func (d disconnectLogDo) FindByPage(offset int, limit int) (result []*model.DisconnectLog, count int64, err error) {
- result, err = d.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 = d.Offset(-1).Limit(-1).Count()
- return
- }
- func (d disconnectLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = d.Count()
- if err != nil {
- return
- }
- err = d.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (d disconnectLogDo) Scan(result interface{}) (err error) {
- return d.DO.Scan(result)
- }
- func (d disconnectLogDo) Delete(models ...*model.DisconnectLog) (result gen.ResultInfo, err error) {
- return d.DO.Delete(models)
- }
- func (d *disconnectLogDo) withDO(do gen.Dao) *disconnectLogDo {
- d.DO = *do.(*gen.DO)
- return d
- }
|