123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477 |
- // 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 newBatchMsg(db *gorm.DB, opts ...gen.DOOption) batchMsg {
- _batchMsg := batchMsg{}
- _batchMsg.batchMsgDo.UseDB(db, opts...)
- _batchMsg.batchMsgDo.UseModel(&model.BatchMsg{})
- tableName := _batchMsg.batchMsgDo.TableName()
- _batchMsg.ALL = field.NewAsterisk(tableName)
- _batchMsg.ID = field.NewInt64(tableName, "id")
- _batchMsg.CreatedAt = field.NewTime(tableName, "created_at")
- _batchMsg.UpdatedAt = field.NewTime(tableName, "updated_at")
- _batchMsg.DeletedAt = field.NewField(tableName, "deleted_at")
- _batchMsg.TaskName = field.NewString(tableName, "task_name")
- _batchMsg.Status = field.NewInt64(tableName, "status")
- _batchMsg.BatchNo = field.NewString(tableName, "batch_no")
- _batchMsg.Fromwxid = field.NewString(tableName, "fromwxid")
- _batchMsg.Msg = field.NewString(tableName, "msg")
- _batchMsg.Tagids = field.NewString(tableName, "tagids")
- _batchMsg.Tag = field.NewString(tableName, "tag")
- _batchMsg.Total = field.NewInt64(tableName, "total")
- _batchMsg.Success = field.NewInt64(tableName, "success")
- _batchMsg.Fail = field.NewInt64(tableName, "fail")
- _batchMsg.StartTime = field.NewTime(tableName, "start_time")
- _batchMsg.StopTime = field.NewTime(tableName, "stop_time")
- _batchMsg.SendTime = field.NewTime(tableName, "send_time")
- _batchMsg.Type = field.NewInt64(tableName, "type")
- _batchMsg.OrganizationID = field.NewInt64(tableName, "organization_id")
- _batchMsg.Ctype = field.NewInt64(tableName, "ctype")
- _batchMsg.Cc = field.NewString(tableName, "cc")
- _batchMsg.Phone = field.NewString(tableName, "phone")
- _batchMsg.TemplateName = field.NewString(tableName, "template_name")
- _batchMsg.TemplateCode = field.NewString(tableName, "template_code")
- _batchMsg.Lang = field.NewString(tableName, "lang")
- _batchMsg.fillFieldMap()
- return _batchMsg
- }
- // batchMsg 批量消息表
- type batchMsg struct {
- batchMsgDo
- ALL field.Asterisk
- ID field.Int64
- CreatedAt field.Time // Create Time | 创建日期
- UpdatedAt field.Time // Update Time | 修改日期
- DeletedAt field.Field // Delete Time | 删除日期
- TaskName field.String // 群发任务名称
- Status field.Int64 // 状态 0 未开始 1 发送中 2 发送完成 3 发送中止
- BatchNo field.String // 批次号
- Fromwxid field.String // 发送方微信ID
- Msg field.String // 内容
- Tagids field.String // 需要发送的tagids
- Tag field.String // 发送规则 all 全部 tag1,tag2 按tag发送
- Total field.Int64 // 总数
- Success field.Int64 // 成功数量
- Fail field.Int64 // 失败数量
- StartTime field.Time // 开始时间
- StopTime field.Time // 结束时间
- SendTime field.Time // 发送时间
- Type field.Int64 // 1-群发消息 2-群发朋友圈
- OrganizationID field.Int64 // 机构ID
- Ctype field.Int64 // 内容类型:1-微信 2-whatsapp 3-企微
- Cc field.String // 国家区号
- Phone field.String // 手机号
- TemplateName field.String // 模板名
- TemplateCode field.String // 模板code
- Lang field.String // 模板语言
- fieldMap map[string]field.Expr
- }
- func (b batchMsg) Table(newTableName string) *batchMsg {
- b.batchMsgDo.UseTable(newTableName)
- return b.updateTableName(newTableName)
- }
- func (b batchMsg) As(alias string) *batchMsg {
- b.batchMsgDo.DO = *(b.batchMsgDo.As(alias).(*gen.DO))
- return b.updateTableName(alias)
- }
- func (b *batchMsg) updateTableName(table string) *batchMsg {
- b.ALL = field.NewAsterisk(table)
- b.ID = field.NewInt64(table, "id")
- b.CreatedAt = field.NewTime(table, "created_at")
- b.UpdatedAt = field.NewTime(table, "updated_at")
- b.DeletedAt = field.NewField(table, "deleted_at")
- b.TaskName = field.NewString(table, "task_name")
- b.Status = field.NewInt64(table, "status")
- b.BatchNo = field.NewString(table, "batch_no")
- b.Fromwxid = field.NewString(table, "fromwxid")
- b.Msg = field.NewString(table, "msg")
- b.Tagids = field.NewString(table, "tagids")
- b.Tag = field.NewString(table, "tag")
- b.Total = field.NewInt64(table, "total")
- b.Success = field.NewInt64(table, "success")
- b.Fail = field.NewInt64(table, "fail")
- b.StartTime = field.NewTime(table, "start_time")
- b.StopTime = field.NewTime(table, "stop_time")
- b.SendTime = field.NewTime(table, "send_time")
- b.Type = field.NewInt64(table, "type")
- b.OrganizationID = field.NewInt64(table, "organization_id")
- b.Ctype = field.NewInt64(table, "ctype")
- b.Cc = field.NewString(table, "cc")
- b.Phone = field.NewString(table, "phone")
- b.TemplateName = field.NewString(table, "template_name")
- b.TemplateCode = field.NewString(table, "template_code")
- b.Lang = field.NewString(table, "lang")
- b.fillFieldMap()
- return b
- }
- func (b *batchMsg) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := b.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (b *batchMsg) fillFieldMap() {
- b.fieldMap = make(map[string]field.Expr, 25)
- b.fieldMap["id"] = b.ID
- b.fieldMap["created_at"] = b.CreatedAt
- b.fieldMap["updated_at"] = b.UpdatedAt
- b.fieldMap["deleted_at"] = b.DeletedAt
- b.fieldMap["task_name"] = b.TaskName
- b.fieldMap["status"] = b.Status
- b.fieldMap["batch_no"] = b.BatchNo
- b.fieldMap["fromwxid"] = b.Fromwxid
- b.fieldMap["msg"] = b.Msg
- b.fieldMap["tagids"] = b.Tagids
- b.fieldMap["tag"] = b.Tag
- b.fieldMap["total"] = b.Total
- b.fieldMap["success"] = b.Success
- b.fieldMap["fail"] = b.Fail
- b.fieldMap["start_time"] = b.StartTime
- b.fieldMap["stop_time"] = b.StopTime
- b.fieldMap["send_time"] = b.SendTime
- b.fieldMap["type"] = b.Type
- b.fieldMap["organization_id"] = b.OrganizationID
- b.fieldMap["ctype"] = b.Ctype
- b.fieldMap["cc"] = b.Cc
- b.fieldMap["phone"] = b.Phone
- b.fieldMap["template_name"] = b.TemplateName
- b.fieldMap["template_code"] = b.TemplateCode
- b.fieldMap["lang"] = b.Lang
- }
- func (b batchMsg) clone(db *gorm.DB) batchMsg {
- b.batchMsgDo.ReplaceConnPool(db.Statement.ConnPool)
- return b
- }
- func (b batchMsg) replaceDB(db *gorm.DB) batchMsg {
- b.batchMsgDo.ReplaceDB(db)
- return b
- }
- type batchMsgDo struct{ gen.DO }
- type IBatchMsgDo interface {
- gen.SubQuery
- Debug() IBatchMsgDo
- WithContext(ctx context.Context) IBatchMsgDo
- WithResult(fc func(tx gen.Dao)) gen.ResultInfo
- ReplaceDB(db *gorm.DB)
- ReadDB() IBatchMsgDo
- WriteDB() IBatchMsgDo
- As(alias string) gen.Dao
- Session(config *gorm.Session) IBatchMsgDo
- Columns(cols ...field.Expr) gen.Columns
- Clauses(conds ...clause.Expression) IBatchMsgDo
- Not(conds ...gen.Condition) IBatchMsgDo
- Or(conds ...gen.Condition) IBatchMsgDo
- Select(conds ...field.Expr) IBatchMsgDo
- Where(conds ...gen.Condition) IBatchMsgDo
- Order(conds ...field.Expr) IBatchMsgDo
- Distinct(cols ...field.Expr) IBatchMsgDo
- Omit(cols ...field.Expr) IBatchMsgDo
- Join(table schema.Tabler, on ...field.Expr) IBatchMsgDo
- LeftJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo
- RightJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo
- Group(cols ...field.Expr) IBatchMsgDo
- Having(conds ...gen.Condition) IBatchMsgDo
- Limit(limit int) IBatchMsgDo
- Offset(offset int) IBatchMsgDo
- Count() (count int64, err error)
- Scopes(funcs ...func(gen.Dao) gen.Dao) IBatchMsgDo
- Unscoped() IBatchMsgDo
- Create(values ...*model.BatchMsg) error
- CreateInBatches(values []*model.BatchMsg, batchSize int) error
- Save(values ...*model.BatchMsg) error
- First() (*model.BatchMsg, error)
- Take() (*model.BatchMsg, error)
- Last() (*model.BatchMsg, error)
- Find() ([]*model.BatchMsg, error)
- FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BatchMsg, err error)
- FindInBatches(result *[]*model.BatchMsg, batchSize int, fc func(tx gen.Dao, batch int) error) error
- Pluck(column field.Expr, dest interface{}) error
- Delete(...*model.BatchMsg) (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) IBatchMsgDo
- Assign(attrs ...field.AssignExpr) IBatchMsgDo
- Joins(fields ...field.RelationField) IBatchMsgDo
- Preload(fields ...field.RelationField) IBatchMsgDo
- FirstOrInit() (*model.BatchMsg, error)
- FirstOrCreate() (*model.BatchMsg, error)
- FindByPage(offset int, limit int) (result []*model.BatchMsg, 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) IBatchMsgDo
- UnderlyingDB() *gorm.DB
- schema.Tabler
- }
- func (b batchMsgDo) Debug() IBatchMsgDo {
- return b.withDO(b.DO.Debug())
- }
- func (b batchMsgDo) WithContext(ctx context.Context) IBatchMsgDo {
- return b.withDO(b.DO.WithContext(ctx))
- }
- func (b batchMsgDo) ReadDB() IBatchMsgDo {
- return b.Clauses(dbresolver.Read)
- }
- func (b batchMsgDo) WriteDB() IBatchMsgDo {
- return b.Clauses(dbresolver.Write)
- }
- func (b batchMsgDo) Session(config *gorm.Session) IBatchMsgDo {
- return b.withDO(b.DO.Session(config))
- }
- func (b batchMsgDo) Clauses(conds ...clause.Expression) IBatchMsgDo {
- return b.withDO(b.DO.Clauses(conds...))
- }
- func (b batchMsgDo) Returning(value interface{}, columns ...string) IBatchMsgDo {
- return b.withDO(b.DO.Returning(value, columns...))
- }
- func (b batchMsgDo) Not(conds ...gen.Condition) IBatchMsgDo {
- return b.withDO(b.DO.Not(conds...))
- }
- func (b batchMsgDo) Or(conds ...gen.Condition) IBatchMsgDo {
- return b.withDO(b.DO.Or(conds...))
- }
- func (b batchMsgDo) Select(conds ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Select(conds...))
- }
- func (b batchMsgDo) Where(conds ...gen.Condition) IBatchMsgDo {
- return b.withDO(b.DO.Where(conds...))
- }
- func (b batchMsgDo) Order(conds ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Order(conds...))
- }
- func (b batchMsgDo) Distinct(cols ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Distinct(cols...))
- }
- func (b batchMsgDo) Omit(cols ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Omit(cols...))
- }
- func (b batchMsgDo) Join(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Join(table, on...))
- }
- func (b batchMsgDo) LeftJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.LeftJoin(table, on...))
- }
- func (b batchMsgDo) RightJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.RightJoin(table, on...))
- }
- func (b batchMsgDo) Group(cols ...field.Expr) IBatchMsgDo {
- return b.withDO(b.DO.Group(cols...))
- }
- func (b batchMsgDo) Having(conds ...gen.Condition) IBatchMsgDo {
- return b.withDO(b.DO.Having(conds...))
- }
- func (b batchMsgDo) Limit(limit int) IBatchMsgDo {
- return b.withDO(b.DO.Limit(limit))
- }
- func (b batchMsgDo) Offset(offset int) IBatchMsgDo {
- return b.withDO(b.DO.Offset(offset))
- }
- func (b batchMsgDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IBatchMsgDo {
- return b.withDO(b.DO.Scopes(funcs...))
- }
- func (b batchMsgDo) Unscoped() IBatchMsgDo {
- return b.withDO(b.DO.Unscoped())
- }
- func (b batchMsgDo) Create(values ...*model.BatchMsg) error {
- if len(values) == 0 {
- return nil
- }
- return b.DO.Create(values)
- }
- func (b batchMsgDo) CreateInBatches(values []*model.BatchMsg, batchSize int) error {
- return b.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 (b batchMsgDo) Save(values ...*model.BatchMsg) error {
- if len(values) == 0 {
- return nil
- }
- return b.DO.Save(values)
- }
- func (b batchMsgDo) First() (*model.BatchMsg, error) {
- if result, err := b.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.BatchMsg), nil
- }
- }
- func (b batchMsgDo) Take() (*model.BatchMsg, error) {
- if result, err := b.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.BatchMsg), nil
- }
- }
- func (b batchMsgDo) Last() (*model.BatchMsg, error) {
- if result, err := b.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.BatchMsg), nil
- }
- }
- func (b batchMsgDo) Find() ([]*model.BatchMsg, error) {
- result, err := b.DO.Find()
- return result.([]*model.BatchMsg), err
- }
- func (b batchMsgDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BatchMsg, err error) {
- buf := make([]*model.BatchMsg, 0, batchSize)
- err = b.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 (b batchMsgDo) FindInBatches(result *[]*model.BatchMsg, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return b.DO.FindInBatches(result, batchSize, fc)
- }
- func (b batchMsgDo) Attrs(attrs ...field.AssignExpr) IBatchMsgDo {
- return b.withDO(b.DO.Attrs(attrs...))
- }
- func (b batchMsgDo) Assign(attrs ...field.AssignExpr) IBatchMsgDo {
- return b.withDO(b.DO.Assign(attrs...))
- }
- func (b batchMsgDo) Joins(fields ...field.RelationField) IBatchMsgDo {
- for _, _f := range fields {
- b = *b.withDO(b.DO.Joins(_f))
- }
- return &b
- }
- func (b batchMsgDo) Preload(fields ...field.RelationField) IBatchMsgDo {
- for _, _f := range fields {
- b = *b.withDO(b.DO.Preload(_f))
- }
- return &b
- }
- func (b batchMsgDo) FirstOrInit() (*model.BatchMsg, error) {
- if result, err := b.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.BatchMsg), nil
- }
- }
- func (b batchMsgDo) FirstOrCreate() (*model.BatchMsg, error) {
- if result, err := b.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.BatchMsg), nil
- }
- }
- func (b batchMsgDo) FindByPage(offset int, limit int) (result []*model.BatchMsg, count int64, err error) {
- result, err = b.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 = b.Offset(-1).Limit(-1).Count()
- return
- }
- func (b batchMsgDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = b.Count()
- if err != nil {
- return
- }
- err = b.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (b batchMsgDo) Scan(result interface{}) (err error) {
- return b.DO.Scan(result)
- }
- func (b batchMsgDo) Delete(models ...*model.BatchMsg) (result gen.ResultInfo, err error) {
- return b.DO.Delete(models)
- }
- func (b *batchMsgDo) withDO(do gen.Dao) *batchMsgDo {
- b.DO = *do.(*gen.DO)
- return b
- }
|