TargetsWithMedal.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package fans_medal
  2. import (
  3. "context"
  4. "time"
  5. "github.com/pkg/errors"
  6. ServiceConf "go-common/app/interface/live/app-interface/conf"
  7. "go-common/app/interface/live/app-interface/dao"
  8. fansMedalV1 "go-common/app/service/live/fans_medal/api/liverpc/v1"
  9. "go-common/library/ecode"
  10. "go-common/library/log"
  11. rpcCtx "go-common/library/net/rpc/liverpc/context"
  12. )
  13. // GetFansMedal ...
  14. // 获取粉丝勋章佩戴信息
  15. func (d *Dao) GetFansMedal(ctx context.Context, req *fansMedalV1.FansMedalTargetsWithMedalReq, params ServiceConf.ChunkCallInfo) (fansResult *fansMedalV1.FansMedalTargetsWithMedalResp, err error) {
  16. fansResult = &fansMedalV1.FansMedalTargetsWithMedalResp{}
  17. ret, err := dao.FansMedalApi.V1FansMedal.TargetsWithMedal(rpcCtx.WithTimeout(ctx, time.Duration(params.RPCTimeout)*time.Millisecond),
  18. &fansMedalV1.FansMedalTargetsWithMedalReq{Uid: req.Uid, TargetIds: req.TargetIds})
  19. if err != nil {
  20. return
  21. }
  22. erelongInfo, success := ServiceConf.CheckReturn(err, ret.Code, ret.Msg, ServiceConf.TargetsWithMedal, params.RPCTimeout, params.ChunkSize, params.ChunkNum)
  23. if !success {
  24. if err != nil {
  25. err = errors.WithMessage(ecode.FansMedalFrameWorkCallError, "GET SEA PATROL FAIL")
  26. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  27. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.TargetIds)
  28. } else {
  29. err = errors.WithMessage(ecode.FansMedalLiveRPCCodeError, "GET SEA PATROL FAIL")
  30. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  31. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.TargetIds)
  32. }
  33. return
  34. }
  35. if ret.Data == nil || len(ret.Data) <= 0 {
  36. erelongInfo.ErrType = ServiceConf.EmptyResultEn
  37. erelongInfo.ErrDesc = ServiceConf.EmptyResult
  38. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s"+"|Params:%v",
  39. erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName, req.TargetIds)
  40. return
  41. }
  42. fansResult = ret
  43. return
  44. }