blocked.go 819 B

12345678910111213141516171819202122232425262728293031
  1. package dao
  2. import (
  3. "context"
  4. "time"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _countBlockedSQL = "SELECT COUNT(*) FROM blocked_info WHERE uid=? AND ctime > ? AND status = 0"
  9. _blockedInfoID = "SELECT id FROM blocked_info WHERE uid=? ORDER BY id DESC"
  10. )
  11. // CountBlocked get user block count ofter ts.
  12. func (d *Dao) CountBlocked(c context.Context, uid int64, ts time.Time) (count int64, err error) {
  13. row := d.db.QueryRow(c, _countBlockedSQL, uid, ts)
  14. if err = row.Scan(&count); err != nil {
  15. log.Error("d.CountBlocked err(%v)", err)
  16. }
  17. return
  18. }
  19. // BlockedInfoID get user blocked new info.
  20. func (d *Dao) BlockedInfoID(c context.Context, uid int64) (id int64, err error) {
  21. row := d.db.QueryRow(c, _blockedInfoID, uid)
  22. if err = row.Scan(&id); err != nil {
  23. log.Error("d.BlockedInfoID err(%v)", err)
  24. }
  25. return
  26. }