123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- 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 newWhatsappChannel(db *gorm.DB, opts ...gen.DOOption) whatsappChannel {
- _whatsappChannel := whatsappChannel{}
- _whatsappChannel.whatsappChannelDo.UseDB(db, opts...)
- _whatsappChannel.whatsappChannelDo.UseModel(&model.WhatsappChannel{})
- tableName := _whatsappChannel.whatsappChannelDo.TableName()
- _whatsappChannel.ALL = field.NewAsterisk(tableName)
- _whatsappChannel.ID = field.NewInt64(tableName, "id")
- _whatsappChannel.CreatedAt = field.NewTime(tableName, "created_at")
- _whatsappChannel.UpdatedAt = field.NewTime(tableName, "updated_at")
- _whatsappChannel.Status = field.NewInt64(tableName, "status")
- _whatsappChannel.DeletedAt = field.NewField(tableName, "deleted_at")
- _whatsappChannel.Ak = field.NewString(tableName, "ak")
- _whatsappChannel.Sk = field.NewString(tableName, "sk")
- _whatsappChannel.WaID = field.NewString(tableName, "wa_id")
- _whatsappChannel.WaName = field.NewString(tableName, "wa_name")
- _whatsappChannel.OrganizationID = field.NewInt64(tableName, "organization_id")
- _whatsappChannel.WabaID = field.NewInt64(tableName, "waba_id")
- _whatsappChannel.BusinessID = field.NewInt64(tableName, "business_id")
- _whatsappChannel.VerifyAccount = field.NewString(tableName, "verify_account")
- _whatsappChannel.fillFieldMap()
- return _whatsappChannel
- }
- type whatsappChannel struct {
- whatsappChannelDo
- ALL field.Asterisk
- ID field.Int64
- CreatedAt field.Time
- UpdatedAt field.Time
- Status field.Int64
- DeletedAt field.Field
- Ak field.String
- Sk field.String
- WaID field.String
- WaName field.String
- OrganizationID field.Int64
- WabaID field.Int64
- BusinessID field.Int64
- VerifyAccount field.String
- fieldMap map[string]field.Expr
- }
- func (w whatsappChannel) Table(newTableName string) *whatsappChannel {
- w.whatsappChannelDo.UseTable(newTableName)
- return w.updateTableName(newTableName)
- }
- func (w whatsappChannel) As(alias string) *whatsappChannel {
- w.whatsappChannelDo.DO = *(w.whatsappChannelDo.As(alias).(*gen.DO))
- return w.updateTableName(alias)
- }
- func (w *whatsappChannel) updateTableName(table string) *whatsappChannel {
- w.ALL = field.NewAsterisk(table)
- w.ID = field.NewInt64(table, "id")
- w.CreatedAt = field.NewTime(table, "created_at")
- w.UpdatedAt = field.NewTime(table, "updated_at")
- w.Status = field.NewInt64(table, "status")
- w.DeletedAt = field.NewField(table, "deleted_at")
- w.Ak = field.NewString(table, "ak")
- w.Sk = field.NewString(table, "sk")
- w.WaID = field.NewString(table, "wa_id")
- w.WaName = field.NewString(table, "wa_name")
- w.OrganizationID = field.NewInt64(table, "organization_id")
- w.WabaID = field.NewInt64(table, "waba_id")
- w.BusinessID = field.NewInt64(table, "business_id")
- w.VerifyAccount = field.NewString(table, "verify_account")
- w.fillFieldMap()
- return w
- }
- func (w *whatsappChannel) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := w.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (w *whatsappChannel) fillFieldMap() {
- w.fieldMap = make(map[string]field.Expr, 13)
- w.fieldMap["id"] = w.ID
- w.fieldMap["created_at"] = w.CreatedAt
- w.fieldMap["updated_at"] = w.UpdatedAt
- w.fieldMap["status"] = w.Status
- w.fieldMap["deleted_at"] = w.DeletedAt
- w.fieldMap["ak"] = w.Ak
- w.fieldMap["sk"] = w.Sk
- w.fieldMap["wa_id"] = w.WaID
- w.fieldMap["wa_name"] = w.WaName
- w.fieldMap["organization_id"] = w.OrganizationID
- w.fieldMap["waba_id"] = w.WabaID
- w.fieldMap["business_id"] = w.BusinessID
- w.fieldMap["verify_account"] = w.VerifyAccount
- }
- func (w whatsappChannel) clone(db *gorm.DB) whatsappChannel {
- w.whatsappChannelDo.ReplaceConnPool(db.Statement.ConnPool)
- return w
- }
- func (w whatsappChannel) replaceDB(db *gorm.DB) whatsappChannel {
- w.whatsappChannelDo.ReplaceDB(db)
- return w
- }
- type whatsappChannelDo struct{ gen.DO }
- type IWhatsappChannelDo interface {
- gen.SubQuery
- Debug() IWhatsappChannelDo
- WithContext(ctx context.Context) IWhatsappChannelDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IWhatsappChannelDo
- WriteDB() IWhatsappChannelDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IWhatsappChannelDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IWhatsappChannelDo
- Not(conds ...gen.Condition) IWhatsappChannelDo
- Or(conds ...gen.Condition) IWhatsappChannelDo
- Select(conds ...field.Expr) IWhatsappChannelDo
- Where(conds ...gen.Condition) IWhatsappChannelDo
- Order(conds ...field.Expr) IWhatsappChannelDo
- Distinct(cols ...field.Expr) IWhatsappChannelDo
- Omit(cols ...field.Expr) IWhatsappChannelDo
- Join(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo
- RightJoin(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo
- Group(cols ...field.Expr) IWhatsappChannelDo
- Having(conds ...gen.Condition) IWhatsappChannelDo
- Limit(limit int) IWhatsappChannelDo
- Offset(offset int) IWhatsappChannelDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IWhatsappChannelDo
- Unscoped() IWhatsappChannelDo
- Create(values ...*model.WhatsappChannel) error
- CreateInBatches(values []*model.WhatsappChannel, batchSize int) error
- Save(values ...*model.WhatsappChannel) error
- First() (*model.WhatsappChannel, error)
- Take() (*model.WhatsappChannel, error)
- Last() (*model.WhatsappChannel, error)
- Find() ([]*model.WhatsappChannel, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WhatsappChannel, err error)
- FindInBatches(result *[]*model.WhatsappChannel, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*model.WhatsappChannel) (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) IWhatsappChannelDo
- Assign(attrs ...field.AssignExpr) IWhatsappChannelDo
- Joins(fields ...field.RelationField) IWhatsappChannelDo
- Preload(fields ...field.RelationField) IWhatsappChannelDo
- FirstOrInit() (*model.WhatsappChannel, error)
- FirstOrCreate() (*model.WhatsappChannel, error)
- FindByPage(offset int, limit int) (result []*model.WhatsappChannel, 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) IWhatsappChannelDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (w whatsappChannelDo) Debug() IWhatsappChannelDo {
- return w.withDO(w.DO.Debug())
- }
- func (w whatsappChannelDo) WithContext(ctx context.Context) IWhatsappChannelDo {
- return w.withDO(w.DO.WithContext(ctx))
- }
- func (w whatsappChannelDo) ReadDB() IWhatsappChannelDo {
- return w.Clauses(dbresolver.Read)
- }
- func (w whatsappChannelDo) WriteDB() IWhatsappChannelDo {
- return w.Clauses(dbresolver.Write)
- }
- func (w whatsappChannelDo) Session(config *gorm.Session) IWhatsappChannelDo {
- return w.withDO(w.DO.Session(config))
- }
- func (w whatsappChannelDo) Clauses(conds ...clause.Expression) IWhatsappChannelDo {
- return w.withDO(w.DO.Clauses(conds...))
- }
- func (w whatsappChannelDo) Returning(value interface{}, columns ...string) IWhatsappChannelDo {
- return w.withDO(w.DO.Returning(value, columns...))
- }
- func (w whatsappChannelDo) Not(conds ...gen.Condition) IWhatsappChannelDo {
- return w.withDO(w.DO.Not(conds...))
- }
- func (w whatsappChannelDo) Or(conds ...gen.Condition) IWhatsappChannelDo {
- return w.withDO(w.DO.Or(conds...))
- }
- func (w whatsappChannelDo) Select(conds ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Select(conds...))
- }
- func (w whatsappChannelDo) Where(conds ...gen.Condition) IWhatsappChannelDo {
- return w.withDO(w.DO.Where(conds...))
- }
- func (w whatsappChannelDo) Order(conds ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Order(conds...))
- }
- func (w whatsappChannelDo) Distinct(cols ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Distinct(cols...))
- }
- func (w whatsappChannelDo) Omit(cols ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Omit(cols...))
- }
- func (w whatsappChannelDo) Join(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Join(table, on...))
- }
- func (w whatsappChannelDo) LeftJoin(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.LeftJoin(table, on...))
- }
- func (w whatsappChannelDo) RightJoin(table schema.Tabler, on ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.RightJoin(table, on...))
- }
- func (w whatsappChannelDo) Group(cols ...field.Expr) IWhatsappChannelDo {
- return w.withDO(w.DO.Group(cols...))
- }
- func (w whatsappChannelDo) Having(conds ...gen.Condition) IWhatsappChannelDo {
- return w.withDO(w.DO.Having(conds...))
- }
- func (w whatsappChannelDo) Limit(limit int) IWhatsappChannelDo {
- return w.withDO(w.DO.Limit(limit))
- }
- func (w whatsappChannelDo) Offset(offset int) IWhatsappChannelDo {
- return w.withDO(w.DO.Offset(offset))
- }
- func (w whatsappChannelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IWhatsappChannelDo {
- return w.withDO(w.DO.Scopes(funcs...))
- }
- func (w whatsappChannelDo) Unscoped() IWhatsappChannelDo {
- return w.withDO(w.DO.Unscoped())
- }
- func (w whatsappChannelDo) Create(values ...*model.WhatsappChannel) error {
- if len(values) == 0 {
- return nil
- }
- return w.DO.Create(values)
- }
- func (w whatsappChannelDo) CreateInBatches(values []*model.WhatsappChannel, batchSize int) error {
- return w.DO.CreateInBatches(values, batchSize)
- }
- func (w whatsappChannelDo) Save(values ...*model.WhatsappChannel) error {
- if len(values) == 0 {
- return nil
- }
- return w.DO.Save(values)
- }
- func (w whatsappChannelDo) First() (*model.WhatsappChannel, error) {
- if result, err := w.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.WhatsappChannel), nil
- }
- }
- func (w whatsappChannelDo) Take() (*model.WhatsappChannel, error) {
- if result, err := w.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.WhatsappChannel), nil
- }
- }
- func (w whatsappChannelDo) Last() (*model.WhatsappChannel, error) {
- if result, err := w.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.WhatsappChannel), nil
- }
- }
- func (w whatsappChannelDo) Find() ([]*model.WhatsappChannel, error) {
- result, err := w.DO.Find()
- return result.([]*model.WhatsappChannel), err
- }
- func (w whatsappChannelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.WhatsappChannel, err error) {
- buf := make([]*model.WhatsappChannel, 0, batchSize)
- err = w.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 (w whatsappChannelDo) FindInBatches(result *[]*model.WhatsappChannel, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return w.DO.FindInBatches(result, batchSize, fc)
- }
- func (w whatsappChannelDo) Attrs(attrs ...field.AssignExpr) IWhatsappChannelDo {
- return w.withDO(w.DO.Attrs(attrs...))
- }
- func (w whatsappChannelDo) Assign(attrs ...field.AssignExpr) IWhatsappChannelDo {
- return w.withDO(w.DO.Assign(attrs...))
- }
- func (w whatsappChannelDo) Joins(fields ...field.RelationField) IWhatsappChannelDo {
- for _, _f := range fields {
- w = *w.withDO(w.DO.Joins(_f))
- }
- return &w
- }
- func (w whatsappChannelDo) Preload(fields ...field.RelationField) IWhatsappChannelDo {
- for _, _f := range fields {
- w = *w.withDO(w.DO.Preload(_f))
- }
- return &w
- }
- func (w whatsappChannelDo) FirstOrInit() (*model.WhatsappChannel, error) {
- if result, err := w.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.WhatsappChannel), nil
- }
- }
- func (w whatsappChannelDo) FirstOrCreate() (*model.WhatsappChannel, error) {
- if result, err := w.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.WhatsappChannel), nil
- }
- }
- func (w whatsappChannelDo) FindByPage(offset int, limit int) (result []*model.WhatsappChannel, count int64, err error) {
- result, err = w.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 = w.Offset(-1).Limit(-1).Count()
- return
- }
- func (w whatsappChannelDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = w.Count()
- if err != nil {
- return
- }
- err = w.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (w whatsappChannelDo) Scan(result interface{}) (err error) {
- return w.DO.Scan(result)
- }
- func (w whatsappChannelDo) Delete(models ...*model.WhatsappChannel) (result gen.ResultInfo, err error) {
- return w.DO.Delete(models)
- }
- func (w *whatsappChannelDo) withDO(do gen.Dao) *whatsappChannelDo {
- w.DO = *do.(*gen.DO)
- return w
- }
|