batch_msg.gen.go 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package query
  5. import (
  6. "context"
  7. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "wechat-api/database/dao/wechat/model"
  14. )
  15. func newBatchMsg(db *gorm.DB, opts ...gen.DOOption) batchMsg {
  16. _batchMsg := batchMsg{}
  17. _batchMsg.batchMsgDo.UseDB(db, opts...)
  18. _batchMsg.batchMsgDo.UseModel(&model.BatchMsg{})
  19. tableName := _batchMsg.batchMsgDo.TableName()
  20. _batchMsg.ALL = field.NewAsterisk(tableName)
  21. _batchMsg.ID = field.NewInt64(tableName, "id")
  22. _batchMsg.CreatedAt = field.NewTime(tableName, "created_at")
  23. _batchMsg.UpdatedAt = field.NewTime(tableName, "updated_at")
  24. _batchMsg.DeletedAt = field.NewField(tableName, "deleted_at")
  25. _batchMsg.TaskName = field.NewString(tableName, "task_name")
  26. _batchMsg.Status = field.NewInt64(tableName, "status")
  27. _batchMsg.BatchNo = field.NewString(tableName, "batch_no")
  28. _batchMsg.Fromwxid = field.NewString(tableName, "fromwxid")
  29. _batchMsg.Msg = field.NewString(tableName, "msg")
  30. _batchMsg.Tagids = field.NewString(tableName, "tagids")
  31. _batchMsg.Tag = field.NewString(tableName, "tag")
  32. _batchMsg.Total = field.NewInt64(tableName, "total")
  33. _batchMsg.Success = field.NewInt64(tableName, "success")
  34. _batchMsg.Fail = field.NewInt64(tableName, "fail")
  35. _batchMsg.StartTime = field.NewTime(tableName, "start_time")
  36. _batchMsg.StopTime = field.NewTime(tableName, "stop_time")
  37. _batchMsg.SendTime = field.NewTime(tableName, "send_time")
  38. _batchMsg.Type = field.NewInt64(tableName, "type")
  39. _batchMsg.OrganizationID = field.NewInt64(tableName, "organization_id")
  40. _batchMsg.Ctype = field.NewInt64(tableName, "ctype")
  41. _batchMsg.Cc = field.NewString(tableName, "cc")
  42. _batchMsg.Phone = field.NewString(tableName, "phone")
  43. _batchMsg.TemplateName = field.NewString(tableName, "template_name")
  44. _batchMsg.TemplateCode = field.NewString(tableName, "template_code")
  45. _batchMsg.Lang = field.NewString(tableName, "lang")
  46. _batchMsg.fillFieldMap()
  47. return _batchMsg
  48. }
  49. // batchMsg 批量消息表
  50. type batchMsg struct {
  51. batchMsgDo
  52. ALL field.Asterisk
  53. ID field.Int64
  54. CreatedAt field.Time // Create Time | 创建日期
  55. UpdatedAt field.Time // Update Time | 修改日期
  56. DeletedAt field.Field // Delete Time | 删除日期
  57. TaskName field.String // 群发任务名称
  58. Status field.Int64 // 状态 0 未开始 1 发送中 2 发送完成 3 发送中止
  59. BatchNo field.String // 批次号
  60. Fromwxid field.String // 发送方微信ID
  61. Msg field.String // 内容
  62. Tagids field.String // 需要发送的tagids
  63. Tag field.String // 发送规则 all 全部 tag1,tag2 按tag发送
  64. Total field.Int64 // 总数
  65. Success field.Int64 // 成功数量
  66. Fail field.Int64 // 失败数量
  67. StartTime field.Time // 开始时间
  68. StopTime field.Time // 结束时间
  69. SendTime field.Time // 发送时间
  70. Type field.Int64 // 1-群发消息 2-群发朋友圈
  71. OrganizationID field.Int64 // 机构ID
  72. Ctype field.Int64 // 内容类型:1-微信 2-whatsapp 3-企微
  73. Cc field.String // 国家区号
  74. Phone field.String // 手机号
  75. TemplateName field.String // 模板名
  76. TemplateCode field.String // 模板code
  77. Lang field.String // 模板语言
  78. fieldMap map[string]field.Expr
  79. }
  80. func (b batchMsg) Table(newTableName string) *batchMsg {
  81. b.batchMsgDo.UseTable(newTableName)
  82. return b.updateTableName(newTableName)
  83. }
  84. func (b batchMsg) As(alias string) *batchMsg {
  85. b.batchMsgDo.DO = *(b.batchMsgDo.As(alias).(*gen.DO))
  86. return b.updateTableName(alias)
  87. }
  88. func (b *batchMsg) updateTableName(table string) *batchMsg {
  89. b.ALL = field.NewAsterisk(table)
  90. b.ID = field.NewInt64(table, "id")
  91. b.CreatedAt = field.NewTime(table, "created_at")
  92. b.UpdatedAt = field.NewTime(table, "updated_at")
  93. b.DeletedAt = field.NewField(table, "deleted_at")
  94. b.TaskName = field.NewString(table, "task_name")
  95. b.Status = field.NewInt64(table, "status")
  96. b.BatchNo = field.NewString(table, "batch_no")
  97. b.Fromwxid = field.NewString(table, "fromwxid")
  98. b.Msg = field.NewString(table, "msg")
  99. b.Tagids = field.NewString(table, "tagids")
  100. b.Tag = field.NewString(table, "tag")
  101. b.Total = field.NewInt64(table, "total")
  102. b.Success = field.NewInt64(table, "success")
  103. b.Fail = field.NewInt64(table, "fail")
  104. b.StartTime = field.NewTime(table, "start_time")
  105. b.StopTime = field.NewTime(table, "stop_time")
  106. b.SendTime = field.NewTime(table, "send_time")
  107. b.Type = field.NewInt64(table, "type")
  108. b.OrganizationID = field.NewInt64(table, "organization_id")
  109. b.Ctype = field.NewInt64(table, "ctype")
  110. b.Cc = field.NewString(table, "cc")
  111. b.Phone = field.NewString(table, "phone")
  112. b.TemplateName = field.NewString(table, "template_name")
  113. b.TemplateCode = field.NewString(table, "template_code")
  114. b.Lang = field.NewString(table, "lang")
  115. b.fillFieldMap()
  116. return b
  117. }
  118. func (b *batchMsg) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  119. _f, ok := b.fieldMap[fieldName]
  120. if !ok || _f == nil {
  121. return nil, false
  122. }
  123. _oe, ok := _f.(field.OrderExpr)
  124. return _oe, ok
  125. }
  126. func (b *batchMsg) fillFieldMap() {
  127. b.fieldMap = make(map[string]field.Expr, 25)
  128. b.fieldMap["id"] = b.ID
  129. b.fieldMap["created_at"] = b.CreatedAt
  130. b.fieldMap["updated_at"] = b.UpdatedAt
  131. b.fieldMap["deleted_at"] = b.DeletedAt
  132. b.fieldMap["task_name"] = b.TaskName
  133. b.fieldMap["status"] = b.Status
  134. b.fieldMap["batch_no"] = b.BatchNo
  135. b.fieldMap["fromwxid"] = b.Fromwxid
  136. b.fieldMap["msg"] = b.Msg
  137. b.fieldMap["tagids"] = b.Tagids
  138. b.fieldMap["tag"] = b.Tag
  139. b.fieldMap["total"] = b.Total
  140. b.fieldMap["success"] = b.Success
  141. b.fieldMap["fail"] = b.Fail
  142. b.fieldMap["start_time"] = b.StartTime
  143. b.fieldMap["stop_time"] = b.StopTime
  144. b.fieldMap["send_time"] = b.SendTime
  145. b.fieldMap["type"] = b.Type
  146. b.fieldMap["organization_id"] = b.OrganizationID
  147. b.fieldMap["ctype"] = b.Ctype
  148. b.fieldMap["cc"] = b.Cc
  149. b.fieldMap["phone"] = b.Phone
  150. b.fieldMap["template_name"] = b.TemplateName
  151. b.fieldMap["template_code"] = b.TemplateCode
  152. b.fieldMap["lang"] = b.Lang
  153. }
  154. func (b batchMsg) clone(db *gorm.DB) batchMsg {
  155. b.batchMsgDo.ReplaceConnPool(db.Statement.ConnPool)
  156. return b
  157. }
  158. func (b batchMsg) replaceDB(db *gorm.DB) batchMsg {
  159. b.batchMsgDo.ReplaceDB(db)
  160. return b
  161. }
  162. type batchMsgDo struct{ gen.DO }
  163. type IBatchMsgDo interface {
  164. gen.SubQuery
  165. Debug() IBatchMsgDo
  166. WithContext(ctx context.Context) IBatchMsgDo
  167. WithResult(fc func(tx gen.Dao)) gen.ResultInfo
  168. ReplaceDB(db *gorm.DB)
  169. ReadDB() IBatchMsgDo
  170. WriteDB() IBatchMsgDo
  171. As(alias string) gen.Dao
  172. Session(config *gorm.Session) IBatchMsgDo
  173. Columns(cols ...field.Expr) gen.Columns
  174. Clauses(conds ...clause.Expression) IBatchMsgDo
  175. Not(conds ...gen.Condition) IBatchMsgDo
  176. Or(conds ...gen.Condition) IBatchMsgDo
  177. Select(conds ...field.Expr) IBatchMsgDo
  178. Where(conds ...gen.Condition) IBatchMsgDo
  179. Order(conds ...field.Expr) IBatchMsgDo
  180. Distinct(cols ...field.Expr) IBatchMsgDo
  181. Omit(cols ...field.Expr) IBatchMsgDo
  182. Join(table schema.Tabler, on ...field.Expr) IBatchMsgDo
  183. LeftJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo
  184. RightJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo
  185. Group(cols ...field.Expr) IBatchMsgDo
  186. Having(conds ...gen.Condition) IBatchMsgDo
  187. Limit(limit int) IBatchMsgDo
  188. Offset(offset int) IBatchMsgDo
  189. Count() (count int64, err error)
  190. Scopes(funcs ...func(gen.Dao) gen.Dao) IBatchMsgDo
  191. Unscoped() IBatchMsgDo
  192. Create(values ...*model.BatchMsg) error
  193. CreateInBatches(values []*model.BatchMsg, batchSize int) error
  194. Save(values ...*model.BatchMsg) error
  195. First() (*model.BatchMsg, error)
  196. Take() (*model.BatchMsg, error)
  197. Last() (*model.BatchMsg, error)
  198. Find() ([]*model.BatchMsg, error)
  199. FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BatchMsg, err error)
  200. FindInBatches(result *[]*model.BatchMsg, batchSize int, fc func(tx gen.Dao, batch int) error) error
  201. Pluck(column field.Expr, dest interface{}) error
  202. Delete(...*model.BatchMsg) (info gen.ResultInfo, err error)
  203. Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  204. UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  205. Updates(value interface{}) (info gen.ResultInfo, err error)
  206. UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
  207. UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
  208. UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
  209. UpdateFrom(q gen.SubQuery) gen.Dao
  210. Attrs(attrs ...field.AssignExpr) IBatchMsgDo
  211. Assign(attrs ...field.AssignExpr) IBatchMsgDo
  212. Joins(fields ...field.RelationField) IBatchMsgDo
  213. Preload(fields ...field.RelationField) IBatchMsgDo
  214. FirstOrInit() (*model.BatchMsg, error)
  215. FirstOrCreate() (*model.BatchMsg, error)
  216. FindByPage(offset int, limit int) (result []*model.BatchMsg, count int64, err error)
  217. ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
  218. Scan(result interface{}) (err error)
  219. Returning(value interface{}, columns ...string) IBatchMsgDo
  220. UnderlyingDB() *gorm.DB
  221. schema.Tabler
  222. }
  223. func (b batchMsgDo) Debug() IBatchMsgDo {
  224. return b.withDO(b.DO.Debug())
  225. }
  226. func (b batchMsgDo) WithContext(ctx context.Context) IBatchMsgDo {
  227. return b.withDO(b.DO.WithContext(ctx))
  228. }
  229. func (b batchMsgDo) ReadDB() IBatchMsgDo {
  230. return b.Clauses(dbresolver.Read)
  231. }
  232. func (b batchMsgDo) WriteDB() IBatchMsgDo {
  233. return b.Clauses(dbresolver.Write)
  234. }
  235. func (b batchMsgDo) Session(config *gorm.Session) IBatchMsgDo {
  236. return b.withDO(b.DO.Session(config))
  237. }
  238. func (b batchMsgDo) Clauses(conds ...clause.Expression) IBatchMsgDo {
  239. return b.withDO(b.DO.Clauses(conds...))
  240. }
  241. func (b batchMsgDo) Returning(value interface{}, columns ...string) IBatchMsgDo {
  242. return b.withDO(b.DO.Returning(value, columns...))
  243. }
  244. func (b batchMsgDo) Not(conds ...gen.Condition) IBatchMsgDo {
  245. return b.withDO(b.DO.Not(conds...))
  246. }
  247. func (b batchMsgDo) Or(conds ...gen.Condition) IBatchMsgDo {
  248. return b.withDO(b.DO.Or(conds...))
  249. }
  250. func (b batchMsgDo) Select(conds ...field.Expr) IBatchMsgDo {
  251. return b.withDO(b.DO.Select(conds...))
  252. }
  253. func (b batchMsgDo) Where(conds ...gen.Condition) IBatchMsgDo {
  254. return b.withDO(b.DO.Where(conds...))
  255. }
  256. func (b batchMsgDo) Order(conds ...field.Expr) IBatchMsgDo {
  257. return b.withDO(b.DO.Order(conds...))
  258. }
  259. func (b batchMsgDo) Distinct(cols ...field.Expr) IBatchMsgDo {
  260. return b.withDO(b.DO.Distinct(cols...))
  261. }
  262. func (b batchMsgDo) Omit(cols ...field.Expr) IBatchMsgDo {
  263. return b.withDO(b.DO.Omit(cols...))
  264. }
  265. func (b batchMsgDo) Join(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
  266. return b.withDO(b.DO.Join(table, on...))
  267. }
  268. func (b batchMsgDo) LeftJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
  269. return b.withDO(b.DO.LeftJoin(table, on...))
  270. }
  271. func (b batchMsgDo) RightJoin(table schema.Tabler, on ...field.Expr) IBatchMsgDo {
  272. return b.withDO(b.DO.RightJoin(table, on...))
  273. }
  274. func (b batchMsgDo) Group(cols ...field.Expr) IBatchMsgDo {
  275. return b.withDO(b.DO.Group(cols...))
  276. }
  277. func (b batchMsgDo) Having(conds ...gen.Condition) IBatchMsgDo {
  278. return b.withDO(b.DO.Having(conds...))
  279. }
  280. func (b batchMsgDo) Limit(limit int) IBatchMsgDo {
  281. return b.withDO(b.DO.Limit(limit))
  282. }
  283. func (b batchMsgDo) Offset(offset int) IBatchMsgDo {
  284. return b.withDO(b.DO.Offset(offset))
  285. }
  286. func (b batchMsgDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IBatchMsgDo {
  287. return b.withDO(b.DO.Scopes(funcs...))
  288. }
  289. func (b batchMsgDo) Unscoped() IBatchMsgDo {
  290. return b.withDO(b.DO.Unscoped())
  291. }
  292. func (b batchMsgDo) Create(values ...*model.BatchMsg) error {
  293. if len(values) == 0 {
  294. return nil
  295. }
  296. return b.DO.Create(values)
  297. }
  298. func (b batchMsgDo) CreateInBatches(values []*model.BatchMsg, batchSize int) error {
  299. return b.DO.CreateInBatches(values, batchSize)
  300. }
  301. // Save : !!! underlying implementation is different with GORM
  302. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  303. func (b batchMsgDo) Save(values ...*model.BatchMsg) error {
  304. if len(values) == 0 {
  305. return nil
  306. }
  307. return b.DO.Save(values)
  308. }
  309. func (b batchMsgDo) First() (*model.BatchMsg, error) {
  310. if result, err := b.DO.First(); err != nil {
  311. return nil, err
  312. } else {
  313. return result.(*model.BatchMsg), nil
  314. }
  315. }
  316. func (b batchMsgDo) Take() (*model.BatchMsg, error) {
  317. if result, err := b.DO.Take(); err != nil {
  318. return nil, err
  319. } else {
  320. return result.(*model.BatchMsg), nil
  321. }
  322. }
  323. func (b batchMsgDo) Last() (*model.BatchMsg, error) {
  324. if result, err := b.DO.Last(); err != nil {
  325. return nil, err
  326. } else {
  327. return result.(*model.BatchMsg), nil
  328. }
  329. }
  330. func (b batchMsgDo) Find() ([]*model.BatchMsg, error) {
  331. result, err := b.DO.Find()
  332. return result.([]*model.BatchMsg), err
  333. }
  334. func (b batchMsgDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.BatchMsg, err error) {
  335. buf := make([]*model.BatchMsg, 0, batchSize)
  336. err = b.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  337. defer func() { results = append(results, buf...) }()
  338. return fc(tx, batch)
  339. })
  340. return results, err
  341. }
  342. func (b batchMsgDo) FindInBatches(result *[]*model.BatchMsg, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  343. return b.DO.FindInBatches(result, batchSize, fc)
  344. }
  345. func (b batchMsgDo) Attrs(attrs ...field.AssignExpr) IBatchMsgDo {
  346. return b.withDO(b.DO.Attrs(attrs...))
  347. }
  348. func (b batchMsgDo) Assign(attrs ...field.AssignExpr) IBatchMsgDo {
  349. return b.withDO(b.DO.Assign(attrs...))
  350. }
  351. func (b batchMsgDo) Joins(fields ...field.RelationField) IBatchMsgDo {
  352. for _, _f := range fields {
  353. b = *b.withDO(b.DO.Joins(_f))
  354. }
  355. return &b
  356. }
  357. func (b batchMsgDo) Preload(fields ...field.RelationField) IBatchMsgDo {
  358. for _, _f := range fields {
  359. b = *b.withDO(b.DO.Preload(_f))
  360. }
  361. return &b
  362. }
  363. func (b batchMsgDo) FirstOrInit() (*model.BatchMsg, error) {
  364. if result, err := b.DO.FirstOrInit(); err != nil {
  365. return nil, err
  366. } else {
  367. return result.(*model.BatchMsg), nil
  368. }
  369. }
  370. func (b batchMsgDo) FirstOrCreate() (*model.BatchMsg, error) {
  371. if result, err := b.DO.FirstOrCreate(); err != nil {
  372. return nil, err
  373. } else {
  374. return result.(*model.BatchMsg), nil
  375. }
  376. }
  377. func (b batchMsgDo) FindByPage(offset int, limit int) (result []*model.BatchMsg, count int64, err error) {
  378. result, err = b.Offset(offset).Limit(limit).Find()
  379. if err != nil {
  380. return
  381. }
  382. if size := len(result); 0 < limit && 0 < size && size < limit {
  383. count = int64(size + offset)
  384. return
  385. }
  386. count, err = b.Offset(-1).Limit(-1).Count()
  387. return
  388. }
  389. func (b batchMsgDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  390. count, err = b.Count()
  391. if err != nil {
  392. return
  393. }
  394. err = b.Offset(offset).Limit(limit).Scan(result)
  395. return
  396. }
  397. func (b batchMsgDo) Scan(result interface{}) (err error) {
  398. return b.DO.Scan(result)
  399. }
  400. func (b batchMsgDo) Delete(models ...*model.BatchMsg) (result gen.ResultInfo, err error) {
  401. return b.DO.Delete(models)
  402. }
  403. func (b *batchMsgDo) withDO(do gen.Dao) *batchMsgDo {
  404. b.DO = *do.(*gen.DO)
  405. return b
  406. }