feat: 添加章节管理功能以支持清除回忆
- 在数据库模型中新增 is_active 字段,用于标记章节是否启用。 - 添加数据库迁移脚本以更新现有章节,确保默认值为 TRUE。 - 更新章节相关的 API 以仅返回 active 章节,并实现清除章节的功能。 - 在 Android 客户端中实现清除章节的确认弹窗和相应的 API 调用,提升用户体验。
This commit is contained in:
@@ -112,9 +112,12 @@ async def export_pdf(
|
||||
if book.user_id != current_user.id:
|
||||
raise HTTPException(status_code=403, detail="无权导出此回忆录")
|
||||
|
||||
# 获取所有章节
|
||||
# 获取所有 active 章节
|
||||
from database.models import Chapter
|
||||
stmt = select(Chapter).where(Chapter.user_id == current_user.id).order_by(Chapter.order_index)
|
||||
stmt = select(Chapter).where(
|
||||
Chapter.user_id == current_user.id,
|
||||
Chapter.is_active == True
|
||||
).order_by(Chapter.order_index)
|
||||
result = await db.execute(stmt)
|
||||
chapters = result.scalars().all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user