Refactor blog module and remove blog-related functionality
- Removed blog router and associated API endpoints. - Deleted blog persistence functions and related query parameters. - Removed blog schemas and models from the codebase. - Introduced common crate for shared types, including DateTimeWithTimeZoneWrapper. - Added Thought and Follow models with corresponding migrations. - Updated dependencies in Cargo.toml files to reflect changes. - Adjusted tests to remove references to the blog module.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::domains::blog;
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct BlogSchema {
|
||||
pub id: u32,
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
pub author_id: u32,
|
||||
}
|
||||
|
||||
impl From<blog::Model> for BlogSchema {
|
||||
fn from(blog: blog::Model) -> Self {
|
||||
Self {
|
||||
id: blog.id as u32,
|
||||
title: blog.title,
|
||||
content: blog.content,
|
||||
author_id: blog.author_id as u32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct BlogListSchema {
|
||||
pub blogs: Vec<BlogSchema>,
|
||||
}
|
||||
|
||||
impl From<Vec<blog::Model>> for BlogListSchema {
|
||||
fn from(blogs: Vec<blog::Model>) -> Self {
|
||||
Self {
|
||||
blogs: blogs.into_iter().map(BlogSchema::from).collect(),
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,2 +1,2 @@
|
||||
pub mod blog;
|
||||
pub mod thought;
|
||||
pub mod user;
|
||||
|
36
thoughts-backend/models/src/schemas/thought.rs
Normal file
36
thoughts-backend/models/src/schemas/thought.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use crate::domains::thought;
|
||||
use common::DateTimeWithTimeZoneWrapper;
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ThoughtSchema {
|
||||
pub id: i32,
|
||||
pub author_id: i32,
|
||||
pub content: String,
|
||||
pub created_at: DateTimeWithTimeZoneWrapper,
|
||||
}
|
||||
|
||||
impl From<thought::Model> for ThoughtSchema {
|
||||
fn from(model: thought::Model) -> Self {
|
||||
Self {
|
||||
id: model.id,
|
||||
author_id: model.author_id,
|
||||
content: model.content,
|
||||
created_at: model.created_at.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema)]
|
||||
pub struct ThoughtListSchema {
|
||||
pub thoughts: Vec<ThoughtSchema>,
|
||||
}
|
||||
|
||||
impl From<Vec<thought::Model>> for ThoughtListSchema {
|
||||
fn from(models: Vec<thought::Model>) -> Self {
|
||||
Self {
|
||||
thoughts: models.into_iter().map(ThoughtSchema::from).collect(),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user