2025-02-03 23:42:08 +03:00

36 lines
811 B
Go

package userroutes
import (
"context"
db_repo "enshi/db/go_queries"
"enshi/db_connection"
"enshi/middleware/getters"
"github.com/gin-gonic/gin"
)
func GetUserInfo(c *gin.Context) {
userId, err := getters.GetInt64Param(c, "user-id")
if err != nil {
c.JSON(400, gin.H{"error": "Invalid user ID"})
return
}
userInfo, err := db_repo.New(db_connection.Dbx).GetUserById(context.Background(), userId)
if err != nil {
c.JSON(500, gin.H{"error": "Failed to retrieve user information"})
return
}
userProfileInfo, err := db_repo.New(db_connection.Dbx).GetProfileByUserId(context.Background(), userId)
if err != nil {
c.JSON(500, gin.H{"error": "Failed to retrieve user profile information"})
return
}
c.JSON(200, gin.H{
"user_info": userInfo,
"profile_info": userProfileInfo,
})
}