up_quality_info.go 905 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/job/main/growup/model"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _upQualitySQL = "SELECT id,mid,quality_value FROM %s WHERE id > ? AND is_deleted = 0 ORDER BY id LIMIT ?"
  10. )
  11. // GetUpQuality get up_quality_info
  12. func (d *Dao) GetUpQuality(c context.Context, table string, id int64, limit int) (up []*model.UpQuality, last int64, err error) {
  13. up = make([]*model.UpQuality, 0)
  14. if table == "" {
  15. err = fmt.Errorf("ERROR: table is null")
  16. return
  17. }
  18. rows, err := d.db.Query(c, fmt.Sprintf(_upQualitySQL, table), id, limit)
  19. if err != nil {
  20. log.Error("GetUpQuality d.db.Query error(%v)", err)
  21. return
  22. }
  23. defer rows.Close()
  24. for rows.Next() {
  25. u := &model.UpQuality{}
  26. err = rows.Scan(&last, &u.MID, &u.Quality)
  27. if err != nil {
  28. log.Error("GetUpQuality rows.Scan error(%v)", err)
  29. return
  30. }
  31. up = append(up, u)
  32. }
  33. err = rows.Err()
  34. return
  35. }