diff --git a/app/api/v1/tryon.py b/app/api/v1/tryon.py index 027c304..6ecde4c 100644 --- a/app/api/v1/tryon.py +++ b/app/api/v1/tryon.py @@ -86,7 +86,7 @@ async def get_tryon_histories( """ 获取试穿历史 """ - histories = await db.execute(select(TryonHistory).where(TryonHistory.user_id == current_user.id)) + histories = await db.execute(select(TryonHistory).where(TryonHistory.user_id == current_user.id).order_by(TryonHistory.create_time.desc())) tryon_histories = histories.scalars().all() return StandardResponse(code=200, message="试穿历史获取成功", data=[TryonHistoryModel.model_validate(history) for history in tryon_histories]) @@ -133,5 +133,10 @@ async def check_tryon_status( tryon_history.completion_url = url await db.commit() await db.refresh(tryon_history) + elif completion.get("status") == "FAILED": + tryon_history.status = TryonStatus.FAILED + await db.commit() + await db.refresh(tryon_history) + - return StandardResponse(code=200, message="检查试穿状态成功", data=TryonHistoryModel.model_validate(tryon_history)) + return StandardResponse(code=200, message="", data=TryonHistoryModel.model_validate(tryon_history))