diff --git a/app/api/v1/tryon.py b/app/api/v1/tryon.py index f990bce..def3cf7 100644 --- a/app/api/v1/tryon.py +++ b/app/api/v1/tryon.py @@ -72,6 +72,31 @@ async def tryon( else: return StandardResponse(code=500, message="试穿任务提交失败") +@router.get("/histories/all", tags=["tryon"]) +async def get_all_tryon_histories( + db: AsyncSession = Depends(deps.get_db) +): + """ + 获取所有试穿历史 + """ + histories = await db.execute(select(TryonHistory).where(TryonHistory.status == TryonStatus.COMPLETED).order_by(TryonHistory.create_time.desc())) + tryon_histories = histories.scalars().all() + + result = [] + for history in tryon_histories: + item = { + "id": history.id, + "person_image_url": history.person_image_url, + "top_clothing_url": history.top_clothing_url, + "bottom_clothing_url": history.bottom_clothing_url, + "completion_url": history.completion_url, + "comment": history.comment, + "score": history.score, + "create_time": history.create_time, + } + result.append(item) + return StandardResponse(code=200, message="试穿历史获取成功", data=result) + @router.get("/histories", tags=["tryon"]) async def get_tryon_histories( db: AsyncSession = Depends(deps.get_db), @@ -95,6 +120,9 @@ async def get_tryon_histories( "status": history.status, "task_id": history.task_id, "completion_url": history.completion_url, + "comment": history.comment, + "score": history.score, + "create_time": history.create_time, } result.append(item)