Spaces:
Sleeping
Sleeping
feat update get
Browse files
src/expon/feedback/interfaces/rest/feedback_controller.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from fastapi import APIRouter, Depends, HTTPException
|
2 |
from sqlalchemy.orm import Session
|
3 |
from uuid import UUID
|
|
|
4 |
|
5 |
from src.expon.shared.infrastructure.dependencies import get_db
|
6 |
from src.expon.feedback.interfaces.rest.feedback_request import FeedbackRequest
|
@@ -19,18 +20,18 @@ def generate_feedback(request: FeedbackRequest, db: Session = Depends(get_db)):
|
|
19 |
result = service.generate_feedback(request.presentation_id)
|
20 |
return result
|
21 |
|
22 |
-
@router.get("/user/{user_id}", response_model=
|
23 |
def get_feedback_by_user(user_id: UUID, db: Session = Depends(get_db)):
|
24 |
repo = FeedbackRepository(db)
|
25 |
results = repo.get_by_user(user_id)
|
26 |
return results
|
27 |
|
28 |
-
@router.get("/presentation/{presentation_id}", response_model=FeedbackResponse)
|
29 |
def get_feedback_by_presentation(presentation_id: UUID, db: Session = Depends(get_db)):
|
30 |
repo = FeedbackRepository(db)
|
31 |
-
|
32 |
|
33 |
-
if
|
34 |
raise HTTPException(status_code=404, detail="Feedback no encontrado")
|
35 |
|
36 |
-
return
|
|
|
1 |
from fastapi import APIRouter, Depends, HTTPException
|
2 |
from sqlalchemy.orm import Session
|
3 |
from uuid import UUID
|
4 |
+
from typing import List
|
5 |
|
6 |
from src.expon.shared.infrastructure.dependencies import get_db
|
7 |
from src.expon.feedback.interfaces.rest.feedback_request import FeedbackRequest
|
|
|
20 |
result = service.generate_feedback(request.presentation_id)
|
21 |
return result
|
22 |
|
23 |
+
@router.get("/user/{user_id}", response_model=List[FeedbackResponse])
|
24 |
def get_feedback_by_user(user_id: UUID, db: Session = Depends(get_db)):
|
25 |
repo = FeedbackRepository(db)
|
26 |
results = repo.get_by_user(user_id)
|
27 |
return results
|
28 |
|
29 |
+
@router.get("/presentation/{presentation_id}", response_model=List[FeedbackResponse])
|
30 |
def get_feedback_by_presentation(presentation_id: UUID, db: Session = Depends(get_db)):
|
31 |
repo = FeedbackRepository(db)
|
32 |
+
results = repo.get_by_presentation(presentation_id)
|
33 |
|
34 |
+
if not results:
|
35 |
raise HTTPException(status_code=404, detail="Feedback no encontrado")
|
36 |
|
37 |
+
return results
|