feat: Add public team listing and detail endpoints with DTOs for public access

This commit is contained in:
MythEclipse
2025-09-22 17:07:14 +07:00
parent fa3687c6be
commit b1c678c72b
3 changed files with 146 additions and 14 deletions
+44 -2
View File
@@ -3,7 +3,7 @@ use crate::{
MessageResponseDto, ResponseListSuccessDto, ResponseSuccessDto,
TeamsCreateRequestDto, TeamsDetailItemDto, TeamsListItemDto, permissions_guard,
TeamsUpdateRequestDto, TeamInviteRequestDto, TeamAcceptInvitationRequestDto,
TeamMemberDto, TeamsSearchQueryDto
TeamMemberDto, TeamsSearchQueryDto, PublicTeamsListItemDto, PublicTeamsDetailItemDto
};
use axum::extract::Path;
use axum::http::HeaderMap;
@@ -250,7 +250,7 @@ pub async fn post_accept_invitation(
("per_page" = Option<i64>, Query, description = "Items per page"),
),
responses(
(status = 200, description = "Search teams", body = ResponseListSuccessDto<Vec<TeamsListItemDto>>)
(status = 200, description = "Search teams", body = ResponseListSuccessDto<Vec<PublicTeamsListItemDto>>)
),
tag = "Teams"
)]
@@ -321,4 +321,46 @@ pub async fn post_leave_team(
Ok((claims, state)) => TeamsService::leave_team(&state, claims, id).await,
Err(response) => response,
}
}
#[utoipa::path(
get,
path = "/v1/teams/public",
params(
("page" = Option<i64>, Query, description = "Page number"),
("per_page" = Option<i64>, Query, description = "Items per page"),
("search" = Option<String>, Query, description = "Search keyword"),
("sort_by" = Option<String>, Query, description = "Sort by field"),
("order" = Option<String>, Query, description = "Order ASC or DESC"),
("filter" = Option<String>, Query, description = "Filter value"),
("filter_by" = Option<String>, Query, description = "Field to filter by"),
),
responses(
(status = 200, description = "Get public team list", body = ResponseListSuccessDto<Vec<PublicTeamsListItemDto>>)
),
tag = "Teams"
)]
pub async fn get_public_team_list(
Extension(state): Extension<AppState>,
axum::extract::Query(meta): axum::extract::Query<MetaRequestDto>,
) -> impl IntoResponse {
TeamsService::get_team_list(&state, meta).await
}
#[utoipa::path(
get,
path = "/v1/teams/public/{id}",
params(
("id" = String, Path, description = "Team ID")
),
responses(
(status = 200, description = "Get public team by ID", body = ResponseSuccessDto<PublicTeamsDetailItemDto>)
),
tag = "Teams"
)]
pub async fn get_public_team_by_id(
Extension(state): Extension<AppState>,
Path(id): Path<String>,
) -> impl IntoResponse {
TeamsService::get_team_by_id(&state, id).await
}