From 012aff60efeae762ee771e5cc176117768299dda Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Thu, 25 Sep 2025 23:28:37 +0700 Subject: [PATCH] refactor: Update admin team routes to remove versioning and avoid conflicts --- .../src/v1/teams/admin_teams_controller.rs | 24 +++++++++---------- imphnen-iam/src/v1/teams/mod.rs | 4 ++-- imphnen-iam/src/v1/teams/teams_controller.rs | 17 ++++++------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/imphnen-iam/src/v1/teams/admin_teams_controller.rs b/imphnen-iam/src/v1/teams/admin_teams_controller.rs index 6f35123..750beee 100644 --- a/imphnen-iam/src/v1/teams/admin_teams_controller.rs +++ b/imphnen-iam/src/v1/teams/admin_teams_controller.rs @@ -33,7 +33,7 @@ where security( ("Bearer" = []) ), - path = "/v1/admin/teams", + path = "/", params( ("page" = Option, Query, description = "Page number"), ("per_page" = Option, Query, description = "Items per page"), @@ -63,7 +63,7 @@ pub async fn get_all_teams( security( ("Bearer" = []) ), - path = "/v1/admin/teams/{id}", + path = "/{id}", params( ("id" = String, Path, description = "Team ID") ), @@ -87,7 +87,7 @@ pub async fn get_team_by_id( security( ("Bearer" = []) ), - path = "/v1/admin/teams/{id}/members", + path = "/{id}/members", params( ("id" = String, Path, description = "Team ID") ), @@ -111,7 +111,7 @@ pub async fn get_team_members( security( ("Bearer" = []) ), - path = "/v1/admin/teams", + path = "/", request_body = TeamsCreateRequestDto, responses( (status = 200, description = "Create team (admin)", body = ResponseSuccessDto) @@ -133,7 +133,7 @@ pub async fn create_team( security( ("Bearer" = []) ), - path = "/v1/admin/teams/{id}", + path = "/{id}", params( ("id" = String, Path, description = "Team ID") ), @@ -159,7 +159,7 @@ pub async fn update_team( security( ("Bearer" = []) ), - path = "/v1/admin/teams/{id}", + path = "/{id}", params( ("id" = String, Path, description = "Team ID") ), @@ -183,7 +183,7 @@ pub async fn delete_team( security( ("Bearer" = []) ), - path = "/v1/admin/teams/{id}/invite", + path = "/{id}/invite", params( ("id" = String, Path, description = "Team ID") ), @@ -207,10 +207,10 @@ pub async fn invite_team_members( pub fn admin_teams_router() -> Router { Router::new() .route("/", axum::routing::get(get_all_teams)) - .route("/:id", axum::routing::get(get_team_by_id)) - .route("/:id/members", axum::routing::get(get_team_members)) + .route("/{id}", axum::routing::get(get_team_by_id)) + .route("/{id}/members", axum::routing::get(get_team_members)) .route("/", axum::routing::post(create_team)) - .route("/:id", axum::routing::put(update_team)) - .route("/:id", axum::routing::delete(delete_team)) - .route("/:id/invite", axum::routing::post(invite_team_members)) + .route("/{id}", axum::routing::put(update_team)) + .route("/{id}", axum::routing::delete(delete_team)) + .route("/{id}/invite", axum::routing::post(invite_team_members)) } \ No newline at end of file diff --git a/imphnen-iam/src/v1/teams/mod.rs b/imphnen-iam/src/v1/teams/mod.rs index db61d8e..0ef43d1 100644 --- a/imphnen-iam/src/v1/teams/mod.rs +++ b/imphnen-iam/src/v1/teams/mod.rs @@ -18,6 +18,6 @@ pub fn teams_router() -> Router { Router::new() // Public routes .merge(teams_controller::teams_router()) - // Admin routes - .merge(admin_teams_controller::admin_teams_router()) + // Admin routes - prefixed with /admin to avoid route conflicts + .nest("/admin", admin_teams_controller::admin_teams_router()) } \ No newline at end of file diff --git a/imphnen-iam/src/v1/teams/teams_controller.rs b/imphnen-iam/src/v1/teams/teams_controller.rs index 0547a34..fe02c16 100644 --- a/imphnen-iam/src/v1/teams/teams_controller.rs +++ b/imphnen-iam/src/v1/teams/teams_controller.rs @@ -379,17 +379,14 @@ pub async fn get_admin_team_members( pub fn teams_router() -> Router { Router::new() .route("/", axum::routing::get(get_team_list)) - .route("/:id", axum::routing::get(get_team_by_id)) + .route("/{id}", axum::routing::get(get_team_by_id)) .route("/create", axum::routing::post(post_create_team)) - .route("/update/:id", axum::routing::put(put_update_team)) - .route("/delete/:id", axum::routing::delete(delete_team)) - .route("/:id/invite", axum::routing::post(post_invite_team_members)) - .route("/accept/:token", axum::routing::post(post_accept_invitation)) + .route("/update/{id}", axum::routing::put(put_update_team)) + .route("/delete/{id}", axum::routing::delete(delete_team)) + .route("/{id}/invite", axum::routing::post(post_invite_team_members)) + .route("/accept/{token}", axum::routing::post(post_accept_invitation)) .route("/search", axum::routing::get(get_public_team_search)) - .route("/:id/members", axum::routing::get(get_team_members)) - .route("/:id/leave", axum::routing::post(post_leave_team)) + .route("/{id}/members", axum::routing::get(get_team_members)) + .route("/{id}/leave", axum::routing::post(post_leave_team)) .route("/leave-me", axum::routing::post(post_leave_current_team)) - .route("/admin", axum::routing::get(get_admin_team_list)) - .route("/admin/:id", axum::routing::get(get_admin_team_by_id)) - .route("/admin/:id/members", axum::routing::get(get_admin_team_members)) }