push.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/job/main/vip/model"
  5. "go-common/library/database/sql"
  6. "github.com/pkg/errors"
  7. )
  8. //PushDatas get push datas
  9. func (d *Dao) PushDatas(c context.Context, curtime string) (res []*model.VipPushData, err error) {
  10. var rows *sql.Rows
  11. if rows, err = d.db.Query(c, _selPushDataSQL, curtime, curtime); err != nil {
  12. err = errors.WithStack(err)
  13. return
  14. }
  15. defer rows.Close()
  16. for rows.Next() {
  17. r := new(model.VipPushData)
  18. if err = rows.Scan(&r.ID, &r.DisableType, &r.GroupName, &r.Title, &r.Content, &r.PushTotalCount, &r.PushedCount, &r.ProgressStatus, &r.Status, &r.Platform, &r.LinkType, &r.LinkURL, &r.ErrorCode, &r.ExpiredDayStart, &r.ExpiredDayEnd, &r.EffectStartDate, &r.EffectEndDate, &r.PushStartTime, &r.PushEndTime); err != nil {
  19. err = errors.WithStack(err)
  20. return
  21. }
  22. res = append(res, r)
  23. }
  24. err = rows.Err()
  25. return
  26. }
  27. //UpdatePushData update push data
  28. func (d *Dao) UpdatePushData(c context.Context, status, progressStatus int8, pushedCount int32, errcode, data, id int64) (err error) {
  29. if _, err = d.db.Exec(c, _updatePushDataSQL, progressStatus, status, pushedCount, errcode, data, id); err != nil {
  30. err = errors.WithStack(err)
  31. d.errProm.Incr("exec_err")
  32. }
  33. return
  34. }