Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOduneye committed Jan 22, 2024
1 parent 1879632 commit 296f106
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion backend/src/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions backend/src/services/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 296f106

Please sign in to comment.