use postgresql

This commit is contained in:
2022-03-22 02:57:22 +08:00
parent 58eb7aba6f
commit c9659acd6e
23 changed files with 188 additions and 38 deletions

View File

@@ -18,11 +18,12 @@ pub async fn delete(di: Form<DeleteInput>, user: CurrentUser, db: Db) -> API<Val
"cid" => {
let c = Comment::get(&db, di.id).await.m()?;
c.soft_delete(&user, &db).await?;
let p = Post::get(&db, c.post_id).await.m()?;
p.change_n_comments(&db, -1).await.m()?;
}
"pid" => {
let p = Post::get(&db, di.id).await.m()?;
p.soft_delete(&user, &db).await?;
p.change_n_comments(&db, -1).await.m()?;
}
_ => return Err(APIError::PcError(NotAllowed)),
}

View File

@@ -140,7 +140,7 @@ pub async fn get_list(
#[post("/dopost", data = "<poi>")]
pub async fn publish_post(poi: Form<PostInput>, user: CurrentUser, db: Db) -> JsonAPI {
let r = Post::create(
let p = Post::create(
&db,
NewPost {
content: poi.text.to_string(),
@@ -156,7 +156,6 @@ pub async fn publish_post(poi: Form<PostInput>, user: CurrentUser, db: Db) -> Js
.m()?;
// TODO: attention
Ok(json!({
"data": r,
"code": 0
}))
}