// 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 newCustomerServiceChatLog(db *gorm.DB, opts ...gen.DOOption) customerServiceChatLog { _customerServiceChatLog := customerServiceChatLog{} _customerServiceChatLog.customerServiceChatLogDo.UseDB(db, opts...) _customerServiceChatLog.customerServiceChatLogDo.UseModel(&model.CustomerServiceChatLog{}) tableName := _customerServiceChatLog.customerServiceChatLogDo.TableName() _customerServiceChatLog.ALL = field.NewAsterisk(tableName) _customerServiceChatLog.ID = field.NewInt64(tableName, "id") _customerServiceChatLog.Type = field.NewInt32(tableName, "type") _customerServiceChatLog.AccID = field.NewInt64(tableName, "acc_id") _customerServiceChatLog.OpenID = field.NewString(tableName, "open_id") _customerServiceChatLog.PlayerName = field.NewString(tableName, "player_name") _customerServiceChatLog.Text = field.NewString(tableName, "text") _customerServiceChatLog.Time = field.NewTime(tableName, "time") _customerServiceChatLog.CreatedAt = field.NewTime(tableName, "created_at") _customerServiceChatLog.fillFieldMap() return _customerServiceChatLog } type customerServiceChatLog struct { customerServiceChatLogDo ALL field.Asterisk ID field.Int64 Type field.Int32 // 消息类型 1 玩家消息 2客服消息 AccID field.Int64 // 玩家账号id OpenID field.String // open_id PlayerName field.String // 玩家昵称 Text field.String // 消息内容 Time field.Time // 消息发送时间 CreatedAt field.Time // 创建时间 fieldMap map[string]field.Expr } func (c customerServiceChatLog) Table(newTableName string) *customerServiceChatLog { c.customerServiceChatLogDo.UseTable(newTableName) return c.updateTableName(newTableName) } func (c customerServiceChatLog) As(alias string) *customerServiceChatLog { c.customerServiceChatLogDo.DO = *(c.customerServiceChatLogDo.As(alias).(*gen.DO)) return c.updateTableName(alias) } func (c *customerServiceChatLog) updateTableName(table string) *customerServiceChatLog { c.ALL = field.NewAsterisk(table) c.ID = field.NewInt64(table, "id") c.Type = field.NewInt32(table, "type") c.AccID = field.NewInt64(table, "acc_id") c.OpenID = field.NewString(table, "open_id") c.PlayerName = field.NewString(table, "player_name") c.Text = field.NewString(table, "text") c.Time = field.NewTime(table, "time") c.CreatedAt = field.NewTime(table, "created_at") c.fillFieldMap() return c } func (c *customerServiceChatLog) 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 *customerServiceChatLog) fillFieldMap() { c.fieldMap = make(map[string]field.Expr, 8) c.fieldMap["id"] = c.ID c.fieldMap["type"] = c.Type c.fieldMap["acc_id"] = c.AccID c.fieldMap["open_id"] = c.OpenID c.fieldMap["player_name"] = c.PlayerName c.fieldMap["text"] = c.Text c.fieldMap["time"] = c.Time c.fieldMap["created_at"] = c.CreatedAt } func (c customerServiceChatLog) clone(db *gorm.DB) customerServiceChatLog { c.customerServiceChatLogDo.ReplaceConnPool(db.Statement.ConnPool) return c } func (c customerServiceChatLog) replaceDB(db *gorm.DB) customerServiceChatLog { c.customerServiceChatLogDo.ReplaceDB(db) return c } type customerServiceChatLogDo struct{ gen.DO } func (c customerServiceChatLogDo) Debug() *customerServiceChatLogDo { return c.withDO(c.DO.Debug()) } func (c customerServiceChatLogDo) WithContext(ctx context.Context) *customerServiceChatLogDo { return c.withDO(c.DO.WithContext(ctx)) } func (c customerServiceChatLogDo) ReadDB() *customerServiceChatLogDo { return c.Clauses(dbresolver.Read) } func (c customerServiceChatLogDo) WriteDB() *customerServiceChatLogDo { return c.Clauses(dbresolver.Write) } func (c customerServiceChatLogDo) Session(config *gorm.Session) *customerServiceChatLogDo { return c.withDO(c.DO.Session(config)) } func (c customerServiceChatLogDo) Clauses(conds ...clause.Expression) *customerServiceChatLogDo { return c.withDO(c.DO.Clauses(conds...)) } func (c customerServiceChatLogDo) Returning(value interface{}, columns ...string) *customerServiceChatLogDo { return c.withDO(c.DO.Returning(value, columns...)) } func (c customerServiceChatLogDo) Not(conds ...gen.Condition) *customerServiceChatLogDo { return c.withDO(c.DO.Not(conds...)) } func (c customerServiceChatLogDo) Or(conds ...gen.Condition) *customerServiceChatLogDo { return c.withDO(c.DO.Or(conds...)) } func (c customerServiceChatLogDo) Select(conds ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Select(conds...)) } func (c customerServiceChatLogDo) Where(conds ...gen.Condition) *customerServiceChatLogDo { return c.withDO(c.DO.Where(conds...)) } func (c customerServiceChatLogDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *customerServiceChatLogDo { return c.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) } func (c customerServiceChatLogDo) Order(conds ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Order(conds...)) } func (c customerServiceChatLogDo) Distinct(cols ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Distinct(cols...)) } func (c customerServiceChatLogDo) Omit(cols ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Omit(cols...)) } func (c customerServiceChatLogDo) Join(table schema.Tabler, on ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Join(table, on...)) } func (c customerServiceChatLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.LeftJoin(table, on...)) } func (c customerServiceChatLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.RightJoin(table, on...)) } func (c customerServiceChatLogDo) Group(cols ...field.Expr) *customerServiceChatLogDo { return c.withDO(c.DO.Group(cols...)) } func (c customerServiceChatLogDo) Having(conds ...gen.Condition) *customerServiceChatLogDo { return c.withDO(c.DO.Having(conds...)) } func (c customerServiceChatLogDo) Limit(limit int) *customerServiceChatLogDo { return c.withDO(c.DO.Limit(limit)) } func (c customerServiceChatLogDo) Offset(offset int) *customerServiceChatLogDo { return c.withDO(c.DO.Offset(offset)) } func (c customerServiceChatLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *customerServiceChatLogDo { return c.withDO(c.DO.Scopes(funcs...)) } func (c customerServiceChatLogDo) Unscoped() *customerServiceChatLogDo { return c.withDO(c.DO.Unscoped()) } func (c customerServiceChatLogDo) Create(values ...*model.CustomerServiceChatLog) error { if len(values) == 0 { return nil } return c.DO.Create(values) } func (c customerServiceChatLogDo) CreateInBatches(values []*model.CustomerServiceChatLog, 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 customerServiceChatLogDo) Save(values ...*model.CustomerServiceChatLog) error { if len(values) == 0 { return nil } return c.DO.Save(values) } func (c customerServiceChatLogDo) First() (*model.CustomerServiceChatLog, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { return result.(*model.CustomerServiceChatLog), nil } } func (c customerServiceChatLogDo) Take() (*model.CustomerServiceChatLog, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { return result.(*model.CustomerServiceChatLog), nil } } func (c customerServiceChatLogDo) Last() (*model.CustomerServiceChatLog, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { return result.(*model.CustomerServiceChatLog), nil } } func (c customerServiceChatLogDo) Find() ([]*model.CustomerServiceChatLog, error) { result, err := c.DO.Find() return result.([]*model.CustomerServiceChatLog), err } func (c customerServiceChatLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.CustomerServiceChatLog, err error) { buf := make([]*model.CustomerServiceChatLog, 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 customerServiceChatLogDo) FindInBatches(result *[]*model.CustomerServiceChatLog, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } func (c customerServiceChatLogDo) Attrs(attrs ...field.AssignExpr) *customerServiceChatLogDo { return c.withDO(c.DO.Attrs(attrs...)) } func (c customerServiceChatLogDo) Assign(attrs ...field.AssignExpr) *customerServiceChatLogDo { return c.withDO(c.DO.Assign(attrs...)) } func (c customerServiceChatLogDo) Joins(fields ...field.RelationField) *customerServiceChatLogDo { for _, _f := range fields { c = *c.withDO(c.DO.Joins(_f)) } return &c } func (c customerServiceChatLogDo) Preload(fields ...field.RelationField) *customerServiceChatLogDo { for _, _f := range fields { c = *c.withDO(c.DO.Preload(_f)) } return &c } func (c customerServiceChatLogDo) FirstOrInit() (*model.CustomerServiceChatLog, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.CustomerServiceChatLog), nil } } func (c customerServiceChatLogDo) FirstOrCreate() (*model.CustomerServiceChatLog, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.CustomerServiceChatLog), nil } } func (c customerServiceChatLogDo) FindByPage(offset int, limit int) (result []*model.CustomerServiceChatLog, 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 customerServiceChatLogDo) 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 customerServiceChatLogDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } func (c customerServiceChatLogDo) Delete(models ...*model.CustomerServiceChatLog) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } func (c *customerServiceChatLogDo) withDO(do gen.Dao) *customerServiceChatLogDo { c.DO = *do.(*gen.DO) return c }