update
This commit is contained in:
parent
1b6b1f8429
commit
d0f608abaa
@ -16,8 +16,9 @@ from app.models.tryon import TryonHistory, TryonStatus
|
|||||||
from app.schemas.tryon import TryonHistoryModel
|
from app.schemas.tryon import TryonHistoryModel
|
||||||
from app.core.exceptions import BusinessError
|
from app.core.exceptions import BusinessError
|
||||||
from app.services import cos as cos_service
|
from app.services import cos as cos_service
|
||||||
|
from app.schemas.person_image import PersonImage
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
from sqlalchemy.orm import selectinload
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
@ -86,10 +87,25 @@ async def get_tryon_histories(
|
|||||||
"""
|
"""
|
||||||
获取试穿历史
|
获取试穿历史
|
||||||
"""
|
"""
|
||||||
histories = await db.execute(select(TryonHistory).where(TryonHistory.user_id == current_user.id).order_by(TryonHistory.create_time.desc()))
|
histories = await db.execute(select(TryonHistory).where(TryonHistory.user_id == current_user.id).order_by(TryonHistory.create_time.desc()).options(selectinload(TryonHistory.person_image)))
|
||||||
tryon_histories = histories.scalars().all()
|
tryon_histories = histories.scalars().all()
|
||||||
|
|
||||||
return StandardResponse(code=200, message="试穿历史获取成功", data=[TryonHistoryModel.model_validate(history) for history in tryon_histories])
|
result = []
|
||||||
|
for history in tryon_histories:
|
||||||
|
item = {
|
||||||
|
"id": history.id,
|
||||||
|
"person_image": PersonImage.model_validate(history.person_image),
|
||||||
|
"top_clothing_url": history.top_clothing_url,
|
||||||
|
"bottom_clothing_url": history.bottom_clothing_url,
|
||||||
|
"top_clothing_id": history.top_clothing_id,
|
||||||
|
"bottom_clothing_id": history.bottom_clothing_id,
|
||||||
|
"status": history.status,
|
||||||
|
"task_id": history.task_id,
|
||||||
|
"completion_url": history.completion_url,
|
||||||
|
}
|
||||||
|
result.append(item)
|
||||||
|
|
||||||
|
return StandardResponse(code=200, message="试穿历史获取成功", data=result)
|
||||||
|
|
||||||
@router.delete("/history/{history_id}", tags=["tryon"])
|
@router.delete("/history/{history_id}", tags=["tryon"])
|
||||||
async def delete_tryon_history(
|
async def delete_tryon_history(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user