getuserinfologic.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  6. "app.yhyue.com/moapp/jybase/common"
  7. "app.yhyue.com/moapp/jybase/encrypt"
  8. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/svc"
  9. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/types"
  10. "bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
  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 {
  40. resp.Error_msg = ""
  41. resp.Error_code = -1
  42. l.Error("get user info error:", err)
  43. }
  44. if res.ErrorMsg != "" {
  45. resp.Error_msg = res.ErrorMsg
  46. resp.Error_code = -1
  47. l.Error(fmt.Sprintf("%+v", req), res.ErrorMsg)
  48. } else {
  49. data := map[string]interface{}{
  50. "start_time": res.Data.StartTime,
  51. "end_time": res.Data.EndTime,
  52. "area": res.Data.Area,
  53. "matchway": res.Data.Matchway,
  54. "items": res.Data.Items,
  55. "projectmatch": res.Data.Projectmatch,
  56. "infotype": res.Data.Infotype,
  57. "types": res.SubscribeType, //订阅设置类型 f:免费订阅 v:超级订阅 m:大会员订阅 e:商机管理订阅
  58. "vip_status": res.VipStatus,
  59. "member_status": res.MemberStatus,
  60. "entniche_status": res.EntnicheStatus,
  61. "phone": res.Phone,
  62. "nickname": res.Nickname,
  63. "headimg": res.Headimg,
  64. }
  65. resp.Data = data
  66. }
  67. return
  68. }