getentuserinfologic.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package logic
  2. import (
  3. "context"
  4. "fmt"
  5. "bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
  6. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  7. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/svc"
  8. "bp.jydev.jianyu360.cn/BaseService/userCenter/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type GetEntUserInfoLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewGetEntUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEntUserInfoLogic {
  17. return &GetEntUserInfoLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *GetEntUserInfoLogic) GetEntUserInfo(req *types.EntUserReq) (resp *types.Resp, err error) {
  24. // todo: add your logic here and delete this line
  25. resp = &types.Resp{Data: nil}
  26. res, err := entity.UserCenterRpc.GetEntUserInfo(l.ctx, &pb.EntUserReq{
  27. AppId: req.AppId,
  28. EntUserId: req.EntUserId,
  29. })
  30. if res == nil {
  31. resp = &types.Resp{Data: nil, Error_msg: "暂无数据", Error_code: -1}
  32. return
  33. }
  34. if res.ErrorMsg != "" {
  35. resp.Error_msg = res.ErrorMsg
  36. resp.Error_code = -1
  37. l.Error(fmt.Sprintf("%+v", req), res.ErrorMsg)
  38. } else {
  39. data := map[string]interface{}{
  40. "name": res.Data.Name,
  41. "phone": res.Data.Phone,
  42. "deptName": res.Data.DeptName,
  43. "mail": res.Data.Mail,
  44. }
  45. resp.Data = data
  46. }
  47. return
  48. }