2023-04-01 16:19:12 +02:00
|
|
|
from fastapi import APIRouter, Depends, Request
|
|
|
|
from ..model.entry import Entry, CreateEntryPayload, UpdateEntryPayload
|
|
|
|
from ..controller.entry import CreateEntry, UpdateEntry, DeleteEntry
|
|
|
|
|
|
|
|
|
|
|
|
router = APIRouter(tags=["entry"])
|
|
|
|
|
|
|
|
|
2023-04-01 20:23:04 +02:00
|
|
|
@router.post("", response_model=Entry)
|
2023-04-01 16:19:12 +02:00
|
|
|
async def create_entry(
|
|
|
|
request: Request,
|
|
|
|
data: CreateEntryPayload,
|
|
|
|
contoller: CreateEntry = Depends(CreateEntry),
|
|
|
|
):
|
|
|
|
return await contoller.call(data)
|
|
|
|
|
|
|
|
|
2023-04-02 12:49:31 +02:00
|
|
|
@router.patch("/{entry_id}", response_model=Entry)
|
2023-04-01 16:19:12 +02:00
|
|
|
async def update_entry(
|
|
|
|
request: Request,
|
|
|
|
entry_id: int,
|
|
|
|
data: UpdateEntryPayload,
|
|
|
|
contoller: UpdateEntry = Depends(UpdateEntry),
|
|
|
|
):
|
|
|
|
return await contoller.call(entry_id, data)
|
|
|
|
|
|
|
|
|
2023-04-02 12:33:25 +02:00
|
|
|
@router.delete("/{entry_id}")
|
2023-04-01 16:19:12 +02:00
|
|
|
async def delete_entry(
|
|
|
|
request: Request,
|
|
|
|
entry_id: int,
|
|
|
|
contoller: DeleteEntry = Depends(DeleteEntry),
|
|
|
|
):
|
|
|
|
return await contoller.call(entry_id)
|