userinfo_find.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/middleware"
  5. "youngee_b_api/model/http_model"
  6. "youngee_b_api/service"
  7. "youngee_b_api/util"
  8. "github.com/gin-gonic/gin"
  9. "github.com/sirupsen/logrus"
  10. log "github.com/sirupsen/logrus"
  11. )
  12. func WrapFindUserInfoHandler(ctx *gin.Context) {
  13. handler := newFindUserInfoHandler(ctx)
  14. baseRun(handler)
  15. }
  16. func newFindUserInfoHandler(ctx *gin.Context) *FindUserInfoHandler {
  17. return &FindUserInfoHandler{
  18. req: http_model.NewFindUserInfoRequest(),
  19. resp: http_model.NewFindUserInfoResponse(),
  20. ctx: ctx,
  21. }
  22. }
  23. type FindUserInfoHandler struct {
  24. req *http_model.FindUserInfoRequest
  25. resp *http_model.CommonResponse
  26. ctx *gin.Context
  27. }
  28. func (h *FindUserInfoHandler) getRequest() interface{} {
  29. return h.req
  30. }
  31. func (h *FindUserInfoHandler) getContext() *gin.Context {
  32. return h.ctx
  33. }
  34. func (h *FindUserInfoHandler) getResponse() interface{} {
  35. return h.resp
  36. }
  37. func (h *FindUserInfoHandler) run() {
  38. auth := middleware.GetSessionAuth(h.ctx)
  39. //fmt.Printf("auth test %+v", auth)
  40. res, err := service.User.Find(h.ctx, auth.EnterpriseID, auth.ID)
  41. if err != nil {
  42. // 数据库查询失败,返回5001
  43. logrus.Errorf("[FindUserInfoHandler] call FindByID err:%+v\n", err)
  44. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  45. log.Info("FindUserInfo fail,req:%+v", h.req)
  46. return
  47. }
  48. h.resp.Data = res
  49. }
  50. func (h *FindUserInfoHandler) checkParam() error {
  51. return nil
  52. }