feat: initialize thoughts-frontend with Next.js, TypeScript, and ESLint
- Add ESLint configuration for Next.js and TypeScript support. - Create Next.js configuration file with standalone output option. - Initialize package.json with scripts for development, build, and linting. - Set up PostCSS configuration for Tailwind CSS. - Add SVG assets for UI components. - Create TypeScript configuration for strict type checking and module resolution.
This commit is contained in:
24
thoughts-backend/app/src/persistence/blog.rs
Normal file
24
thoughts-backend/app/src/persistence/blog.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DbConn, DbErr, EntityTrait, QueryFilter, Set};
|
||||
|
||||
use models::{domains::blog, params::blog::CreateBlogParams, queries::blog::BlogQuery};
|
||||
|
||||
pub async fn search_blogs(db: &DbConn, query: BlogQuery) -> Result<Vec<blog::Model>, DbErr> {
|
||||
blog::Entity::find()
|
||||
.filter(blog::Column::Title.contains(query.title.unwrap_or_default()))
|
||||
.all(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn create_blog(
|
||||
db: &DbConn,
|
||||
params: CreateBlogParams,
|
||||
) -> Result<blog::ActiveModel, DbErr> {
|
||||
blog::ActiveModel {
|
||||
author_id: Set(params.author_id as i32),
|
||||
title: Set(params.title),
|
||||
content: Set(params.content),
|
||||
..Default::default()
|
||||
}
|
||||
.save(db)
|
||||
.await
|
||||
}
|
2
thoughts-backend/app/src/persistence/mod.rs
Normal file
2
thoughts-backend/app/src/persistence/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod blog;
|
||||
pub mod user;
|
28
thoughts-backend/app/src/persistence/user.rs
Normal file
28
thoughts-backend/app/src/persistence/user.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use sea_orm::{ActiveModelTrait, ColumnTrait, DbConn, DbErr, EntityTrait, QueryFilter, Set};
|
||||
|
||||
use models::domains::user;
|
||||
use models::params::user::CreateUserParams;
|
||||
use models::queries::user::UserQuery;
|
||||
|
||||
pub async fn create_user(
|
||||
db: &DbConn,
|
||||
params: CreateUserParams,
|
||||
) -> Result<user::ActiveModel, DbErr> {
|
||||
user::ActiveModel {
|
||||
username: Set(params.username),
|
||||
..Default::default()
|
||||
}
|
||||
.save(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn search_users(db: &DbConn, query: UserQuery) -> Result<Vec<user::Model>, DbErr> {
|
||||
user::Entity::find()
|
||||
.filter(user::Column::Username.contains(query.username.unwrap_or_default()))
|
||||
.all(db)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_user(db: &DbConn, id: i32) -> Result<Option<user::Model>, DbErr> {
|
||||
user::Entity::find_by_id(id).one(db).await
|
||||
}
|
Reference in New Issue
Block a user