info.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package room
  2. import (
  3. "context"
  4. "fmt"
  5. "time"
  6. "github.com/pkg/errors"
  7. "go-common/app/interface/live/app-interface/conf"
  8. cDao "go-common/app/interface/live/app-interface/dao"
  9. roomV2 "go-common/app/service/live/room/api/liverpc/v2"
  10. "go-common/library/ecode"
  11. "go-common/library/log"
  12. rpcCtx "go-common/library/net/rpc/liverpc/context"
  13. )
  14. // GetRoomInfoByIds
  15. func (d *Dao) GetRoomInfoByIds(ctx context.Context, roomIds []int64, fields []string, from string) (multiRoomListResp map[int64]*roomV2.RoomGetByIdsResp_RoomInfo, err error) {
  16. multiRoomListResp = make(map[int64]*roomV2.RoomGetByIdsResp_RoomInfo)
  17. getByIdsTimeout := time.Duration(conf.GetTimeout("getByIds", 100)) * time.Millisecond
  18. multiRoomList, getByIdsError := cDao.RoomApi.V2Room.GetByIds(rpcCtx.WithTimeout(ctx, getByIdsTimeout), &roomV2.RoomGetByIdsReq{
  19. Ids: roomIds,
  20. NeedBroadcastType: 1,
  21. NeedUinfo: 1,
  22. Fields: fields,
  23. From: from,
  24. })
  25. if getByIdsError != nil {
  26. log.Error("[GetRoomInfoByIds]room.v2.getByIds rpc error:%+v", getByIdsError)
  27. // 这个是推荐房间列表的基础信息,如果失败需要cancel,不然返回值会很奇怪
  28. err = errors.WithMessage(ecode.GetRoomError, fmt.Sprintf("room.v2.getByIds rpc error:%+v", getByIdsError))
  29. return
  30. }
  31. if multiRoomList.Code != 0 {
  32. log.Error("[GetRoomInfoByIds]room.v2.getByIds response error,code:%d,msg:%s", multiRoomList.Code, multiRoomList.Msg)
  33. // 这个是推荐房间列表的基础信息,如果失败需要cancel,不然返回值会很奇怪
  34. err = errors.WithMessage(ecode.GetRoomError, fmt.Sprintf("room.v2.getByIds response error,code:%d,msg:%s", multiRoomList.Code, multiRoomList.Msg))
  35. return
  36. }
  37. if multiRoomList.Data == nil {
  38. log.Error("[GetRoomInfoByIds]room.v2.getByIds empty error")
  39. // 这个是推荐房间列表的基础信息,如果失败需要cancel,不然返回值会很奇怪
  40. err = errors.WithMessage(ecode.GetRoomEmptyError, "room.v2.getByIds empty error")
  41. return
  42. }
  43. multiRoomListResp = multiRoomList.Data
  44. return
  45. }