From 296f1062e917a2ab890415e816f7da8f91724a34 Mon Sep 17 00:00:00 2001 From: David Oduneye Date: Mon, 22 Jan 2024 17:36:38 -0500 Subject: [PATCH] rebase --- backend/src/server/server.go | 1 - backend/src/services/user.go | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/backend/src/server/server.go b/backend/src/server/server.go index df1401fae..43dcc83bc 100644 --- a/backend/src/server/server.go +++ b/backend/src/server/server.go @@ -69,7 +69,6 @@ func userRoutes(router fiber.Router, userService services.UserServiceInterface) users := router.Group("/users") users.Get("/", userController.GetAllUsers) - users.Delete("/:id", userController.DeleteUser) users.Get("/:id", userController.GetUser) users.Patch("/:id", userController.UpdateUser) users.Delete("/:id", userController.DeleteUser) diff --git a/backend/src/services/user.go b/backend/src/services/user.go index 6d1ead2b5..d46cee782 100644 --- a/backend/src/services/user.go +++ b/backend/src/services/user.go @@ -27,16 +27,6 @@ func (u *UserService) GetAllUsers() ([]models.User, error) { return transactions.GetAllUsers(u.DB) } -// Delete user with a specific id -func (u *UserService) DeleteUser(id string) error { - idAsInt, err := utilities.ValidateID(id) - if err != nil { - return fiber.ErrInternalServerError - } - - return transactions.DeleteUser(u.DB, *idAsInt) -} - func (u *UserService) GetUser(userID string) (*models.User, error) { idAsUint, err := utilities.ValidateID(userID) if err != nil { @@ -71,3 +61,13 @@ func (u *UserService) UpdateUser(id string, userBody models.UserRequestBody) (*m return transactions.UpdateUser(u.DB, *idAsUint, *user) } + +// Delete user with a specific id +func (u *UserService) DeleteUser(id string) error { + idAsInt, err := utilities.ValidateID(id) + if err != nil { + return fiber.ErrInternalServerError + } + + return transactions.DeleteUser(u.DB, *idAsInt) +}