up_base.go 742 B

12345678910111213141516171819202122232425262728293031323334
  1. package card
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/library/log"
  6. )
  7. const _listUpBaseSQL = "SELECT id, mid FROM up_base_info WHERE id > ? AND business_type = 1 %s LIMIT ?"
  8. // ListUpBase list <id, mid> k-v pairs
  9. func (d *Dao) ListUpBase(c context.Context, size int, lastID int64, where string) (idMids map[int64]int64, err error) {
  10. idMids = make(map[int64]int64)
  11. rows, err := d.db.Query(c, fmt.Sprintf(_listUpBaseSQL, where), lastID, size)
  12. if err != nil {
  13. log.Error("ListUpBase d.db.Query error(%v)", err)
  14. return
  15. }
  16. defer rows.Close()
  17. for rows.Next() {
  18. var mid int64
  19. var id int64
  20. err = rows.Scan(&id, &mid)
  21. if err != nil {
  22. log.Error("ListUpBase rows.Scan error(%v)", err)
  23. return
  24. }
  25. idMids[id] = mid
  26. }
  27. return
  28. }