getentuserinfologic.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. entUserid := req.HeaderEntUserId
  27. //优先取传的参数,没有的话取header里的取自己的
  28. if req.EntUserId > 0 {
  29. entUserid = req.EntUserId
  30. }
  31. res, err := entity.UserCenterRpc.GetEntUserInfo(l.ctx, &pb.EntUserReq{
  32. AppId: req.AppId,
  33. EntUserId: entUserid,
  34. EntId: req.EntId,
  35. })
  36. if res == nil {
  37. resp = &types.Resp{Data: nil, Error_msg: "暂无数据", Error_code: -1}
  38. return
  39. }
  40. if res.ErrorMsg != "" {
  41. resp.Error_msg = res.ErrorMsg
  42. resp.Error_code = -1
  43. l.Error(fmt.Sprintf("%+v", req), res.ErrorMsg)
  44. } else {
  45. data := map[string]interface{}{
  46. "name": res.Data.Name,
  47. "phone": res.Data.Phone,
  48. "deptName": res.Data.DeptName,
  49. "mail": res.Data.Mail,
  50. }
  51. resp.Data = data
  52. }
  53. return
  54. }