use ::session::AuthedUser; use api::http::{Path, State}; use api::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler::RepoPath; use crate::service::GitService; use crate::service::repos::RepoDto; #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/archive", tag = "repos", description = "将仓库标记为归档状态,禁止继续作为常规写入目标。", params(RepoPath), responses( (status = 200, description = "archive repo", body = AppResponseData) ) )] pub async fn archive_repo( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, ) -> Result, ApiError> { let caller = uid; let ctx = service .context(path.space_name, path.repo_name) .await .map_err(GitApiError::from)?; let out = service .set_repo_archived(&ctx, caller, true) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) } #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/unarchive", tag = "repos", description = "清除仓库的归档状态,使仓库恢复为可常规使用。", params(RepoPath), responses( (status = 200, description = "unarchive repo", body = AppResponseData) ) )] pub async fn unarchive_repo( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, ) -> Result, ApiError> { let caller = uid; let ctx = service .context(path.space_name, path.repo_name) .await .map_err(GitApiError::from)?; let out = service .set_repo_archived(&ctx, caller, false) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }