diff options
| author | WriterV2 <primary-v2@protonmail.com> | 2024-11-03 18:50:29 +0100 |
|---|---|---|
| committer | WriterV2 <primary-v2@protonmail.com> | 2024-11-03 18:50:29 +0100 |
| commit | fa7f650562337c7f3a4fb7446e56575e26380494 (patch) | |
| tree | 082643ee68f3773e6b9bfd2ed42e75d1bee79d44 /src/db/story.rs | |
| parent | eb326116f4abc6b12ec81d06586d7cf08755538c (diff) | |
Feat: Finalize ability to get all products with details
- Remove dummy product
- Add ProductMarker method to get product id + implement
- Move method to get all products out of PageBuilder into its own
function in Product module
- Finalize getting all products with details
- Add empty implementation for Story for testing purposes (TODO: add
card details)
Diffstat (limited to 'src/db/story.rs')
| -rw-r--r-- | src/db/story.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/db/story.rs b/src/db/story.rs index ee79e4f..686c33f 100644 --- a/src/db/story.rs +++ b/src/db/story.rs @@ -1,8 +1,10 @@ use axum::async_trait; +use maud::html; use sqlx::SqlitePool; use crate::error::AppError; use crate::db::product::Product; +use crate::handlers::frontend_builder::PageBuilder; use super::product::ProductMarker; use super::ProductDatabaseHandler; @@ -17,16 +19,20 @@ pub struct Story { pub pid: i64, } -impl ProductMarker for Story {} +impl ProductMarker for Story { + fn product_id(&self) -> i64 { + self.pid + } +} #[async_trait] impl ProductDatabaseHandler for Story { - async fn get_all(pool: SqlitePool) -> Result<Vec<Self>, AppError> + async fn get_all(pool: &SqlitePool) -> Result<Vec<Self>, AppError> where Self: Sized, { Ok(sqlx::query_as!(Story, "SELECT * FROM story") - .fetch_all(&pool) + .fetch_all(pool) .await?) } @@ -63,3 +69,17 @@ impl ProductDatabaseHandler for Story { Ok(story) } } + +impl PageBuilder for Story { + fn page_title() -> String { + "Stories".to_string() + } + + // TODO: Add pdf and epub download link + language info + fn product_specific_card_content(&self) -> maud::Markup { + html!( + span { + } + ) + } +} |
