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
+19 -3
View File
@@ -1,10 +1,12 @@
use actix_web::{HttpResponse, web};
use serde::Deserialize;
use utoipa::IntoParams;
use uuid::Uuid;
use crate::api::response::{ApiErrorResponse, ApiResponse};
use crate::error::AppError;
use crate::models::repos::Repo;
use crate::models::base_info::{resolve_users, resolve_workspaces};
use crate::models::repos::RepoDetail;
use crate::service::AppService;
use crate::session::Session;
@@ -41,7 +43,7 @@ pub struct QueryParams {
QueryParams,
),
responses(
(status = 200, description = "Repositories listed successfully. Returns an array of repository objects with metadata.", body = ApiResponse<Vec<Repo>>),
(status = 200, description = "Repositories listed successfully. Returns an array of repository objects with metadata.", body = ApiResponse<Vec<RepoDetail>>),
(status = 401, description = "Authentication required or session expired", body = ApiErrorResponse),
(status = 403, description = "Insufficient permissions to access this workspace", body = ApiErrorResponse),
(status = 404, description = "Workspace not found", body = ApiErrorResponse),
@@ -67,5 +69,19 @@ pub async fn list(
)
.await?;
Ok(HttpResponse::Ok().json(ApiResponse::new(repos)))
let db = &service.ctx.db;
let owner_ids: Vec<Uuid> = repos.iter().map(|r| r.owner_id).collect();
let ws_ids: Vec<Uuid> = repos.iter().map(|r| r.workspace_id).collect();
let users = resolve_users(db, &owner_ids).await?;
let workspaces = resolve_workspaces(db, &ws_ids).await?;
let details: Vec<RepoDetail> = repos
.into_iter()
.map(|r| {
let owner = users.get(&r.owner_id).cloned().unwrap_or_default();
let workspace = workspaces.get(&r.workspace_id).cloned().unwrap_or_default();
r.into_detail(owner, workspace)
})
.collect();
Ok(HttpResponse::Ok().json(ApiResponse::new(details)))
}