123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- // 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
- }
|