add: full journals api
add: full notes api
This commit is contained in:
parent
102ea0ee35
commit
42421bd906
11 changed files with 476 additions and 12 deletions
|
@ -3,7 +3,7 @@ use crate::{
|
|||
model::{
|
||||
auth::User,
|
||||
permissions::FinePermission,
|
||||
journals::{Journal, JournalViewPermission},
|
||||
journals::{Journal, JournalPrivacyPermission},
|
||||
Error, Result,
|
||||
},
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ impl DataManager {
|
|||
created: get!(x->1(i64)) as usize,
|
||||
owner: get!(x->2(i64)) as usize,
|
||||
title: get!(x->3(String)),
|
||||
view: serde_json::from_str(&get!(x->4(String))).unwrap(),
|
||||
privacy: serde_json::from_str(&get!(x->4(String))).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ impl DataManager {
|
|||
|
||||
let res = query_rows!(
|
||||
&conn,
|
||||
"SELECT * FROM journals WHERE owner = $1 ORDER BY name ASC",
|
||||
"SELECT * FROM journals WHERE owner = $1 ORDER BY title ASC",
|
||||
&[&(id as i64)],
|
||||
|x| { Self::get_journal_from_row(x) }
|
||||
);
|
||||
|
@ -89,7 +89,7 @@ impl DataManager {
|
|||
&(data.created as i64),
|
||||
&(data.owner as i64),
|
||||
&data.title,
|
||||
&serde_json::to_string(&data.view).unwrap(),
|
||||
&serde_json::to_string(&data.privacy).unwrap(),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -137,5 +137,5 @@ impl DataManager {
|
|||
}
|
||||
|
||||
auto_method!(update_journal_title(&str)@get_journal_by_id:MANAGE_JOURNALS -> "UPDATE journals SET title = $1 WHERE id = $2" --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_journal_view(JournalViewPermission)@get_journal_by_id:MANAGE_JOURNALS -> "UPDATE journals SET privacy = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.journal:{}");
|
||||
auto_method!(update_journal_privacy(JournalPrivacyPermission)@get_journal_by_id:MANAGE_JOURNALS -> "UPDATE journals SET privacy = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.journal:{}");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue