From a450f32272c51e8b70ca56aa7796ceeb46f8a46f Mon Sep 17 00:00:00 2001 From: LeonG11 Date: Wed, 24 Jun 2026 10:58:51 +0300 Subject: [PATCH] feat: add profile page --- backend/handlers/user_handler.go | 13 +++++++++++++ backend/main.go | 1 + 2 files changed, 14 insertions(+) diff --git a/backend/handlers/user_handler.go b/backend/handlers/user_handler.go index 655c358..1fb4aef 100644 --- a/backend/handlers/user_handler.go +++ b/backend/handlers/user_handler.go @@ -161,3 +161,16 @@ func UpdateProfile(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "Данные успешно обновлены"}) } + +func GetUserInfo(c *gin.Context) { + userID := c.MustGet("user_id") + + var user models.User + + if err := database.DB.First(&user, userID).Error; err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "Ошибка при получение профиля"}) + return + } + + c.JSON(http.StatusOK, user) +} diff --git a/backend/main.go b/backend/main.go index 09992c3..d6f7d0d 100644 --- a/backend/main.go +++ b/backend/main.go @@ -57,6 +57,7 @@ func main() { protected.GET("/orders", handlers.GetUserOrders) protected.GET("/orders/:id", handlers.GetOrder) protected.PATCH("/profile", handlers.UpdateProfile) + protected.GET("/profile", handlers.GetUserInfo) } admin := protected.Group("/admin")