uid2roomid.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package room
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. ServiceConf "go-common/app/interface/live/app-interface/conf"
  6. "go-common/app/interface/live/app-interface/dao"
  7. roomV2 "go-common/app/service/live/room/api/liverpc/v2"
  8. "go-common/library/ecode"
  9. "go-common/library/log"
  10. rpcCtx "go-common/library/net/rpc/liverpc/context"
  11. "time"
  12. )
  13. // UIDs2roomIDs ...
  14. // uid转换roomID,每批最大400
  15. func (d *Dao) UIDs2roomIDs(ctx context.Context, req *roomV2.RoomRoomIdByUidMultiReq, params ServiceConf.ChunkCallInfo) (ret *roomV2.RoomRoomIdByUidMultiResp, err error) {
  16. ret, err = dao.RoomApi.V2Room.RoomIdByUidMulti(rpcCtx.WithTimeout(ctx, time.Duration(params.RPCTimeout)*time.Millisecond), &roomV2.RoomRoomIdByUidMultiReq{Uids: req.Uids})
  17. if err != nil {
  18. return
  19. }
  20. erelongInfo, success := ServiceConf.CheckReturn(err, ret.Code, ret.Msg, ServiceConf.GetRoomID, params.RPCTimeout, params.ChunkSize, params.ChunkNum)
  21. if !success {
  22. if err != nil {
  23. err = errors.WithMessage(ecode.FansMedalFrameWorkCallError, "GET SEA PATROL FAIL")
  24. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  25. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.Uids)
  26. }
  27. return
  28. }
  29. if ret.Data == nil || len(ret.Data) <= 0 {
  30. erelongInfo.ErrType = ServiceConf.EmptyResultEn
  31. erelongInfo.ErrDesc = ServiceConf.EmptyResult
  32. // log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  33. // erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.Uids)
  34. return
  35. }
  36. return
  37. }