// 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 newChat(db *gorm.DB, opts ...gen.DOOption) chat { _chat := chat{} _chat.chatDo.UseDB(db, opts...) _chat.chatDo.UseModel(&model.Chat{}) tableName := _chat.chatDo.TableName() _chat.ALL = field.NewAsterisk(tableName) _chat.ID = field.NewInt64(tableName, "id") _chat.Playerid = field.NewInt64(tableName, "playerid") _chat.EmojiIds = field.NewString(tableName, "emojiIds") _chat.ForbidTime = field.NewInt64(tableName, "forbidTime") _chat.fillFieldMap() return _chat } type chat struct { chatDo chatDo ALL field.Asterisk ID field.Int64 Playerid field.Int64 EmojiIds field.String ForbidTime field.Int64 fieldMap map[string]field.Expr } func (c chat) Table(newTableName string) *chat { c.chatDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c chat) As(alias string) *chat { c.chatDo.DO = *(c.chatDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *chat) updateTableName(table string) *chat { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt64(table, "id") c.Playerid = field.NewInt64(table, "playerid") c.EmojiIds = field.NewString(table, "emojiIds") c.ForbidTime = field.NewInt64(table, "forbidTime") c.fillFieldMap() return c } func (c *chat) WithContext(ctx context.Context) *chatDo { return c.chatDo.WithContext(ctx) } func (c chat) TableName() string { return c.chatDo.TableName() } func (c chat) Alias() string { return c.chatDo.Alias() } func (c chat) Columns(cols ...field.Expr) gen.Columns { return c.chatDo.Columns(cols...) } func (c *chat) 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 *chat) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 4) c.fieldMap["id"] = c.ID c.fieldMap["playerid"] = c.Playerid c.fieldMap["emojiIds"] = c.EmojiIds c.fieldMap["forbidTime"] = c.ForbidTime } func (c chat) clone(db *gorm.DB) chat { c.chatDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c chat) replaceDB(db *gorm.DB) chat { c.chatDo.ReplaceDB(db) return c } type chatDo struct{ gen.DO } func (c chatDo) Debug() *chatDo { return c.withDO(c.DO.Debug()) } func (c chatDo) WithContext(ctx context.Context) *chatDo { return c.withDO(c.DO.WithContext(ctx)) } func (c chatDo) ReadDB() *chatDo { return c.Clauses(dbresolver.Read) } func (c chatDo) WriteDB() *chatDo { return c.Clauses(dbresolver.Write) } func (c chatDo) Session(config *gorm.Session) *chatDo { return c.withDO(c.DO.Session(config)) } func (c chatDo) Clauses(conds ...clause.Expression) *chatDo { return c.withDO(c.DO.Clauses(conds...)) } func (c chatDo) Returning(value interface{}, columns ...string) *chatDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c chatDo) Not(conds ...gen.Condition) *chatDo { return c.withDO(c.DO.Not(conds...)) } func (c chatDo) Or(conds ...gen.Condition) *chatDo { return c.withDO(c.DO.Or(conds...)) } func (c chatDo) Select(conds ...field.Expr) *chatDo { return c.withDO(c.DO.Select(conds...)) } func (c chatDo) Where(conds ...gen.Condition) *chatDo { return c.withDO(c.DO.Where(conds...)) } func (c chatDo) Order(conds ...field.Expr) *chatDo { return c.withDO(c.DO.Order(conds...)) } func (c chatDo) Distinct(cols ...field.Expr) *chatDo { return c.withDO(c.DO.Distinct(cols...)) } func (c chatDo) Omit(cols ...field.Expr) *chatDo { return c.withDO(c.DO.Omit(cols...)) } func (c chatDo) Join(table schema.Tabler, on ...field.Expr) *chatDo { return c.withDO(c.DO.Join(table, on...)) } func (c chatDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chatDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c chatDo) RightJoin(table schema.Tabler, on ...field.Expr) *chatDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c chatDo) Group(cols ...field.Expr) *chatDo { return c.withDO(c.DO.Group(cols...)) } func (c chatDo) Having(conds ...gen.Condition) *chatDo { return c.withDO(c.DO.Having(conds...)) } func (c chatDo) Limit(limit int) *chatDo { return c.withDO(c.DO.Limit(limit)) } func (c chatDo) Offset(offset int) *chatDo { return c.withDO(c.DO.Offset(offset)) } func (c chatDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chatDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c chatDo) Unscoped() *chatDo { return c.withDO(c.DO.Unscoped()) } func (c chatDo) Create(values ...*model.Chat) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c chatDo) CreateInBatches(values []*model.Chat, 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 chatDo) Save(values ...*model.Chat) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c chatDo) First() (*model.Chat, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.Chat), nil } } func (c chatDo) Take() (*model.Chat, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.Chat), nil } } func (c chatDo) Last() (*model.Chat, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.Chat), nil } } func (c chatDo) Find() ([]*model.Chat, error) { result, err := c.DO.Find() return result.([]*model.Chat), err } func (c chatDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Chat, err error) { buf := make([]*model.Chat, 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 chatDo) FindInBatches(result *[]*model.Chat, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c chatDo) Attrs(attrs ...field.AssignExpr) *chatDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c chatDo) Assign(attrs ...field.AssignExpr) *chatDo { return c.withDO(c.DO.Assign(attrs...)) } func (c chatDo) Joins(fields ...field.RelationField) *chatDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c chatDo) Preload(fields ...field.RelationField) *chatDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c chatDo) FirstOrInit() (*model.Chat, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.Chat), nil } } func (c chatDo) FirstOrCreate() (*model.Chat, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.Chat), nil } } func (c chatDo) FindByPage(offset int, limit int) (result []*model.Chat, 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 chatDo) 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 chatDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c chatDo) Delete(models ...*model.Chat) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *chatDo) withDO(do gen.Dao) *chatDo { c.DO = *do.(*gen.DO) return c }