123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- // 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 newChapterLog(db *gorm.DB, opts ...gen.DOOption) chapterLog {
- _chapterLog := chapterLog{}
- _chapterLog.chapterLogDo.UseDB(db, opts...)
- _chapterLog.chapterLogDo.UseModel(&model.ChapterLog{})
- tableName := _chapterLog.chapterLogDo.TableName()
- _chapterLog.ALL = field.NewAsterisk(tableName)
- _chapterLog.ID = field.NewInt64(tableName, "id")
- _chapterLog.ChannelID = field.NewString(tableName, "channel_id")
- _chapterLog.Flag = field.NewInt32(tableName, "flag")
- _chapterLog.UserID = field.NewInt64(tableName, "user_id")
- _chapterLog.ServerID = field.NewInt32(tableName, "server_id")
- _chapterLog.EventID = field.NewInt32(tableName, "event_id")
- _chapterLog.ChapterID = field.NewInt32(tableName, "chapter_id")
- _chapterLog.RoomID = field.NewInt64(tableName, "room_id")
- _chapterLog.UserCreatedAt = field.NewInt32(tableName, "user_created_at")
- _chapterLog.EventAt = field.NewInt32(tableName, "event_at")
- _chapterLog.Extra = field.NewString(tableName, "extra")
- _chapterLog.Token = field.NewString(tableName, "token")
- _chapterLog.Difficulty = field.NewInt32(tableName, "difficulty")
- _chapterLog.EventAtNs = field.NewInt64(tableName, "event_at_ns")
- _chapterLog.fillFieldMap()
- return _chapterLog
- }
- type chapterLog struct {
- chapterLogDo
- ALL field.Asterisk
- ID field.Int64
- ChannelID field.String // 渠道ID
- Flag field.Int32
- UserID field.Int64 // 用户id
- ServerID field.Int32 // 服务器ID
- EventID field.Int32 // 埋点id
- ChapterID field.Int32 // 关卡id
- RoomID field.Int64 // 房间id
- UserCreatedAt field.Int32 // 用户注册时间
- EventAt field.Int32 // 埋点事件触发的时间
- Extra field.String // 其他参数
- Token field.String // 登陆的token
- Difficulty field.Int32 // 困难度
- EventAtNs field.Int64 // 埋点事件触发的时间
- fieldMap map[string]field.Expr
- }
- func (c chapterLog) Table(newTableName string) *chapterLog {
- c.chapterLogDo.UseTable(newTableName)
- return c.updateTableName(newTableName)
- }
- func (c chapterLog) As(alias string) *chapterLog {
- c.chapterLogDo.DO = *(c.chapterLogDo.As(alias).(*gen.DO))
- return c.updateTableName(alias)
- }
- func (c *chapterLog) updateTableName(table string) *chapterLog {
- c.ALL = field.NewAsterisk(table)
- c.ID = field.NewInt64(table, "id")
- c.ChannelID = field.NewString(table, "channel_id")
- c.Flag = field.NewInt32(table, "flag")
- c.UserID = field.NewInt64(table, "user_id")
- c.ServerID = field.NewInt32(table, "server_id")
- c.EventID = field.NewInt32(table, "event_id")
- c.ChapterID = field.NewInt32(table, "chapter_id")
- c.RoomID = field.NewInt64(table, "room_id")
- c.UserCreatedAt = field.NewInt32(table, "user_created_at")
- c.EventAt = field.NewInt32(table, "event_at")
- c.Extra = field.NewString(table, "extra")
- c.Token = field.NewString(table, "token")
- c.Difficulty = field.NewInt32(table, "difficulty")
- c.EventAtNs = field.NewInt64(table, "event_at_ns")
- c.fillFieldMap()
- return c
- }
- func (c *chapterLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := c.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (c *chapterLog) fillFieldMap() {
- c.fieldMap = make(map[string]field.Expr, 14)
- c.fieldMap["id"] = c.ID
- c.fieldMap["channel_id"] = c.ChannelID
- c.fieldMap["flag"] = c.Flag
- c.fieldMap["user_id"] = c.UserID
- c.fieldMap["server_id"] = c.ServerID
- c.fieldMap["event_id"] = c.EventID
- c.fieldMap["chapter_id"] = c.ChapterID
- c.fieldMap["room_id"] = c.RoomID
- c.fieldMap["user_created_at"] = c.UserCreatedAt
- c.fieldMap["event_at"] = c.EventAt
- c.fieldMap["extra"] = c.Extra
- c.fieldMap["token"] = c.Token
- c.fieldMap["difficulty"] = c.Difficulty
- c.fieldMap["event_at_ns"] = c.EventAtNs
- }
- func (c chapterLog) clone(db *gorm.DB) chapterLog {
- c.chapterLogDo.ReplaceConnPool(db.Statement.ConnPool)
- return c
- }
- func (c chapterLog) replaceDB(db *gorm.DB) chapterLog {
- c.chapterLogDo.ReplaceDB(db)
- return c
- }
- type chapterLogDo struct{ gen.DO }
- func (c chapterLogDo) Debug() *chapterLogDo {
- return c.withDO(c.DO.Debug())
- }
- func (c chapterLogDo) WithContext(ctx context.Context) *chapterLogDo {
- return c.withDO(c.DO.WithContext(ctx))
- }
- func (c chapterLogDo) ReadDB() *chapterLogDo {
- return c.Clauses(dbresolver.Read)
- }
- func (c chapterLogDo) WriteDB() *chapterLogDo {
- return c.Clauses(dbresolver.Write)
- }
- func (c chapterLogDo) Session(config *gorm.Session) *chapterLogDo {
- return c.withDO(c.DO.Session(config))
- }
- func (c chapterLogDo) Clauses(conds ...clause.Expression) *chapterLogDo {
- return c.withDO(c.DO.Clauses(conds...))
- }
- func (c chapterLogDo) Returning(value interface{}, columns ...string) *chapterLogDo {
- return c.withDO(c.DO.Returning(value, columns...))
- }
- func (c chapterLogDo) Not(conds ...gen.Condition) *chapterLogDo {
- return c.withDO(c.DO.Not(conds...))
- }
- func (c chapterLogDo) Or(conds ...gen.Condition) *chapterLogDo {
- return c.withDO(c.DO.Or(conds...))
- }
- func (c chapterLogDo) Select(conds ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Select(conds...))
- }
- func (c chapterLogDo) Where(conds ...gen.Condition) *chapterLogDo {
- return c.withDO(c.DO.Where(conds...))
- }
- func (c chapterLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *chapterLogDo {
- return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
- }
- func (c chapterLogDo) Order(conds ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Order(conds...))
- }
- func (c chapterLogDo) Distinct(cols ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Distinct(cols...))
- }
- func (c chapterLogDo) Omit(cols ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Omit(cols...))
- }
- func (c chapterLogDo) Join(table schema.Tabler, on ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Join(table, on...))
- }
- func (c chapterLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.LeftJoin(table, on...))
- }
- func (c chapterLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.RightJoin(table, on...))
- }
- func (c chapterLogDo) Group(cols ...field.Expr) *chapterLogDo {
- return c.withDO(c.DO.Group(cols...))
- }
- func (c chapterLogDo) Having(conds ...gen.Condition) *chapterLogDo {
- return c.withDO(c.DO.Having(conds...))
- }
- func (c chapterLogDo) Limit(limit int) *chapterLogDo {
- return c.withDO(c.DO.Limit(limit))
- }
- func (c chapterLogDo) Offset(offset int) *chapterLogDo {
- return c.withDO(c.DO.Offset(offset))
- }
- func (c chapterLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chapterLogDo {
- return c.withDO(c.DO.Scopes(funcs...))
- }
- func (c chapterLogDo) Unscoped() *chapterLogDo {
- return c.withDO(c.DO.Unscoped())
- }
- func (c chapterLogDo) Create(values ...*model.ChapterLog) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Create(values)
- }
- func (c chapterLogDo) CreateInBatches(values []*model.ChapterLog, batchSize int) error {
- return c.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 (c chapterLogDo) Save(values ...*model.ChapterLog) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Save(values)
- }
- func (c chapterLogDo) First() (*model.ChapterLog, error) {
- if result, err := c.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChapterLog), nil
- }
- }
- func (c chapterLogDo) Take() (*model.ChapterLog, error) {
- if result, err := c.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChapterLog), nil
- }
- }
- func (c chapterLogDo) Last() (*model.ChapterLog, error) {
- if result, err := c.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChapterLog), nil
- }
- }
- func (c chapterLogDo) Find() ([]*model.ChapterLog, error) {
- result, err := c.DO.Find()
- return result.([]*model.ChapterLog), err
- }
- func (c chapterLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChapterLog, err error) {
- buf := make([]*model.ChapterLog, 0, batchSize)
- err = c.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 (c chapterLogDo) FindInBatches(result *[]*model.ChapterLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return c.DO.FindInBatches(result, batchSize, fc)
- }
- func (c chapterLogDo) Attrs(attrs ...field.AssignExpr) *chapterLogDo {
- return c.withDO(c.DO.Attrs(attrs...))
- }
- func (c chapterLogDo) Assign(attrs ...field.AssignExpr) *chapterLogDo {
- return c.withDO(c.DO.Assign(attrs...))
- }
- func (c chapterLogDo) Joins(fields ...field.RelationField) *chapterLogDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Joins(_f))
- }
- return &c
- }
- func (c chapterLogDo) Preload(fields ...field.RelationField) *chapterLogDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Preload(_f))
- }
- return &c
- }
- func (c chapterLogDo) FirstOrInit() (*model.ChapterLog, error) {
- if result, err := c.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChapterLog), nil
- }
- }
- func (c chapterLogDo) FirstOrCreate() (*model.ChapterLog, error) {
- if result, err := c.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChapterLog), nil
- }
- }
- func (c chapterLogDo) FindByPage(offset int, limit int) (result []*model.ChapterLog, count int64, err error) {
- result, err = c.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 = c.Offset(-1).Limit(-1).Count()
- return
- }
- func (c chapterLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = c.Count()
- if err != nil {
- return
- }
- err = c.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (c chapterLogDo) Scan(result interface{}) (err error) {
- return c.DO.Scan(result)
- }
- func (c chapterLogDo) Delete(models ...*model.ChapterLog) (result gen.ResultInfo, err error) {
- return c.DO.Delete(models)
- }
- func (c *chapterLogDo) withDO(do gen.Dao) *chapterLogDo {
- c.DO = *do.(*gen.DO)
- return c
- }
|