passed.go 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package ugc
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/job/main/tv/model/common"
  6. "go-common/library/database/sql"
  7. "go-common/library/log"
  8. "go-common/library/xstr"
  9. )
  10. const (
  11. _passedArc = "SELECT aid, ctime FROM ugc_archive WHERE typeid IN (%s) AND result = 1 AND valid = 1 and deleted = 0"
  12. )
  13. // PassedArcs picks the passed Arc data for Idx Page
  14. func (d *Dao) PassedArcs(c context.Context, tids []int64) (res []*common.IdxRank, err error) {
  15. if len(tids) == 0 {
  16. return
  17. }
  18. var (
  19. rows *sql.Rows
  20. tidsStr = xstr.JoinInts(tids)
  21. )
  22. if rows, err = d.DB.Query(c, fmt.Sprintf(_passedArc, tidsStr)); err != nil {
  23. log.Error("d.PassedArcs.Query error(%v)", err)
  24. return
  25. }
  26. defer rows.Close()
  27. for rows.Next() {
  28. var r = &common.IdxRank{}
  29. if err = rows.Scan(&r.ID, &r.Ctime); err != nil {
  30. log.Error("PassedArcs row.Scan() error(%v)", err)
  31. return
  32. }
  33. res = append(res, r)
  34. }
  35. if err = rows.Err(); err != nil {
  36. log.Error("d.PassedArcs.Query error(%v)", err)
  37. }
  38. return
  39. }