feat: add profile page
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user