special.go 731 B

123456789101112131415161718192021222324252627282930
  1. package manager
  2. import (
  3. "context"
  4. pb "go-common/app/service/main/resource/api/v1"
  5. )
  6. const (
  7. _specialSQL = "SELECT `id`,`title`,`desc`,`cover`,`scover`,`re_type`,`re_value`,`corner`,`size`,`card` FROM special_card"
  8. )
  9. //Specials get specials cars from DB
  10. func (d *Dao) Specials(c context.Context) (sps map[int64]*pb.SpecialReply, err error) {
  11. rows, err := d.db.Query(c, _specialSQL)
  12. if err != nil {
  13. return
  14. }
  15. defer rows.Close()
  16. sps = make(map[int64]*pb.SpecialReply)
  17. for rows.Next() {
  18. sc := &pb.SpecialReply{}
  19. if err = rows.Scan(&sc.Id, &sc.Title, &sc.Desc, &sc.Cover, &sc.Scover, &sc.ReType, &sc.ReValue, &sc.Corner, &sc.Siz, &sc.Card); err != nil {
  20. return
  21. }
  22. sps[sc.Id] = sc
  23. }
  24. err = rows.Err()
  25. return
  26. }