BaseInfo.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package relation
  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. relationV1 "go-common/app/service/live/relation/api/liverpc/v1"
  8. "go-common/library/ecode"
  9. "go-common/library/log"
  10. rpcCtx "go-common/library/net/rpc/liverpc/context"
  11. "time"
  12. )
  13. // GetGiftInfo 获取给我关注的人送礼(金瓜子)信息
  14. func (d *Dao) GetGiftInfo(ctx context.Context, params ServiceConf.ChunkCallInfo) (giftInfo map[int64]int64, err error) {
  15. relationParams := &relationV1.BaseInfoGetGiftInfoReq{}
  16. ret, err := dao.RelationApi.V1BaseInfo.GetGiftInfo(rpcCtx.WithTimeout(ctx, time.Duration(params.RPCTimeout)*time.Millisecond), relationParams)
  17. if err != nil {
  18. return
  19. }
  20. erelongInfo, success := ServiceConf.CheckReturn(err, ret.Code, ret.Msg, "gift", params.RPCTimeout, params.ChunkSize, params.ChunkNum)
  21. if !success {
  22. if err != nil {
  23. err = errors.WithMessage(ecode.PkIDRecordFrameWorkCallError, "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",
  25. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName)
  26. } else {
  27. err = errors.WithMessage(ecode.PkIDLiveRPCCodeError, "GET SEA PATROL FAIL")
  28. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|error:%+v"+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d"+"|ParamsName:%s",
  29. err, erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName)
  30. }
  31. return giftInfo, nil
  32. }
  33. if ret.Data == nil || len(ret.Data) < 0 {
  34. erelongInfo.ErrType = ServiceConf.EmptyResultEn
  35. erelongInfo.ErrDesc = ServiceConf.EmptyResult
  36. log.Error(erelongInfo.ErrType+"|"+erelongInfo.URLName+"|Code:%d"+"|Msg:%s"+"|RPCTimeout:%d"+"|ChunkSize:%d"+"|ChunkNum:%d",
  37. erelongInfo.Code, erelongInfo.Msg, erelongInfo.RPCTimeout, erelongInfo.ChunkSize, erelongInfo.ChunkNum, params.ParamsName)
  38. return giftInfo, nil
  39. }
  40. for _, v := range ret.Data {
  41. giftInfo[v.Mid] = v.Gold
  42. }
  43. return
  44. }
  45. // GetAttentionListGroupBy 获取分组的关注列表
  46. func (d *Dao) GetAttentionListGroupBy(ctx context.Context, params ServiceConf.ChunkCallInfo) (relationInfo map[int64]*relationV1.BaseInfoGetFollowTypeResp_UidInfo, attentionErr error) {
  47. attentionData, attentionErr := dao.RelationApi.V1BaseInfo.GetFollowType(
  48. rpcCtx.WithTimeout(ctx, time.Duration(params.RPCTimeout)*time.Millisecond),
  49. &relationV1.BaseInfoGetFollowTypeReq{})
  50. if attentionErr != nil || attentionData == nil {
  51. attentionErr = ecode.AttentionListRPCError
  52. return
  53. }
  54. relationInfo = attentionData.Data
  55. return
  56. }