-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
525 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod repo_access; | ||
pub mod repo_access; | ||
pub mod repo_owner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use uuid::Uuid; | ||
use crate::api::service::Service; | ||
|
||
pub async fn check_repo_owner(service: &Service, uid: Uuid, repo_id: Uuid) -> anyhow::Result<bool>{ | ||
let repo = service.repo.owner(uid).await?; | ||
if repo.iter().any(|x| x.uid == repo_id){ | ||
Ok(true) | ||
}else { | ||
let groups = service.group.check_member(repo_id,2).await?; | ||
let group_ids = groups | ||
.iter() | ||
.map(|x| x.uid) | ||
.collect::<Vec<_>>(); | ||
let mut repos = vec![]; | ||
for group_id in group_ids { | ||
let repo = service.repo.repo_by_group(group_id).await?; | ||
repos.extend(repo); | ||
} | ||
if repos.iter().any(|x| x.uid == repo_id){ | ||
Ok(true) | ||
}else{ | ||
Ok(false) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::api::service::Service; | ||
use crate::store::dto::CommitDto; | ||
use crate::utils::r::R; | ||
use actix_web::{web, Responder}; | ||
use uuid::Uuid; | ||
|
||
#[utoipa::path( | ||
get, | ||
path = "/api/repo/{repo_id}/commit/{commit_id}/history", | ||
tag = "repo", | ||
params( | ||
("repo_id" = String, description = "repo id"), | ||
("commit_id" = String, description = "commit id"), | ||
), | ||
responses( | ||
(status = 200, description = "success", body = Vec<CommitDto>), | ||
(status = 500, description = "error", body = String) | ||
) | ||
)] | ||
pub async fn api_repo_commit_history( | ||
path: web::Path<(Uuid,String)>, | ||
service: web::Data<Service> | ||
) | ||
-> impl Responder | ||
{ | ||
let (repo_id, commit_id) = path.into_inner(); | ||
match service.repo.commit_history(repo_id, commit_id){ | ||
Ok(commits)=>{ | ||
R::<Vec<CommitDto>>{ | ||
code: 200, | ||
data: Option::from(commits), | ||
msg: Option::from("success".to_string()) | ||
} | ||
}, | ||
Err(e)=>{ | ||
R::<Vec<CommitDto>>{ | ||
code: 500, | ||
data: None, | ||
msg: Option::from(e.to_string()) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod history; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
pub mod create; | ||
pub mod object; | ||
pub mod info; | ||
pub mod branchs; | ||
pub mod branchs; | ||
pub mod commits; | ||
pub mod objects; | ||
pub mod rename; | ||
pub mod topic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod object; | ||
pub mod once; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use actix_web::web; | ||
use uuid::Uuid; | ||
use crate::api::dto::repo::RepoFilePath; | ||
use crate::api::service::Service; | ||
use crate::utils::r::R; | ||
|
||
#[utoipa::path( | ||
get, | ||
tag = "repo", | ||
path = "/api/repo/{repo_id}/object/{branch}/{ref}/once", | ||
params( | ||
("repo_id" = String, description = "repo id"), | ||
("branch" = String, description = "branch name"), | ||
("hash" = String, description = "hash"), | ||
), | ||
request_body = RepoFilePath, | ||
responses( | ||
(status = 200, description = "success", body= Vec<u8>), | ||
(status = 500, description = "error", body = String) | ||
) | ||
)] | ||
pub async fn api_repo_object_once( | ||
service: web::Data<Service>, | ||
path: web::Path<(Uuid,String,String)>, | ||
dto: web::Json<RepoFilePath> | ||
) -> impl actix_web::Responder | ||
{ | ||
let (repo_id, branch, hash) = path.into_inner(); | ||
match service.repo.once_files(repo_id, branch, hash, dto.path.to_string()).await{ | ||
Ok(byte)=>{ | ||
R::<Vec<u8>>{ | ||
code: 200, | ||
data: Option::from(byte), | ||
msg: Option::from("success".to_string()) | ||
} | ||
}, | ||
Err(e)=>{ | ||
R{ | ||
code: 500, | ||
data: None, | ||
msg: Option::from(e.to_string()) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.