associate_banner.go 865 B

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/vip/model"
  5. "go-common/library/database/sql"
  6. "github.com/pkg/errors"
  7. )
  8. const (
  9. _effectiveAssociateVipsSQL = "SELECT title,remark,link,associate_platform FROM vip_associate_vip WHERE state = 0 AND deleted = 0 ORDER BY order_num DESC;"
  10. )
  11. // EffectiveAssociateVips effective associate vips.
  12. func (d *Dao) EffectiveAssociateVips(c context.Context) (res []*model.AssociateVipResp, err error) {
  13. var rows *sql.Rows
  14. if rows, err = d.db.Query(c, _effectiveAssociateVipsSQL); err != nil {
  15. err = errors.WithStack(err)
  16. return
  17. }
  18. defer rows.Close()
  19. for rows.Next() {
  20. r := new(model.AssociateVipResp)
  21. if err = rows.Scan(&r.Title, &r.Remark, &r.Link, &r.AssociatePlatform); err != nil {
  22. err = errors.WithStack(err)
  23. res = nil
  24. return
  25. }
  26. res = append(res, r)
  27. }
  28. err = rows.Err()
  29. return
  30. }