feat: 游玩记录支持区分原故事和AI草稿,已下架草稿显示标签
This commit is contained in:
@@ -747,3 +747,42 @@ async def unpublish_draft_from_center(
|
||||
|
||||
return {"code": 0, "message": "已从创作中心移除"}
|
||||
|
||||
|
||||
@router.put("/{draft_id}/collect")
|
||||
async def collect_draft(
|
||||
draft_id: int,
|
||||
userId: int,
|
||||
isCollected: bool = True,
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""收藏/取消收藏草稿"""
|
||||
await db.execute(
|
||||
update(StoryDraft)
|
||||
.where(
|
||||
StoryDraft.id == draft_id,
|
||||
StoryDraft.user_id == userId
|
||||
)
|
||||
.values(is_collected=isCollected)
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
return {"code": 0, "message": "收藏成功" if isCollected else "取消收藏成功"}
|
||||
|
||||
|
||||
@router.get("/{draft_id}/collect-status")
|
||||
async def get_draft_collect_status(
|
||||
draft_id: int,
|
||||
userId: int,
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""获取草稿收藏状态"""
|
||||
result = await db.execute(
|
||||
select(StoryDraft.is_collected)
|
||||
.where(
|
||||
StoryDraft.id == draft_id,
|
||||
StoryDraft.user_id == userId
|
||||
)
|
||||
)
|
||||
is_collected = result.scalar_one_or_none()
|
||||
|
||||
return {"code": 0, "data": {"isCollected": is_collected or False}}
|
||||
|
||||
Reference in New Issue
Block a user