up_info_video.go 914 B

123456789101112131415161718192021222324252627282930313233343536
  1. package income
  2. import (
  3. "context"
  4. "fmt"
  5. model "go-common/app/job/main/growup/model/income"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _signedSQL = "SELECT id,mid,signed_at,quit_at,account_state,is_deleted FROM up_info_%s WHERE id > ? ORDER BY id LIMIT ?"
  10. )
  11. // Ups get ups by business type
  12. func (d *Dao) Ups(c context.Context, business string, offset int64, limit int64) (last int64, ups map[int64]*model.Signed, err error) {
  13. ups = make(map[int64]*model.Signed)
  14. rows, err := d.db.Query(c, fmt.Sprintf(_signedSQL, business), offset, limit)
  15. if err != nil {
  16. log.Error("db Query Signed up Info error(%v)", err)
  17. return
  18. }
  19. defer rows.Close()
  20. for rows.Next() {
  21. up := &model.Signed{}
  22. err = rows.Scan(&last, &up.MID, &up.SignedAt, &up.QuitAt, &up.AccountState, &up.IsDeleted)
  23. if err != nil {
  24. log.Error("rows scan error(%v)", err)
  25. return
  26. }
  27. if up.IsDeleted == 0 {
  28. ups[up.MID] = up
  29. }
  30. }
  31. return
  32. }