123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- // 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 newBossLog(db *gorm.DB, opts ...gen.DOOption) bossLog {
- _bossLog := bossLog{}
- _bossLog.bossLogDo.UseDB(db, opts...)
- _bossLog.bossLogDo.UseModel(&model.BossLog{})
- tableName := _bossLog.bossLogDo.TableName()
- _bossLog.ALL = field.NewAsterisk(tableName)
- _bossLog.ID = field.NewInt64(tableName, "id")
- _bossLog.UserID = field.NewInt64(tableName, "user_id")
- _bossLog.ServerID = field.NewInt32(tableName, "server_id")
- _bossLog.EventID = field.NewInt32(tableName, "event_id")
- _bossLog.Time = field.NewInt64(tableName, "time")
- _bossLog.Goods = field.NewString(tableName, "goods")
- _bossLog.Date = field.NewString(tableName, "date")
- _bossLog.EventAt = field.NewInt32(tableName, "event_at")
- _bossLog.EventAtNs = field.NewInt64(tableName, "event_at_ns")
- _bossLog.fillFieldMap()
- return _bossLog
- }
- type bossLog struct {
- bossLogDo
- ALL field.Asterisk
- ID field.Int64
- UserID field.Int64 // 用户ID
- ServerID field.Int32 // 服务器ID
- EventID field.Int32 // 事件ID
- Time field.Int64 // 战斗时长
- Goods field.String // {id,count}—{物品id,物品数量}
- Date field.String // 触发日期 2005-01-02
- EventAt field.Int32 // 触发时间戳
- EventAtNs field.Int64 // 发生时间ns
- fieldMap map[string]field.Expr
- }
- func (b bossLog) Table(newTableName string) *bossLog {
- b.bossLogDo.UseTable(newTableName)
- return b.updateTableName(newTableName)
- }
- func (b bossLog) As(alias string) *bossLog {
- b.bossLogDo.DO = *(b.bossLogDo.As(alias).(*gen.DO))
- return b.updateTableName(alias)
- }
- func (b *bossLog) updateTableName(table string) *bossLog {
- b.ALL = field.NewAsterisk(table)
- b.ID = field.NewInt64(table, "id")
- b.UserID = field.NewInt64(table, "user_id")
- b.ServerID = field.NewInt32(table, "server_id")
- b.EventID = field.NewInt32(table, "event_id")
- b.Time = field.NewInt64(table, "time")
- b.Goods = field.NewString(table, "goods")
- b.Date = field.NewString(table, "date")
- b.EventAt = field.NewInt32(table, "event_at")
- b.EventAtNs = field.NewInt64(table, "event_at_ns")
- b.fillFieldMap()
- return b
- }
- func (b *bossLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := b.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (b *bossLog) fillFieldMap() {
- b.fieldMap = make(map[string]field.Expr, 9)
- b.fieldMap["id"] = b.ID
- b.fieldMap["user_id"] = b.UserID
- b.fieldMap["server_id"] = b.ServerID
- b.fieldMap["event_id"] = b.EventID
- b.fieldMap["time"] = b.Time
- b.fieldMap["goods"] = b.Goods
- b.fieldMap["date"] = b.Date
- b.fieldMap["event_at"] = b.EventAt
- b.fieldMap["event_at_ns"] = b.EventAtNs
- }
- func (b bossLog) clone(db *gorm.DB) bossLog {
- b.bossLogDo.ReplaceConnPool(db.Statement.ConnPool)
- return b
- }
- func (b bossLog) replaceDB(db *gorm.DB) bossLog {
- b.bossLogDo.ReplaceDB(db)
- return b
- }
- type bossLogDo struct{ gen.DO }
- func (b bossLogDo) Debug() *bossLogDo {
- return b.withDO(b.DO.Debug())
- }
- func (b bossLogDo) WithContext(ctx context.Context) *bossLogDo {
- return b.withDO(b.DO.WithContext(ctx))
- }
- func (b bossLogDo) ReadDB() *bossLogDo {
- return b.Clauses(dbresolver.Read)
- }
- func (b bossLogDo) WriteDB() *bossLogDo {
- return b.Clauses(dbresolver.Write)
- }
- func (b bossLogDo) Session(config *gorm.Session) *bossLogDo {
- return b.withDO(b.DO.Session(config))
- }
- func (b bossLogDo) Clauses(conds ...clause.Expression) *bossLogDo {
- return b.withDO(b.DO.Clauses(conds...))
- }
- func (b bossLogDo) Returning(value interface{}, columns ...string) *bossLogDo {
- return b.withDO(b.DO.Returning(value, columns...))
- }
- func (b bossLogDo) Not(conds ...gen.Condition) *bossLogDo {
- return b.withDO(b.DO.Not(conds...))
- }
- func (b bossLogDo) Or(conds ...gen.Condition) *bossLogDo {
- return b.withDO(b.DO.Or(conds...))
- }
- func (b bossLogDo) Select(conds ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Select(conds...))
- }
- func (b bossLogDo) Where(conds ...gen.Condition) *bossLogDo {
- return b.withDO(b.DO.Where(conds...))
- }
- func (b bossLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *bossLogDo {
- return b.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (b bossLogDo) Order(conds ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Order(conds...))
- }
- func (b bossLogDo) Distinct(cols ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Distinct(cols...))
- }
- func (b bossLogDo) Omit(cols ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Omit(cols...))
- }
- func (b bossLogDo) Join(table schema.Tabler, on ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Join(table, on...))
- }
- func (b bossLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.LeftJoin(table, on...))
- }
- func (b bossLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.RightJoin(table, on...))
- }
- func (b bossLogDo) Group(cols ...field.Expr) *bossLogDo {
- return b.withDO(b.DO.Group(cols...))
- }
- func (b bossLogDo) Having(conds ...gen.Condition) *bossLogDo {
- return b.withDO(b.DO.Having(conds...))
- }
- func (b bossLogDo) Limit(limit int) *bossLogDo {
- return b.withDO(b.DO.Limit(limit))
- }
- func (b bossLogDo) Offset(offset int) *bossLogDo {
- return b.withDO(b.DO.Offset(offset))
- }
- func (b bossLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *bossLogDo {
- return b.withDO(b.DO.Scopes(funcs...))
- }
- func (b bossLogDo) Unscoped() *bossLogDo {
- return b.withDO(b.DO.Unscoped())
- }
- func (b bossLogDo) Create(values ...*model.BossLog) error {
- if len(values) == 0 {
- return nil
- }
- return b.DO.Create(values)
- }
- func (b bossLogDo) CreateInBatches(values []*model.BossLog, batchSize int) error {
- return b.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 (b bossLogDo) Save(values ...*model.BossLog) error {
- if len(values) == 0 {
- return nil
- }
- return b.DO.Save(values)
- }
- func (b bossLogDo) First() (*model.BossLog, error) {
- if result, err := b.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.BossLog), nil
- }
- }
- func (b bossLogDo) Take() (*model.BossLog, error) {
- if result, err := b.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.BossLog), nil
- }
- }
- func (b bossLogDo) Last() (*model.BossLog, error) {
- if result, err := b.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.BossLog), nil
- }
- }
- func (b bossLogDo) Find() ([]*model.BossLog, error) {
- result, err := b.DO.Find()
- return result.([]*model.BossLog), err
- }
- func (b bossLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BossLog, err error) {
- buf := make([]*model.BossLog, 0, batchSize)
- err = b.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 (b bossLogDo) FindInBatches(result *[]*model.BossLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return b.DO.FindInBatches(result, batchSize, fc)
- }
- func (b bossLogDo) Attrs(attrs ...field.AssignExpr) *bossLogDo {
- return b.withDO(b.DO.Attrs(attrs...))
- }
- func (b bossLogDo) Assign(attrs ...field.AssignExpr) *bossLogDo {
- return b.withDO(b.DO.Assign(attrs...))
- }
- func (b bossLogDo) Joins(fields ...field.RelationField) *bossLogDo {
- for _, _f := range fields {
- b = *b.withDO(b.DO.Joins(_f))
- }
- return &b
- }
- func (b bossLogDo) Preload(fields ...field.RelationField) *bossLogDo {
- for _, _f := range fields {
- b = *b.withDO(b.DO.Preload(_f))
- }
- return &b
- }
- func (b bossLogDo) FirstOrInit() (*model.BossLog, error) {
- if result, err := b.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.BossLog), nil
- }
- }
- func (b bossLogDo) FirstOrCreate() (*model.BossLog, error) {
- if result, err := b.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.BossLog), nil
- }
- }
- func (b bossLogDo) FindByPage(offset int, limit int) (result []*model.BossLog, count int64, err error) {
- result, err = b.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 = b.Offset(-1).Limit(-1).Count()
- return
- }
- func (b bossLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = b.Count()
- if err != nil {
- return
- }
- err = b.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (b bossLogDo) Scan(result interface{}) (err error) {
- return b.DO.Scan(result)
- }
- func (b bossLogDo) Delete(models ...*model.BossLog) (result gen.ResultInfo, err error) {
- return b.DO.Delete(models)
- }
- func (b *bossLogDo) withDO(do gen.Dao) *bossLogDo {
- b.DO = *do.(*gen.DO)
- return b
- }
|