refactor: Update admin team routes to remove versioning and avoid conflicts

This commit is contained in:
MythEclipse
2025-09-25 23:28:37 +07:00
parent f3d88e2ac9
commit 012aff60ef
3 changed files with 21 additions and 24 deletions
@@ -33,7 +33,7 @@ where
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams", path = "/",
params( params(
("page" = Option<i64>, Query, description = "Page number"), ("page" = Option<i64>, Query, description = "Page number"),
("per_page" = Option<i64>, Query, description = "Items per page"), ("per_page" = Option<i64>, Query, description = "Items per page"),
@@ -63,7 +63,7 @@ pub async fn get_all_teams(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams/{id}", path = "/{id}",
params( params(
("id" = String, Path, description = "Team ID") ("id" = String, Path, description = "Team ID")
), ),
@@ -87,7 +87,7 @@ pub async fn get_team_by_id(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams/{id}/members", path = "/{id}/members",
params( params(
("id" = String, Path, description = "Team ID") ("id" = String, Path, description = "Team ID")
), ),
@@ -111,7 +111,7 @@ pub async fn get_team_members(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams", path = "/",
request_body = TeamsCreateRequestDto, request_body = TeamsCreateRequestDto,
responses( responses(
(status = 200, description = "Create team (admin)", body = ResponseSuccessDto<serde_json::Value>) (status = 200, description = "Create team (admin)", body = ResponseSuccessDto<serde_json::Value>)
@@ -133,7 +133,7 @@ pub async fn create_team(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams/{id}", path = "/{id}",
params( params(
("id" = String, Path, description = "Team ID") ("id" = String, Path, description = "Team ID")
), ),
@@ -159,7 +159,7 @@ pub async fn update_team(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams/{id}", path = "/{id}",
params( params(
("id" = String, Path, description = "Team ID") ("id" = String, Path, description = "Team ID")
), ),
@@ -183,7 +183,7 @@ pub async fn delete_team(
security( security(
("Bearer" = []) ("Bearer" = [])
), ),
path = "/v1/admin/teams/{id}/invite", path = "/{id}/invite",
params( params(
("id" = String, Path, description = "Team ID") ("id" = String, Path, description = "Team ID")
), ),
@@ -207,10 +207,10 @@ pub async fn invite_team_members(
pub fn admin_teams_router() -> Router { pub fn admin_teams_router() -> Router {
Router::new() Router::new()
.route("/", axum::routing::get(get_all_teams)) .route("/", axum::routing::get(get_all_teams))
.route("/:id", axum::routing::get(get_team_by_id)) .route("/{id}", axum::routing::get(get_team_by_id))
.route("/:id/members", axum::routing::get(get_team_members)) .route("/{id}/members", axum::routing::get(get_team_members))
.route("/", axum::routing::post(create_team)) .route("/", axum::routing::post(create_team))
.route("/:id", axum::routing::put(update_team)) .route("/{id}", axum::routing::put(update_team))
.route("/:id", axum::routing::delete(delete_team)) .route("/{id}", axum::routing::delete(delete_team))
.route("/:id/invite", axum::routing::post(invite_team_members)) .route("/{id}/invite", axum::routing::post(invite_team_members))
} }
+2 -2
View File
@@ -18,6 +18,6 @@ pub fn teams_router() -> Router {
Router::new() Router::new()
// Public routes // Public routes
.merge(teams_controller::teams_router()) .merge(teams_controller::teams_router())
// Admin routes // Admin routes - prefixed with /admin to avoid route conflicts
.merge(admin_teams_controller::admin_teams_router()) .nest("/admin", admin_teams_controller::admin_teams_router())
} }
+7 -10
View File
@@ -379,17 +379,14 @@ pub async fn get_admin_team_members(
pub fn teams_router() -> Router { pub fn teams_router() -> Router {
Router::new() Router::new()
.route("/", axum::routing::get(get_team_list)) .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("/create", axum::routing::post(post_create_team))
.route("/update/:id", axum::routing::put(put_update_team)) .route("/update/{id}", axum::routing::put(put_update_team))
.route("/delete/:id", axum::routing::delete(delete_team)) .route("/delete/{id}", axum::routing::delete(delete_team))
.route("/:id/invite", axum::routing::post(post_invite_team_members)) .route("/{id}/invite", axum::routing::post(post_invite_team_members))
.route("/accept/:token", axum::routing::post(post_accept_invitation)) .route("/accept/{token}", axum::routing::post(post_accept_invitation))
.route("/search", axum::routing::get(get_public_team_search)) .route("/search", axum::routing::get(get_public_team_search))
.route("/:id/members", axum::routing::get(get_team_members)) .route("/{id}/members", axum::routing::get(get_team_members))
.route("/:id/leave", axum::routing::post(post_leave_team)) .route("/{id}/leave", axum::routing::post(post_leave_team))
.route("/leave-me", axum::routing::post(post_leave_current_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))
} }