feat: add profile page

This commit is contained in:
2026-06-24 10:58:51 +03:00
parent 4fc2c28d3b
commit a450f32272
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -161,3 +161,16 @@ func UpdateProfile(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Данные успешно обновлены"}) 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)
}
+1
View File
@@ -57,6 +57,7 @@ func main() {
protected.GET("/orders", handlers.GetUserOrders) protected.GET("/orders", handlers.GetUserOrders)
protected.GET("/orders/:id", handlers.GetOrder) protected.GET("/orders/:id", handlers.GetOrder)
protected.PATCH("/profile", handlers.UpdateProfile) protected.PATCH("/profile", handlers.UpdateProfile)
protected.GET("/profile", handlers.GetUserInfo)
} }
admin := protected.Group("/admin") admin := protected.Group("/admin")