blacklist.go 769 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package income
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. )
  6. const (
  7. _blacklistSQL = "SELECT id,av_id,ctype,is_delete FROM av_black_list WHERE id > ? ORDER BY id LIMIT ?"
  8. )
  9. // Blacklist map[ctype][]id
  10. func (d *Dao) Blacklist(c context.Context, id int64, limit int64) (m map[int][]int64, last int64, err error) {
  11. rows, err := d.db.Query(c, _blacklistSQL, id, limit)
  12. if err != nil {
  13. return
  14. }
  15. m = make(map[int][]int64)
  16. for rows.Next() {
  17. var ctype, isDeleted int
  18. var avID int64
  19. err = rows.Scan(&last, &avID, &ctype, &isDeleted)
  20. if err != nil {
  21. log.Error("Rows Scan error(%v)", err)
  22. return
  23. }
  24. if isDeleted == 0 {
  25. if _, ok := m[ctype]; ok {
  26. m[ctype] = append(m[ctype], avID)
  27. } else {
  28. m[ctype] = []int64{avID}
  29. }
  30. }
  31. }
  32. return
  33. }