agent init
This commit is contained in:
@@ -18,10 +18,14 @@ router = APIRouter(prefix="/api/chapters", tags=["chapters"])
|
||||
@router.get("", response_model=List[dict])
|
||||
async def get_chapters(
|
||||
current_user: UserModel = Depends(get_current_user),
|
||||
is_new: Optional[bool] = Query(None, description="仅返回未读章节"),
|
||||
db: AsyncSession = Depends(get_async_db)
|
||||
):
|
||||
"""获取用户所有章节(需要认证)"""
|
||||
stmt = select(ChapterModel).where(ChapterModel.user_id == current_user.id).order_by(ChapterModel.order_index)
|
||||
stmt = select(ChapterModel).where(ChapterModel.user_id == current_user.id)
|
||||
if is_new is True:
|
||||
stmt = stmt.where(ChapterModel.is_new == True)
|
||||
stmt = stmt.order_by(ChapterModel.order_index)
|
||||
result = await db.execute(stmt)
|
||||
chapters = result.scalars().all()
|
||||
|
||||
@@ -33,7 +37,10 @@ async def get_chapters(
|
||||
"order_index": ch.order_index,
|
||||
"status": ch.status,
|
||||
"category": ch.category,
|
||||
"images": ch.images or []
|
||||
"images": ch.images or [],
|
||||
"updated_at": ch.updated_at.isoformat() if ch.updated_at else None,
|
||||
"is_new": ch.is_new,
|
||||
"source_segments": ch.source_segments or [],
|
||||
}
|
||||
for ch in chapters
|
||||
]
|
||||
@@ -61,7 +68,10 @@ async def get_chapter(
|
||||
"order_index": chapter.order_index,
|
||||
"status": chapter.status,
|
||||
"category": chapter.category,
|
||||
"images": chapter.images or []
|
||||
"images": chapter.images or [],
|
||||
"updated_at": chapter.updated_at.isoformat() if chapter.updated_at else None,
|
||||
"is_new": chapter.is_new,
|
||||
"source_segments": chapter.source_segments or [],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user