tips.go 943 B

123456789101112131415161718192021222324252627282930313233
  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. _allTips = "SELECT `id`,`platform`,`version`,`tip`,`link`,`start_time`,`end_time`,`level`,`judge_type`,`operator`,`deleted`, `position`,`ctime`,`mtime`FROM `vip_tips` WHERE `deleted` = 0 AND `start_time` < ? AND `end_time`> ?;"
  10. )
  11. //AllTips all tips.
  12. func (d *Dao) AllTips(c context.Context, now int64) (rs []*model.Tips, err error) {
  13. var rows *sql.Rows
  14. if rows, err = d.db.Query(c, _allTips, now, now); err != nil {
  15. err = errors.WithStack(err)
  16. return
  17. }
  18. defer rows.Close()
  19. for rows.Next() {
  20. r := new(model.Tips)
  21. if err = rows.Scan(&r.ID, &r.Platform, &r.Version, &r.Tip, &r.Link, &r.StartTime, &r.EndTime, &r.Level, &r.JudgeType, &r.Operator, &r.Deleted, &r.Position, &r.Ctime, &r.Mtime); err != nil {
  22. rs = nil
  23. err = errors.WithStack(err)
  24. }
  25. rs = append(rs, r)
  26. }
  27. return
  28. }