fooder-api/fooder/view/entry.py
Piotr Domański e2af49046c
All checks were successful
Python lint and test / linttest (push) Successful in 5m30s
[isort] ran with black profile
2024-08-04 16:17:16 +02:00

34 lines
878 B
Python

from fastapi import APIRouter, Depends, Request
from ..controller.entry import CreateEntry, DeleteEntry, UpdateEntry
from ..model.entry import CreateEntryPayload, Entry, UpdateEntryPayload
router = APIRouter(tags=["entry"])
@router.post("", response_model=Entry)
async def create_entry(
request: Request,
data: CreateEntryPayload,
contoller: CreateEntry = Depends(CreateEntry),
):
return await contoller.call(data)
@router.patch("/{entry_id}", response_model=Entry)
async def update_entry(
request: Request,
entry_id: int,
data: UpdateEntryPayload,
contoller: UpdateEntry = Depends(UpdateEntry),
):
return await contoller.call(entry_id, data)
@router.delete("/{entry_id}")
async def delete_entry(
request: Request,
entry_id: int,
contoller: DeleteEntry = Depends(DeleteEntry),
):
return await contoller.call(entry_id)