gift_online.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/live/gift/model"
  5. "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. var (
  9. _getAllGift = "SELECT id,gift_id,name,price,coin_type,type,effect,corner_mark,broadcast,draw,asset_img_basic,asset_img_dynamic,asset_frame_animation,animation_frame_num,asset_gif,asset_webp,asset_full_sc_web,asset_full_sc_horizontal,asset_full_sc_vertical,asset_full_sc_horizontal_svga,asset_full_sc_vertical_svga,asset_bullet_head,asset_bullet_tail,`desc`,rights,rule,limit_interval FROM gift_online"
  10. )
  11. // GetAllGift GetAllGift
  12. func (d *Dao) GetAllGift(ctx context.Context) (gifts []*model.GiftOnline, err error) {
  13. log.Info("GetAllGift")
  14. var rows *sql.Rows
  15. if rows, err = d.db.Query(ctx, _getAllGift); err != nil {
  16. log.Error("query getAllGift error,err %v", err)
  17. return
  18. }
  19. defer rows.Close()
  20. for rows.Next() {
  21. g := &model.GiftOnline{}
  22. if err = rows.Scan(&g.Id, &g.GiftId, &g.Name, &g.Price, &g.CoinType, &g.Type, &g.Effect, &g.CornerMark, &g.Broadcast,
  23. &g.Draw, &g.AssetImgBasic, &g.AssetImgDynamic, &g.AssetFrameAnimation, &g.AnimationFrameNum, &g.AssetGif, &g.AssetWebp,
  24. &g.AssetFullScWeb, &g.AssetFullScHorizontal, &g.AssetFullScVertical, &g.AssetFullScHorizontalSvga, &g.AssetFullScVerticalSvga,
  25. &g.AssetBulletHead, &g.AssetBulletTail, &g.Desc, &g.Rights, &g.Rule, &g.LimitInterval); err != nil {
  26. log.Error("getAllGift scan error,err %v", err)
  27. return
  28. }
  29. gifts = append(gifts, g)
  30. }
  31. return
  32. }