|
@@ -0,0 +1,373 @@
|
|
|
|
+// 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"
|
|
|
|
+
|
|
|
|
+ "sparkteam-dash/orm/model"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+func newBattleLog(db *gorm.DB, opts ...gen.DOOption) battleLog {
|
|
|
|
+ _battleLog := battleLog{}
|
|
|
|
+
|
|
|
|
+ _battleLog.battleLogDo.UseDB(db, opts...)
|
|
|
|
+ _battleLog.battleLogDo.UseModel(&model.BattleLog{})
|
|
|
|
+
|
|
|
|
+ tableName := _battleLog.battleLogDo.TableName()
|
|
|
|
+ _battleLog.ALL = field.NewAsterisk(tableName)
|
|
|
|
+ _battleLog.ID = field.NewInt64(tableName, "id")
|
|
|
|
+ _battleLog.ChapterID = field.NewInt32(tableName, "chapter_id")
|
|
|
|
+ _battleLog.Wave = field.NewInt32(tableName, "wave")
|
|
|
|
+ _battleLog.PlayerID = field.NewInt64(tableName, "player_id")
|
|
|
|
+ _battleLog.BattleTime = field.NewInt32(tableName, "battle_time")
|
|
|
|
+ _battleLog.BattleResult = field.NewInt32(tableName, "battle_result")
|
|
|
|
+ _battleLog.IsNew = field.NewInt32(tableName, "is_new")
|
|
|
|
+ _battleLog.EventTime = field.NewTime(tableName, "event_time")
|
|
|
|
+ _battleLog.EventDay = field.NewTime(tableName, "event_day")
|
|
|
|
+ _battleLog.Channel = field.NewString(tableName, "channel")
|
|
|
|
+ _battleLog.IsRevive = field.NewInt32(tableName, "is_revive")
|
|
|
|
+ _battleLog.ReviveWave = field.NewInt32(tableName, "revive_wave")
|
|
|
|
+
|
|
|
|
+ _battleLog.fillFieldMap()
|
|
|
|
+
|
|
|
|
+ return _battleLog
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type battleLog struct {
|
|
|
|
+ battleLogDo battleLogDo
|
|
|
|
+
|
|
|
|
+ ALL field.Asterisk
|
|
|
|
+ ID field.Int64
|
|
|
|
+ ChapterID field.Int32
|
|
|
|
+ Wave field.Int32
|
|
|
|
+ PlayerID field.Int64
|
|
|
|
+ BattleTime field.Int32
|
|
|
|
+ BattleResult field.Int32 // 战斗结果 0未通关 1通关
|
|
|
|
+ IsNew field.Int32
|
|
|
|
+ EventTime field.Time
|
|
|
|
+ EventDay field.Time
|
|
|
|
+ Channel field.String
|
|
|
|
+ IsRevive field.Int32 // 是否使用复活 0未使用 1使用
|
|
|
|
+ ReviveWave field.Int32 // 在那一波复活
|
|
|
|
+
|
|
|
|
+ fieldMap map[string]field.Expr
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLog) Table(newTableName string) *battleLog {
|
|
|
|
+ b.battleLogDo.UseTable(newTableName)
|
|
|
|
+ return b.updateTableName(newTableName)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLog) As(alias string) *battleLog {
|
|
|
|
+ b.battleLogDo.DO = *(b.battleLogDo.As(alias).(*gen.DO))
|
|
|
|
+ return b.updateTableName(alias)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b *battleLog) updateTableName(table string) *battleLog {
|
|
|
|
+ b.ALL = field.NewAsterisk(table)
|
|
|
|
+ b.ID = field.NewInt64(table, "id")
|
|
|
|
+ b.ChapterID = field.NewInt32(table, "chapter_id")
|
|
|
|
+ b.Wave = field.NewInt32(table, "wave")
|
|
|
|
+ b.PlayerID = field.NewInt64(table, "player_id")
|
|
|
|
+ b.BattleTime = field.NewInt32(table, "battle_time")
|
|
|
|
+ b.BattleResult = field.NewInt32(table, "battle_result")
|
|
|
|
+ b.IsNew = field.NewInt32(table, "is_new")
|
|
|
|
+ b.EventTime = field.NewTime(table, "event_time")
|
|
|
|
+ b.EventDay = field.NewTime(table, "event_day")
|
|
|
|
+ b.Channel = field.NewString(table, "channel")
|
|
|
|
+ b.IsRevive = field.NewInt32(table, "is_revive")
|
|
|
|
+ b.ReviveWave = field.NewInt32(table, "revive_wave")
|
|
|
|
+
|
|
|
|
+ b.fillFieldMap()
|
|
|
|
+
|
|
|
|
+ return b
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b *battleLog) WithContext(ctx context.Context) *battleLogDo {
|
|
|
|
+ return b.battleLogDo.WithContext(ctx)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLog) TableName() string { return b.battleLogDo.TableName() }
|
|
|
|
+
|
|
|
|
+func (b battleLog) Alias() string { return b.battleLogDo.Alias() }
|
|
|
|
+
|
|
|
|
+func (b battleLog) Columns(cols ...field.Expr) gen.Columns { return b.battleLogDo.Columns(cols...) }
|
|
|
|
+
|
|
|
|
+func (b *battleLog) 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 *battleLog) fillFieldMap() {
|
|
|
|
+ b.fieldMap = make(map[string]field.Expr, 12)
|
|
|
|
+ b.fieldMap["id"] = b.ID
|
|
|
|
+ b.fieldMap["chapter_id"] = b.ChapterID
|
|
|
|
+ b.fieldMap["wave"] = b.Wave
|
|
|
|
+ b.fieldMap["player_id"] = b.PlayerID
|
|
|
|
+ b.fieldMap["battle_time"] = b.BattleTime
|
|
|
|
+ b.fieldMap["battle_result"] = b.BattleResult
|
|
|
|
+ b.fieldMap["is_new"] = b.IsNew
|
|
|
|
+ b.fieldMap["event_time"] = b.EventTime
|
|
|
|
+ b.fieldMap["event_day"] = b.EventDay
|
|
|
|
+ b.fieldMap["channel"] = b.Channel
|
|
|
|
+ b.fieldMap["is_revive"] = b.IsRevive
|
|
|
|
+ b.fieldMap["revive_wave"] = b.ReviveWave
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLog) clone(db *gorm.DB) battleLog {
|
|
|
|
+ b.battleLogDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
|
+ return b
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLog) replaceDB(db *gorm.DB) battleLog {
|
|
|
|
+ b.battleLogDo.ReplaceDB(db)
|
|
|
|
+ return b
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type battleLogDo struct{ gen.DO }
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Debug() *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Debug())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) WithContext(ctx context.Context) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.WithContext(ctx))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) ReadDB() *battleLogDo {
|
|
|
|
+ return b.Clauses(dbresolver.Read)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) WriteDB() *battleLogDo {
|
|
|
|
+ return b.Clauses(dbresolver.Write)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Session(config *gorm.Session) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Session(config))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Clauses(conds ...clause.Expression) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Clauses(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Returning(value interface{}, columns ...string) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Returning(value, columns...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Not(conds ...gen.Condition) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Not(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Or(conds ...gen.Condition) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Or(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Select(conds ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Select(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Where(conds ...gen.Condition) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Where(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Order(conds ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Order(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Distinct(cols ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Distinct(cols...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Omit(cols ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Omit(cols...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Join(table schema.Tabler, on ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Join(table, on...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.LeftJoin(table, on...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.RightJoin(table, on...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Group(cols ...field.Expr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Group(cols...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Having(conds ...gen.Condition) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Having(conds...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Limit(limit int) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Limit(limit))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Offset(offset int) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Offset(offset))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Scopes(funcs...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Unscoped() *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Unscoped())
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Create(values ...*model.BattleLog) error {
|
|
|
|
+ if len(values) == 0 {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ return b.DO.Create(values)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) CreateInBatches(values []*model.BattleLog, 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 battleLogDo) Save(values ...*model.BattleLog) error {
|
|
|
|
+ if len(values) == 0 {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+ return b.DO.Save(values)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) First() (*model.BattleLog, error) {
|
|
|
|
+ if result, err := b.DO.First(); err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ } else {
|
|
|
|
+ return result.(*model.BattleLog), nil
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Take() (*model.BattleLog, error) {
|
|
|
|
+ if result, err := b.DO.Take(); err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ } else {
|
|
|
|
+ return result.(*model.BattleLog), nil
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Last() (*model.BattleLog, error) {
|
|
|
|
+ if result, err := b.DO.Last(); err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ } else {
|
|
|
|
+ return result.(*model.BattleLog), nil
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Find() ([]*model.BattleLog, error) {
|
|
|
|
+ result, err := b.DO.Find()
|
|
|
|
+ return result.([]*model.BattleLog), err
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BattleLog, err error) {
|
|
|
|
+ buf := make([]*model.BattleLog, 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 battleLogDo) FindInBatches(result *[]*model.BattleLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
|
+ return b.DO.FindInBatches(result, batchSize, fc)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Attrs(attrs ...field.AssignExpr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Attrs(attrs...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Assign(attrs ...field.AssignExpr) *battleLogDo {
|
|
|
|
+ return b.withDO(b.DO.Assign(attrs...))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Joins(fields ...field.RelationField) *battleLogDo {
|
|
|
|
+ for _, _f := range fields {
|
|
|
|
+ b = *b.withDO(b.DO.Joins(_f))
|
|
|
|
+ }
|
|
|
|
+ return &b
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Preload(fields ...field.RelationField) *battleLogDo {
|
|
|
|
+ for _, _f := range fields {
|
|
|
|
+ b = *b.withDO(b.DO.Preload(_f))
|
|
|
|
+ }
|
|
|
|
+ return &b
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) FirstOrInit() (*model.BattleLog, error) {
|
|
|
|
+ if result, err := b.DO.FirstOrInit(); err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ } else {
|
|
|
|
+ return result.(*model.BattleLog), nil
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) FirstOrCreate() (*model.BattleLog, error) {
|
|
|
|
+ if result, err := b.DO.FirstOrCreate(); err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ } else {
|
|
|
|
+ return result.(*model.BattleLog), nil
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) FindByPage(offset int, limit int) (result []*model.BattleLog, 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 battleLogDo) 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 battleLogDo) Scan(result interface{}) (err error) {
|
|
|
|
+ return b.DO.Scan(result)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b battleLogDo) Delete(models ...*model.BattleLog) (result gen.ResultInfo, err error) {
|
|
|
|
+ return b.DO.Delete(models)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (b *battleLogDo) withDO(do gen.Dao) *battleLogDo {
|
|
|
|
+ b.DO = *do.(*gen.DO)
|
|
|
|
+ return b
|
|
|
|
+}
|