blacklist.go 589 B

123456789101112131415161718192021222324252627282930313233
  1. package income
  2. import (
  3. "context"
  4. )
  5. // Blacklist map[ctype]map[int64]bool
  6. func (s *Service) Blacklist(c context.Context, limit int64) (m map[int]map[int64]bool, err error) {
  7. var id int64
  8. m = make(map[int]map[int64]bool)
  9. for {
  10. var ab map[int][]int64
  11. ab, id, err = s.dao.Blacklist(c, id, limit)
  12. if err != nil {
  13. return
  14. }
  15. if len(ab) == 0 {
  16. break
  17. }
  18. for ctype, avIDs := range ab {
  19. for _, avID := range avIDs {
  20. if _, ok := m[ctype]; ok {
  21. m[ctype][avID] = true
  22. } else {
  23. m[ctype] = map[int64]bool{
  24. avID: true,
  25. }
  26. }
  27. }
  28. }
  29. }
  30. return
  31. }