jointly.go 855 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. _jointlysSQL = "SELECT id,title,content,operator,start_time,end_time,link,is_hot,ctime,mtime FROM vip_jointly WHERE end_time > ? AND deleted = 0;"
  10. )
  11. // Jointlys jointly list.
  12. func (d *Dao) Jointlys(c context.Context, now int64) (res []*model.Jointly, err error) {
  13. var rows *sql.Rows
  14. if rows, err = d.db.Query(c, _jointlysSQL, now); err != nil {
  15. err = errors.WithStack(err)
  16. return
  17. }
  18. defer rows.Close()
  19. for rows.Next() {
  20. r := new(model.Jointly)
  21. if err = rows.Scan(&r.ID, &r.Title, &r.Content, &r.Operator, &r.StartTime, &r.EndTime, &r.Link, &r.IsHot, &r.CTime, &r.MTime); 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. }