blacklist.go 745 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dao
  2. import (
  3. "context"
  4. xsql "go-common/library/database/sql"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _blacklistSQL = `SELECT mid FROM blacklist WHERE status = 0`
  9. )
  10. // Blacklist get blacklist from db.
  11. func (d *Dao) Blacklist(c context.Context) (blacklist []int64, err error) {
  12. var (
  13. rows *xsql.Rows
  14. )
  15. if rows, err = d.db.Query(c, _blacklistSQL); err != nil {
  16. log.Error("dao.Modules.Query error(%v)", err)
  17. return
  18. }
  19. defer rows.Close()
  20. for rows.Next() {
  21. var mid int64
  22. if err = rows.Scan(&mid); err != nil {
  23. log.Error("Space dao Modules:row.Scan() error(%v)", err)
  24. return
  25. }
  26. blacklist = append(blacklist, mid)
  27. }
  28. if err = rows.Err(); err != nil {
  29. log.Error("Space dao Modules.Err() error(%v)", err)
  30. }
  31. return
  32. }