getuserinfologic.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  6. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/svc"
  7. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/types"
  8. "bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
  9. "app.yhyue.com/moapp/jybase/common"
  10. "app.yhyue.com/moapp/jybase/encrypt"
  11. "github.com/zeromicro/go-zero/core/logx"
  12. )
  13. type GetUserInfoLogic struct {
  14. logx.Logger
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. }
  18. func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
  19. return &GetUserInfoLogic{
  20. Logger: logx.WithContext(ctx),
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. }
  24. }
  25. func (l *GetUserInfoLogic) GetUserInfo(req *types.UserReq) (resp *types.Resp, err error) {
  26. // todo: add your logic here and delete this line
  27. resp = &types.Resp{}
  28. userId := int64(req.UserId)
  29. if req.Uid != "" {
  30. //解密userid
  31. decode_userid := encrypt.SE.Decode4Hex(req.Uid)
  32. userId = common.Int64All(decode_userid)
  33. }
  34. res, err := entity.UserCenterRpc.GetUserInfo(l.ctx, &pb.UserReq{
  35. AppId: req.AppId,
  36. UserId: userId,
  37. Types: req.Types,
  38. })
  39. if err != nil || res == nil {
  40. resp.Error_msg = ""
  41. resp.Error_code = -1
  42. l.Error("get user info error:", err)
  43. return
  44. }
  45. if res.ErrorMsg != "" {
  46. resp.Error_msg = res.ErrorMsg
  47. resp.Error_code = -1
  48. l.Error(fmt.Sprintf("%+v", req), res.ErrorMsg)
  49. } else {
  50. data := map[string]interface{}{
  51. "isTourist": res.IsTourist,
  52. "nickname": res.Nickname,
  53. "headimg": res.Headimg,
  54. }
  55. if res.IsTourist < 2 && res.Data != nil {
  56. data = map[string]interface{}{
  57. "start_time": res.Data.StartTime,
  58. "end_time": res.Data.EndTime,
  59. "area": res.Data.Area,
  60. "matchway": res.Data.Matchway,
  61. "items": res.Data.Items,
  62. "projectmatch": res.Data.Projectmatch,
  63. "infotype": res.Data.Infotype,
  64. "types": res.SubscribeType, //订阅设置类型 f:免费订阅 v:超级订阅 m:大会员订阅 e:商机管理订阅
  65. "vip_status": res.VipStatus,
  66. "member_status": res.MemberStatus,
  67. "entniche_status": res.EntnicheStatus,
  68. "phone": res.Phone,
  69. "nickname": res.Nickname,
  70. "headimg": res.Headimg,
  71. "isTourist": res.IsTourist,
  72. }
  73. }
  74. resp.Data = data
  75. }
  76. return
  77. }