-
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
17 changed files
with
233 additions
and
15 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
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,41 @@ | ||
use crate::api::dto::repo_dto::RepoInfo; | ||
use crate::metadata::service::MetaService; | ||
use actix_web::{web, Responder}; | ||
use crate::api::app_write::AppWrite; | ||
|
||
|
||
#[utoipa::path( | ||
get, | ||
tag = "repo", | ||
path = "/api/v1/repo/info", | ||
params( | ||
("uid" = String, Query, description = "Repo Uid"), | ||
), | ||
responses( | ||
(status = 200, description = "Success"), | ||
(status = 400, description = "Bad Request") | ||
) | ||
)] | ||
pub async fn api_repo_info_get( | ||
service: web::Data<MetaService>, | ||
path: web::Path<(String,String)> | ||
) -> impl Responder | ||
{ | ||
let (owner, repo) = path.into_inner(); | ||
let repo_id = match service.repo_service().owner_name_by_uid(owner,repo).await{ | ||
Ok(data) => { | ||
data | ||
} | ||
Err(e) => { | ||
return AppWrite::error(e.to_string()) | ||
} | ||
}; | ||
match service.repo_service().info(repo_id).await{ | ||
Ok(data) => { | ||
AppWrite::ok(data) | ||
} | ||
Err(e) => { | ||
AppWrite::error(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,2 @@ | ||
pub mod search; | ||
pub mod info; |
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,35 @@ | ||
use crate::api::dto::repo_dto::RepoSearch; | ||
use crate::metadata::service::MetaService; | ||
use actix_web::{web, Responder}; | ||
use crate::api::app_write::AppWrite; | ||
|
||
#[utoipa::path( | ||
get, | ||
tag = "search", | ||
path = "/api/v1/search", | ||
params( | ||
("keywords" = String, Query, description = "Search Keywords"), | ||
("page" = u64, Query, description = "Page"), | ||
("size" = u64, Query, description = "Size"), | ||
), | ||
responses( | ||
(status = 200, description = "Success"), | ||
(status = 400, description = "Bad Request") | ||
) | ||
)] | ||
pub async fn api_repo_search( | ||
service: web::Data<MetaService>, | ||
query: web::Query<RepoSearch> | ||
) | ||
-> impl Responder | ||
{ | ||
let (keywords, page, size) = (query.keywords.clone(), query.page, query.size); | ||
match service.repo_service().search(keywords,page,size).await{ | ||
Ok(data) => { | ||
AppWrite::ok(data) | ||
} | ||
Err(e) => { | ||
AppWrite::error(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 |
---|---|---|
|
@@ -5,4 +5,5 @@ pub mod login; | |
pub mod apply; | ||
pub mod reset; | ||
pub mod logout; | ||
pub mod info; | ||
pub mod info; | ||
pub mod starred; |
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,36 @@ | ||
use actix_web::{web, Responder}; | ||
use crate::api::app_write::AppWrite; | ||
use crate::api::dto::repo_dto::RepoSearch; | ||
use crate::api::dto::user_dto::UserOv; | ||
use crate::metadata::service::MetaService; | ||
|
||
#[utoipa::path( | ||
get, | ||
tag = "users", | ||
path = "/api/v1/users/search", | ||
params( | ||
("keywords" = String, Query, description = "Search Keywords"), | ||
("page" = u64, Query, description = "Page"), | ||
("size" = u64, Query, description = "Size"), | ||
), | ||
responses( | ||
(status = 200, description = "Success"), | ||
(status = 400, description = "Bad Request") | ||
) | ||
)] | ||
pub async fn api_users_search( | ||
service: web::Data<MetaService>, | ||
query: web::Query<RepoSearch> | ||
) | ||
-> impl Responder | ||
{ | ||
let (keywords, page, size) = (query.keywords.clone(), query.page, query.size); | ||
match service.user_service().search(keywords,page,size).await{ | ||
Ok(data) => { | ||
AppWrite::<Vec<UserOv>>::ok(data) | ||
} | ||
Err(e) => { | ||
AppWrite::error(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,33 @@ | ||
use actix_web::{web, Responder}; | ||
use crate::api::app_write::AppWrite; | ||
use crate::metadata::service::MetaService; | ||
|
||
#[utoipa::path( | ||
get, | ||
tag = "users", | ||
path = "/api/v1/users/{username}/starred", | ||
responses( | ||
( status = 200, description = "Success" ), | ||
( status = 400, description = "Bad Request" ) | ||
) | ||
)] | ||
pub async fn api_users_starred( | ||
service: web::Data<MetaService>, | ||
path: web::Path<String> | ||
) | ||
-> impl Responder | ||
{ | ||
let username = path.into_inner(); | ||
let uid = match service.user_service().username_to_uid(username).await{ | ||
Ok(uid) => uid, | ||
Err(e) => return AppWrite::error(e.to_string()) | ||
}; | ||
match service.user_service().star(uid).await{ | ||
Ok(data) => { | ||
AppWrite::ok(data) | ||
} | ||
Err(e) => { | ||
AppWrite::error(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
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,3 @@ | ||
use actix_web::{HttpRequest, HttpResponse, Responder}; | ||
use tracing::info; | ||
use crate::ROOT_PATH; | ||
|
||
|
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ pub mod reset; | |
pub mod info; | ||
pub mod check; | ||
pub mod setting; | ||
pub mod search; | ||
|
||
|
||
#[derive(Clone)] | ||
|
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,18 @@ | ||
use crate::api::dto::user_dto::UserOv; | ||
use crate::metadata::model::users::users; | ||
use crate::metadata::service::users_service::UserService; | ||
use sea_orm::*; | ||
|
||
impl UserService { | ||
pub async fn search(&self, keywords: String, page: u64, size: u64) -> anyhow::Result<Vec<UserOv>>{ | ||
let models = users::Entity::find() | ||
.filter(users::Column::Username.contains(keywords.clone())) | ||
.filter(users::Column::Name.contains(keywords.clone())) | ||
.filter(users::Column::Description.contains(keywords)) | ||
.offset(page * size) | ||
.limit(size) | ||
.all(&self.db) | ||
.await?; | ||
Ok(models.into_iter().map(|model| UserOv::from(model)).collect()) | ||
} | ||
} |
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