banner.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package room_ex
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/pkg/errors"
  6. "go-common/app/interface/live/app-interface/conf"
  7. cDao "go-common/app/interface/live/app-interface/dao"
  8. roomEx "go-common/app/service/live/room_ex/api/liverpc/v1"
  9. "go-common/library/ecode"
  10. "go-common/library/log"
  11. rpcCtx "go-common/library/net/rpc/liverpc/context"
  12. "time"
  13. )
  14. func (d *Dao) GetBanner(ctx context.Context, biz int64, position int64, platform string, device string, build int64) (bannerListResp []*roomEx.BannerGetNewBannerResp_NewBanner, err error) {
  15. timeOut := time.Duration(conf.GetTimeout("/room_ex/v1/Banner/getNewBanner", 50)) * time.Millisecond
  16. bannerListResult, errCode := cDao.RoomExtApi.V1Banner.GetNewBanner(rpcCtx.WithTimeout(ctx, timeOut), &roomEx.BannerGetNewBannerReq{
  17. Platform: biz,
  18. Position: position,
  19. UserPlatform: platform,
  20. UserDevice: device,
  21. Build: build,
  22. })
  23. if errCode != nil {
  24. log.Error("[getBannerFromRoomEx]roomEx.v1.getNewBanner rpc error:%+v", errCode)
  25. err = errors.WithMessage(ecode.GetBannerErr, fmt.Sprintf("roomEx.v1.getNewBanner rpc error:%+v", errCode))
  26. return
  27. }
  28. if bannerListResult.Code != 0 {
  29. log.Error("[getBannerFromRoomEx]roomEx.v1.getNewBanner response error:%+v,code:%d,msg:%s", errCode, bannerListResult.Code, bannerListResult.Msg)
  30. err = errors.WithMessage(ecode.GetBannerErr, fmt.Sprintf("roomEx.v1.getNewBanner response error,code:%d,msg:%s", bannerListResult.Code, bannerListResult.Msg))
  31. return
  32. }
  33. if bannerListResult.Data == nil {
  34. log.Error("[getBannerFromRoomEx]roomEx.v1.getNewBanner empty error")
  35. err = errors.WithMessage(ecode.GetBannerErr, "roomEx.v1.getNewBanner empty error")
  36. return
  37. }
  38. bannerListResp = bannerListResult.Data
  39. return
  40. }