feat(api): expand API endpoints for repo, PR, user, workspace management

- Add git operation endpoints: archive, compare branches, diff, tree,
  repository extras
- Add repo endpoints: contributors, delete fork, get branch/commit
  status/deploy key/invitation/member/release/tag/webhook, topics,
  release assets, webhook deliveries/retry
- Add PR endpoints: review requests, templates
- Add user endpoints: block/unblock, follow/unfollow, presence,
  personal access tokens, account restore
- Add workspace endpoints: billing history, approvals, domains,
  integrations, invitations, members, webhooks, restore
- Add internal API, notification API, IM API modules
- Update route configuration and OpenAPI spec
This commit is contained in:
zhenyi
2026-06-10 18:49:27 +08:00
parent 4586b79cb8
commit cec6dce955
161 changed files with 7522 additions and 349 deletions
+17 -3
View File
@@ -1,9 +1,11 @@
use actix_web::{HttpResponse, web};
use serde::Deserialize;
use uuid::Uuid;
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::models::workspaces::Workspace;
use crate::models::base_info::resolve_users;
use crate::models::workspaces::WorkspaceDetail;
use crate::service::AppService;
use crate::session::Session;
@@ -22,7 +24,7 @@ pub struct ListQuery {
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<Vec<Workspace>>),
(status = 200, description = "List of workspaces.", body = ApiResponse<Vec<WorkspaceDetail>>),
(status = 401, description = "Unauthenticated.", body = ApiErrorResponse),
(status = 500, description = "Database read failed.", body = ApiErrorResponse)
)
@@ -40,5 +42,17 @@ pub async fn handle(
query.offset.unwrap_or(0),
)
.await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(data)))
let db = &service.ctx.db;
let owner_ids: Vec<Uuid> = data.iter().map(|w| w.owner_id).collect();
let users = resolve_users(db, &owner_ids).await?;
let details: Vec<WorkspaceDetail> = data
.into_iter()
.map(|w| {
let owner = users.get(&w.owner_id).cloned().unwrap_or_default();
w.into_detail(owner)
})
.collect();
Ok(HttpResponse::Ok().json(ApiResponse::new(details)))
}