feat(admin): 后台新增条目与分组 CRUD
- POST /api/items + DELETE /api/items/{key}:新增应用/海报/图文,按分区/分组挂载;PATCH 支持 nodeKey 移动
- 分组 CRUD:POST /api/categories/{id}/groups、PATCH/DELETE /api/groups/{id}(删除级联组内条目)
- PATCH /api/categories/{id} 增加 blockNodeKey,首页卡片可选择预览分组
- /admin 新增「内容」Tab(新增/删除条目),「分区」Tab 内联分组管理与卡片预览
- 测试 59 passed(条目创建/移动/删除、分组增删改)
This commit is contained in:
@@ -185,6 +185,16 @@ impl Db {
|
||||
entries::load(&conn, key)
|
||||
}
|
||||
|
||||
pub fn create_entry(&self, new: entries::NewEntry) -> Result<EntryRecord, StashError> {
|
||||
let mut conn = self.lock()?;
|
||||
entries::create(&mut conn, new)
|
||||
}
|
||||
|
||||
pub fn remove_entry(&self, key: &str) -> Result<(), StashError> {
|
||||
let conn = self.lock()?;
|
||||
entries::remove(&conn, key)
|
||||
}
|
||||
|
||||
pub fn update_entry(
|
||||
&self,
|
||||
key: &str,
|
||||
@@ -221,6 +231,25 @@ impl Db {
|
||||
categories::update(&mut conn, id, patch)
|
||||
}
|
||||
|
||||
pub fn create_group(
|
||||
&self,
|
||||
section_id: &str,
|
||||
new: categories::NewGroup,
|
||||
) -> Result<(), StashError> {
|
||||
let mut conn = self.lock()?;
|
||||
categories::create_group(&mut conn, section_id, new)
|
||||
}
|
||||
|
||||
pub fn update_group(&self, id: &str, patch: categories::UpdateGroup) -> Result<(), StashError> {
|
||||
let conn = self.lock()?;
|
||||
categories::update_group(&conn, id, patch)
|
||||
}
|
||||
|
||||
pub fn remove_group(&self, id: &str) -> Result<(), StashError> {
|
||||
let conn = self.lock()?;
|
||||
categories::remove_group(&conn, id)
|
||||
}
|
||||
|
||||
pub fn remove_category(&self, id: &str) -> Result<(), StashError> {
|
||||
let mut conn = self.lock()?;
|
||||
categories::remove(&mut conn, id)
|
||||
|
||||
Reference in New Issue
Block a user