Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions controller/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ import (
"github.com/gin-gonic/gin"
)

func GetSpecificUser(ctx *gin.Context) {

userId := ctx.Param("userId")

if userId == "" {
ctx.JSON(http.StatusBadRequest, gin.H{"error": "User ID is required"})
return
}

users, err := initializers.DB.Users.FindMany(
db.Users.ID.Equals(userId),
).With().Exec(ctx)
if err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"Error": "Failed to fetch users"})
return
}

ctx.JSON(http.StatusOK, users)
}

func GetUsers(ctx *gin.Context) {
users, err := initializers.DB.Users.FindMany(
).Exec(ctx)
Expand Down
1 change: 1 addition & 0 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func setupProtectedRouter(router *gin.Engine) *gin.Engine {
protectedRoute.POST("/areas/create", controller.CreateArea)

protectedRoute.GET("/areas", controller.GetUserAreas)
protectedRoute.GET("/users/:userId", controller.GetSpecificUser)
protectedRoute.GET("/services/:userId", controller.GetUserServices)
protectedRoute.PATCH("/areas/:areaId/status", controller.UpdateAreaStatus)
protectedRoute.DELETE("/areas/:areaId/delete", controller.DeleteArea)
Expand Down