getuserinfologic.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: int64(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. "start_time": res.Data.StartTime,
  52. "end_time": res.Data.EndTime,
  53. "area": res.Data.Area,
  54. "matchway": res.Data.Matchway,
  55. "items": res.Data.Items,
  56. "projectmatch": res.Data.Projectmatch,
  57. "infotype": res.Data.Infotype,
  58. "types": res.SubscribeType, //订阅设置类型 f:免费订阅 v:超级订阅 m:大会员订阅 e:商机管理订阅
  59. "vip_status": res.VipStatus,
  60. "member_status": res.MemberStatus,
  61. "entniche_status": res.EntnicheStatus,
  62. "phone": res.Phone,
  63. "nickname": res.Nickname,
  64. "headimg": res.Headimg,
  65. }
  66. resp.Data = data
  67. }
  68. return
  69. }