pendant.go 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. ServiceConf "go-common/app/interface/live/app-interface/conf"
  9. cDao "go-common/app/interface/live/app-interface/dao"
  10. roomV1 "go-common/app/service/live/room/api/liverpc/v1"
  11. "go-common/library/ecode"
  12. "go-common/library/log"
  13. rpcCtx "go-common/library/net/rpc/liverpc/context"
  14. )
  15. // GetRoomPendant
  16. func (d *Dao) GetRoomPendant(ctx context.Context, roomIds []int64, pendantType string, position int64) (pendantRoomListResp map[int64]*roomV1.RoomPendantGetPendantByIdsResp_Result, err error) {
  17. pendantRoomListResp = make(map[int64]*roomV1.RoomPendantGetPendantByIdsResp_Result)
  18. getPendantByIdsTimeout := time.Duration(conf.GetTimeout("getPendantByIds", 50)) * time.Millisecond
  19. pendantRoomList, err := cDao.RoomApi.V1RoomPendant.GetPendantByIds(rpcCtx.WithTimeout(ctx, getPendantByIdsTimeout), &roomV1.RoomPendantGetPendantByIdsReq{
  20. Ids: roomIds,
  21. Type: pendantType,
  22. Position: position, // 历史原因,取右上,但客户端展示在左上
  23. })
  24. if err != nil {
  25. log.Error("[GetRoomPendant]room.v1.getPendantByIds rpc error:%+v", err)
  26. err = errors.WithMessage(ecode.RoomPendantError, fmt.Sprintf("room.v1.getPendantByIds rpc error:%+v", err))
  27. return
  28. }
  29. if pendantRoomList.Code != 0 {
  30. log.Error("[GetRoomPendant]room.v1.getPendantByIds response code:%d,msg:%s", pendantRoomList.Code, pendantRoomList.Msg)
  31. err = errors.WithMessage(ecode.RoomPendantReturnError, fmt.Sprintf("room.v1.getPendantByIds response error, code:%d, msg:%s", pendantRoomList.Code, pendantRoomList.Msg))
  32. return
  33. }
  34. if pendantRoomList.Data == nil || pendantRoomList.Data.Result == nil {
  35. log.Error("[GetRoomPendant]room.v1.getPendantByIds empty error")
  36. err = errors.WithMessage(ecode.RoomPendantReturnError, "")
  37. return
  38. }
  39. pendantRoomListResp = pendantRoomList.Data.Result
  40. return
  41. }
  42. // GetRoomPendantInfo ...
  43. // 获取角标信息
  44. func (d *Dao) GetRoomPendantInfo(ctx context.Context, req *roomV1.RoomPendantGetPendantByIdsReq, params ServiceConf.ChunkCallInfo) (roomNewsResult *roomV1.RoomPendantGetPendantByIdsResp, err error) {
  45. ret, err := cDao.RoomApi.V1RoomPendant.GetPendantByIds(rpcCtx.WithTimeout(ctx, time.Duration(params.RPCTimeout)*time.Millisecond), &roomV1.RoomPendantGetPendantByIdsReq{Ids: req.Ids, Type: req.Type, Position: req.Position})
  46. if err != nil {
  47. return
  48. }
  49. erelongInfo, success := ServiceConf.CheckReturn(err, ret.Code, ret.Msg, ServiceConf.RoomPendent, params.RPCTimeout, params.ChunkSize, params.ChunkNum)
  50. if !success {
  51. if err != nil {
  52. err = errors.WithMessage(ecode.PkIDRecordFrameWorkCallError, "GET SEA PATROL FAIL")
  53. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  54. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.Ids)
  55. } else {
  56. err = errors.WithMessage(ecode.PkIDLiveRPCCodeError, "GET SEA PATROL FAIL")
  57. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  58. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.Ids)
  59. }
  60. return nil, err
  61. }
  62. if ret.Data == nil {
  63. erelongInfo.ErrType = ServiceConf.EmptyResultEn
  64. erelongInfo.ErrDesc = ServiceConf.EmptyResult
  65. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  66. erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.Ids)
  67. return nil, err
  68. }
  69. roomNewsResult = ret
  70. return
  71. }