-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
1 parent
37f700e
commit 2161417
Showing
5 changed files
with
80 additions
and
37 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/api/handlers/collection/fetch_collection_api_handler.rs
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,37 @@ | ||
use crate::api::handlers::model::fetch_model_api_handler::FetchModelResponse; | ||
use crate::avored_state::AvoRedState; | ||
use crate::error::{Error, Result}; | ||
use crate::models::collection_model::CollectionModel; | ||
use crate::models::token_claim_model::LoggedInUser; | ||
use crate::responses::ApiResponse; | ||
use axum::extract::{Path, State}; | ||
use axum::{Extension, Json}; | ||
use std::sync::Arc; | ||
|
||
pub async fn fetch_collection_api_handler( | ||
state: State<Arc<AvoRedState>>, | ||
Path(collection_id): Path<String>, | ||
Extension(logged_in_user): Extension<LoggedInUser>, | ||
) -> Result<Json<ApiResponse<CollectionModel>>> { | ||
println!("->> {:<12} - fetch_model_api_handler", "HANDLER"); | ||
|
||
let has_permission_bool = state | ||
.admin_user_service | ||
.has_permission(logged_in_user, String::from("get_model")) | ||
.await?; | ||
if !has_permission_bool { | ||
return Err(Error::Forbidden); | ||
} | ||
|
||
let model_model = state | ||
.collection_service | ||
.find_by_id(&state.db, collection_id) | ||
.await?; | ||
|
||
let response = ApiResponse { | ||
status: true, | ||
data: model_model, | ||
}; | ||
|
||
Ok(Json(response)) | ||
} |
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,5 @@ | ||
pub mod collection_table_api_handler; | ||
pub mod store_collection_api_handler; | ||
pub mod update_collection_api_handler; | ||
pub mod fetch_collection_api_handler; | ||
pub mod request; |
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