// 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" "wechat-api/database/dao/wechat/model" ) func newAllocAgent(db *gorm.DB, opts ...gen.DOOption) allocAgent { _allocAgent := allocAgent{} _allocAgent.allocAgentDo.UseDB(db, opts...) _allocAgent.allocAgentDo.UseModel(&model.AllocAgent{}) tableName := _allocAgent.allocAgentDo.TableName() _allocAgent.ALL = field.NewAsterisk(tableName) _allocAgent.ID = field.NewInt64(tableName, "id") _allocAgent.CreatedAt = field.NewTime(tableName, "created_at") _allocAgent.UpdatedAt = field.NewTime(tableName, "updated_at") _allocAgent.Status = field.NewInt64(tableName, "status") _allocAgent.DeletedAt = field.NewField(tableName, "deleted_at") _allocAgent.UserID = field.NewString(tableName, "user_id") _allocAgent.OrganizationID = field.NewInt64(tableName, "organization_id") _allocAgent.Agents = field.NewString(tableName, "agents") _allocAgent.fillFieldMap() return _allocAgent } type allocAgent struct { allocAgentDo ALL field.Asterisk ID field.Int64 CreatedAt field.Time // Create Time | 创建日期 UpdatedAt field.Time // Update Time | 修改日期 Status field.Int64 // 状态 1 正常 2 禁用 DeletedAt field.Field // Delete Time | 删除日期 UserID field.String // 前台用户ID OrganizationID field.Int64 // 机构 ID Agents field.String // 分配的智能体ID fieldMap map[string]field.Expr } func (a allocAgent) Table(newTableName string) *allocAgent { a.allocAgentDo.UseTable(newTableName) return a.updateTableName(newTableName) } func (a allocAgent) As(alias string) *allocAgent { a.allocAgentDo.DO = *(a.allocAgentDo.As(alias).(*gen.DO)) return a.updateTableName(alias) } func (a *allocAgent) updateTableName(table string) *allocAgent { a.ALL = field.NewAsterisk(table) a.ID = field.NewInt64(table, "id") a.CreatedAt = field.NewTime(table, "created_at") a.UpdatedAt = field.NewTime(table, "updated_at") a.Status = field.NewInt64(table, "status") a.DeletedAt = field.NewField(table, "deleted_at") a.UserID = field.NewString(table, "user_id") a.OrganizationID = field.NewInt64(table, "organization_id") a.Agents = field.NewString(table, "agents") a.fillFieldMap() return a } func (a *allocAgent) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := a.fieldMap[fieldName] if !ok || _f == nil { return nil, false } _oe, ok := _f.(field.OrderExpr) return _oe, ok } func (a *allocAgent) fillFieldMap() { a.fieldMap = make(map[string]field.Expr, 8) a.fieldMap["id"] = a.ID a.fieldMap["created_at"] = a.CreatedAt a.fieldMap["updated_at"] = a.UpdatedAt a.fieldMap["status"] = a.Status a.fieldMap["deleted_at"] = a.DeletedAt a.fieldMap["user_id"] = a.UserID a.fieldMap["organization_id"] = a.OrganizationID a.fieldMap["agents"] = a.Agents } func (a allocAgent) clone(db *gorm.DB) allocAgent { a.allocAgentDo.ReplaceConnPool(db.Statement.ConnPool) return a } func (a allocAgent) replaceDB(db *gorm.DB) allocAgent { a.allocAgentDo.ReplaceDB(db) return a } type allocAgentDo struct{ gen.DO } type IAllocAgentDo interface { gen.SubQuery Debug() IAllocAgentDo WithContext(ctx context.Context) IAllocAgentDo WithResult(fc func(tx gen.Dao)) gen.ResultInfo ReplaceDB(db *gorm.DB) ReadDB() IAllocAgentDo WriteDB() IAllocAgentDo As(alias string) gen.Dao Session(config *gorm.Session) IAllocAgentDo Columns(cols ...field.Expr) gen.Columns Clauses(conds ...clause.Expression) IAllocAgentDo Not(conds ...gen.Condition) IAllocAgentDo Or(conds ...gen.Condition) IAllocAgentDo Select(conds ...field.Expr) IAllocAgentDo Where(conds ...gen.Condition) IAllocAgentDo Order(conds ...field.Expr) IAllocAgentDo Distinct(cols ...field.Expr) IAllocAgentDo Omit(cols ...field.Expr) IAllocAgentDo Join(table schema.Tabler, on ...field.Expr) IAllocAgentDo LeftJoin(table schema.Tabler, on ...field.Expr) IAllocAgentDo RightJoin(table schema.Tabler, on ...field.Expr) IAllocAgentDo Group(cols ...field.Expr) IAllocAgentDo Having(conds ...gen.Condition) IAllocAgentDo Limit(limit int) IAllocAgentDo Offset(offset int) IAllocAgentDo Count() (count int64, err error) Scopes(funcs ...func(gen.Dao) gen.Dao) IAllocAgentDo Unscoped() IAllocAgentDo Create(values ...*model.AllocAgent) error CreateInBatches(values []*model.AllocAgent, batchSize int) error Save(values ...*model.AllocAgent) error First() (*model.AllocAgent, error) Take() (*model.AllocAgent, error) Last() (*model.AllocAgent, error) Find() ([]*model.AllocAgent, error) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AllocAgent, err error) FindInBatches(result *[]*model.AllocAgent, batchSize int, fc func(tx gen.Dao, batch int) error) error Pluck(column field.Expr, dest interface{}) error Delete(...*model.AllocAgent) (info gen.ResultInfo, err error) Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) Updates(value interface{}) (info gen.ResultInfo, err error) UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) UpdateColumns(value interface{}) (info gen.ResultInfo, err error) UpdateFrom(q gen.SubQuery) gen.Dao Attrs(attrs ...field.AssignExpr) IAllocAgentDo Assign(attrs ...field.AssignExpr) IAllocAgentDo Joins(fields ...field.RelationField) IAllocAgentDo Preload(fields ...field.RelationField) IAllocAgentDo FirstOrInit() (*model.AllocAgent, error) FirstOrCreate() (*model.AllocAgent, error) FindByPage(offset int, limit int) (result []*model.AllocAgent, count int64, err error) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) Scan(result interface{}) (err error) Returning(value interface{}, columns ...string) IAllocAgentDo UnderlyingDB() *gorm.DB schema.Tabler } func (a allocAgentDo) Debug() IAllocAgentDo { return a.withDO(a.DO.Debug()) } func (a allocAgentDo) WithContext(ctx context.Context) IAllocAgentDo { return a.withDO(a.DO.WithContext(ctx)) } func (a allocAgentDo) ReadDB() IAllocAgentDo { return a.Clauses(dbresolver.Read) } func (a allocAgentDo) WriteDB() IAllocAgentDo { return a.Clauses(dbresolver.Write) } func (a allocAgentDo) Session(config *gorm.Session) IAllocAgentDo { return a.withDO(a.DO.Session(config)) } func (a allocAgentDo) Clauses(conds ...clause.Expression) IAllocAgentDo { return a.withDO(a.DO.Clauses(conds...)) } func (a allocAgentDo) Returning(value interface{}, columns ...string) IAllocAgentDo { return a.withDO(a.DO.Returning(value, columns...)) } func (a allocAgentDo) Not(conds ...gen.Condition) IAllocAgentDo { return a.withDO(a.DO.Not(conds...)) } func (a allocAgentDo) Or(conds ...gen.Condition) IAllocAgentDo { return a.withDO(a.DO.Or(conds...)) } func (a allocAgentDo) Select(conds ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Select(conds...)) } func (a allocAgentDo) Where(conds ...gen.Condition) IAllocAgentDo { return a.withDO(a.DO.Where(conds...)) } func (a allocAgentDo) Order(conds ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Order(conds...)) } func (a allocAgentDo) Distinct(cols ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Distinct(cols...)) } func (a allocAgentDo) Omit(cols ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Omit(cols...)) } func (a allocAgentDo) Join(table schema.Tabler, on ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Join(table, on...)) } func (a allocAgentDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.LeftJoin(table, on...)) } func (a allocAgentDo) RightJoin(table schema.Tabler, on ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.RightJoin(table, on...)) } func (a allocAgentDo) Group(cols ...field.Expr) IAllocAgentDo { return a.withDO(a.DO.Group(cols...)) } func (a allocAgentDo) Having(conds ...gen.Condition) IAllocAgentDo { return a.withDO(a.DO.Having(conds...)) } func (a allocAgentDo) Limit(limit int) IAllocAgentDo { return a.withDO(a.DO.Limit(limit)) } func (a allocAgentDo) Offset(offset int) IAllocAgentDo { return a.withDO(a.DO.Offset(offset)) } func (a allocAgentDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAllocAgentDo { return a.withDO(a.DO.Scopes(funcs...)) } func (a allocAgentDo) Unscoped() IAllocAgentDo { return a.withDO(a.DO.Unscoped()) } func (a allocAgentDo) Create(values ...*model.AllocAgent) error { if len(values) == 0 { return nil } return a.DO.Create(values) } func (a allocAgentDo) CreateInBatches(values []*model.AllocAgent, batchSize int) error { return a.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 (a allocAgentDo) Save(values ...*model.AllocAgent) error { if len(values) == 0 { return nil } return a.DO.Save(values) } func (a allocAgentDo) First() (*model.AllocAgent, error) { if result, err := a.DO.First(); err != nil { return nil, err } else { return result.(*model.AllocAgent), nil } } func (a allocAgentDo) Take() (*model.AllocAgent, error) { if result, err := a.DO.Take(); err != nil { return nil, err } else { return result.(*model.AllocAgent), nil } } func (a allocAgentDo) Last() (*model.AllocAgent, error) { if result, err := a.DO.Last(); err != nil { return nil, err } else { return result.(*model.AllocAgent), nil } } func (a allocAgentDo) Find() ([]*model.AllocAgent, error) { result, err := a.DO.Find() return result.([]*model.AllocAgent), err } func (a allocAgentDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AllocAgent, err error) { buf := make([]*model.AllocAgent, 0, batchSize) err = a.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 (a allocAgentDo) FindInBatches(result *[]*model.AllocAgent, batchSize int, fc func(tx gen.Dao, batch int) error) error { return a.DO.FindInBatches(result, batchSize, fc) } func (a allocAgentDo) Attrs(attrs ...field.AssignExpr) IAllocAgentDo { return a.withDO(a.DO.Attrs(attrs...)) } func (a allocAgentDo) Assign(attrs ...field.AssignExpr) IAllocAgentDo { return a.withDO(a.DO.Assign(attrs...)) } func (a allocAgentDo) Joins(fields ...field.RelationField) IAllocAgentDo { for _, _f := range fields { a = *a.withDO(a.DO.Joins(_f)) } return &a } func (a allocAgentDo) Preload(fields ...field.RelationField) IAllocAgentDo { for _, _f := range fields { a = *a.withDO(a.DO.Preload(_f)) } return &a } func (a allocAgentDo) FirstOrInit() (*model.AllocAgent, error) { if result, err := a.DO.FirstOrInit(); err != nil { return nil, err } else { return result.(*model.AllocAgent), nil } } func (a allocAgentDo) FirstOrCreate() (*model.AllocAgent, error) { if result, err := a.DO.FirstOrCreate(); err != nil { return nil, err } else { return result.(*model.AllocAgent), nil } } func (a allocAgentDo) FindByPage(offset int, limit int) (result []*model.AllocAgent, count int64, err error) { result, err = a.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 = a.Offset(-1).Limit(-1).Count() return } func (a allocAgentDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { count, err = a.Count() if err != nil { return } err = a.Offset(offset).Limit(limit).Scan(result) return } func (a allocAgentDo) Scan(result interface{}) (err error) { return a.DO.Scan(result) } func (a allocAgentDo) Delete(models ...*model.AllocAgent) (result gen.ResultInfo, err error) { return a.DO.Delete(models) } func (a *allocAgentDo) withDO(do gen.Dao) *allocAgentDo { a.DO = *do.(*gen.DO) return a }