get_user_profile_handler.go 792 B

1234567891011121314151617181920212223242526272829303132
  1. package user
  2. import (
  3. "net/http"
  4. "github.com/zeromicro/go-zero/rest/httpx"
  5. "github.com/suyuan32/simple-admin-core/api/internal/logic/user"
  6. "github.com/suyuan32/simple-admin-core/api/internal/svc"
  7. )
  8. // swagger:route get /user/profile user GetUserProfile
  9. //
  10. // Get user's profile | 获取用户个人信息
  11. //
  12. // Get user's profile | 获取用户个人信息
  13. //
  14. // Responses:
  15. // 200: ProfileResp
  16. func GetUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  17. return func(w http.ResponseWriter, r *http.Request) {
  18. l := user.NewGetUserProfileLogic(r.Context(), svcCtx)
  19. resp, err := l.GetUserProfile()
  20. if err != nil {
  21. err = svcCtx.Trans.TransError(r.Context(), err)
  22. httpx.ErrorCtx(r.Context(), w, err)
  23. } else {
  24. httpx.OkJsonCtx(r.Context(), w, resp)
  25. }
  26. }
  27. }