api pagin, db _task_subquary, tasks depends
This commit is contained in:
12
src/api/dependacies/task_dep.py
Normal file
12
src/api/dependacies/task_dep.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Depends, Query
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Pagination(BaseModel):
|
||||
page: int | None = Query(default=0, ge=0)
|
||||
limit: int | None = Query(default=30, ge=0, le=50)
|
||||
|
||||
|
||||
PaginationTasks = Annotated[Pagination, Depends()]
|
||||
@@ -3,6 +3,7 @@ from typing import Annotated
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from src.api.dependacies.db_dep import sessionDep
|
||||
from src.api.dependacies.task_dep import PaginationTasks
|
||||
from src.api.dependacies.user_dep import ActiveUser, TaskOwnerDep
|
||||
from src.schemas.tasks import TaskADDRequest
|
||||
from src.services.tasks import TaskService
|
||||
@@ -12,7 +13,7 @@ router = APIRouter(prefix="/tasks", tags=["Tasks"])
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_tasks(session: sessionDep, user: ActiveUser):
|
||||
async def get_tasks(session: sessionDep, user: ActiveUser, page: PaginationTasks):
|
||||
result = await UserService(session).get_user_with_tasks(user.id)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user