get_user_info.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. "youngee_b_api/util"
  7. "github.com/gin-gonic/gin"
  8. "github.com/sirupsen/logrus"
  9. log "github.com/sirupsen/logrus"
  10. )
  11. func WrapGetUserInfoHandler(ctx *gin.Context) {
  12. handler := newGetUserInfoHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newGetUserInfoHandler(ctx *gin.Context) *GetUserInfoHandler {
  16. return &GetUserInfoHandler{
  17. req: http_model.NewGetUserInfoRequest(),
  18. resp: http_model.NewGetUserInfoResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type GetUserInfoHandler struct {
  23. req *http_model.GetUserInfoRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *GetUserInfoHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *GetUserInfoHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *GetUserInfoHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *GetUserInfoHandler) run() {
  37. userData, err := service.BUserInfo.FindBUserInfoByToken(h.ctx, h.req.Token)
  38. if err != nil {
  39. logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
  40. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
  41. log.Info("login fail,req:%+v", h.req)
  42. return
  43. }
  44. var data *http_model.GetUserInfoData
  45. data = userData
  46. h.resp.Message = "成功查询用户信息"
  47. h.resp.Data = data
  48. h.resp.Status = 20000
  49. return
  50. }
  51. func (h *GetUserInfoHandler) checkParam() error {
  52. return nil
  53. }