use actix_web::{HttpResponse, web}; use serde::Deserialize; use crate::api::response::{ApiErrorResponse, ApiResponse}; use crate::error::AppError; use crate::models::workspaces::Workspace; use crate::service::AppService; use crate::session::Session; #[derive(Deserialize, utoipa::IntoParams)] pub struct ListQuery { pub limit: Option, pub offset: Option, } #[utoipa::path( get, path = "/api/v1/workspaces", tag = "Workspaces", operation_id = "workspaceList", summary = "List accessible workspaces", description = "Return workspaces owned by, joined by, or publicly accessible to the current user.", params(ListQuery), responses( (status = 200, description = "List of workspaces.", body = ApiResponse>), (status = 401, description = "Unauthenticated.", body = ApiErrorResponse), (status = 500, description = "Database read failed.", body = ApiErrorResponse) ) )] pub async fn handle( service: web::Data, session: Session, query: web::Query, ) -> Result { let data = service .workspace .workspace_list( &session, query.limit.unwrap_or(50), query.offset.unwrap_or(0), ) .await?; Ok(HttpResponse::Ok().json(ApiResponse::new(data))) }