Handler ListAllUsersProject in global_state.go added for GetAllUsersProject in db.go
This commit is contained in:
parent
34ad6ac777
commit
f2a4c417aa
1 changed files with 16 additions and 0 deletions
|
@ -34,6 +34,7 @@ type GlobalState interface {
|
||||||
GetButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
GetButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
||||||
IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
IncrementButtonCount(c *fiber.Ctx) error // For demonstration purposes
|
||||||
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
|
ListAllUsers(c *fiber.Ctx) error // To get a list of all users in the application database
|
||||||
|
ListAllUsersProject(c *fiber.Ctx) error // To get a list of all users for a specific project
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Constructor"
|
// "Constructor"
|
||||||
|
@ -182,6 +183,7 @@ func (gs *GState) GetUserProjects(c *fiber.Ctx) error {
|
||||||
return c.JSON(projects)
|
return c.JSON(projects)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListAllUsers is a handler that returns a list of all users in the application database
|
||||||
func (gs *GState) ListAllUsers(c *fiber.Ctx) error {
|
func (gs *GState) ListAllUsers(c *fiber.Ctx) error {
|
||||||
// Get all users from the database
|
// Get all users from the database
|
||||||
users, err := gs.Db.GetAllUsersApplication()
|
users, err := gs.Db.GetAllUsersApplication()
|
||||||
|
@ -192,3 +194,17 @@ func (gs *GState) ListAllUsers(c *fiber.Ctx) error {
|
||||||
// Return the list of users as JSON
|
// Return the list of users as JSON
|
||||||
return c.JSON(users)
|
return c.JSON(users)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gs *GState) ListAllUsersProject(c *fiber.Ctx) error {
|
||||||
|
// Extract the project name from the request parameters or body
|
||||||
|
projectName := c.Params("projectName")
|
||||||
|
|
||||||
|
// Get all users associated with the project from the database
|
||||||
|
users, err := gs.Db.GetAllUsersProject(projectName)
|
||||||
|
if err != nil {
|
||||||
|
return c.Status(500).SendString(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the list of users as JSON
|
||||||
|
return c.JSON(users)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue