recommend_up.go 849 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package newbiedao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/growup/model"
  5. "go-common/library/log"
  6. )
  7. const _RecommendUpSql = "SELECT mid, tid FROM recommend_up_white"
  8. // GetRecommendUpList get recommend up list
  9. func (d *Dao) GetRecommendUpList(c context.Context) error {
  10. recUps := make(map[int64]map[int64]*model.RecommendUp)
  11. rows, err := d.db.Query(c, _RecommendUpSql)
  12. if err != nil {
  13. log.Error("d.db.Query recommend up error(%v)", err)
  14. return err
  15. }
  16. defer rows.Close()
  17. for rows.Next() {
  18. recUp := new(model.RecommendUp)
  19. err = rows.Scan(&recUp.Mid, &recUp.Tid)
  20. if err != nil {
  21. log.Error("rows scan error(%v)", err)
  22. return err
  23. }
  24. if _, ok := recUps[recUp.Tid]; !ok {
  25. recUps[recUp.Tid] = make(map[int64]*model.RecommendUp)
  26. }
  27. recUps[recUp.Tid][recUp.Mid] = recUp
  28. }
  29. RecommendUpList = recUps
  30. return nil
  31. }