2023-04-01 16:19:12 +02:00
|
|
|
from fastapi import APIRouter, Depends, Request
|
|
|
|
|
2024-08-04 16:17:16 +02:00
|
|
|
from ..controller.entry import CreateEntry, DeleteEntry, UpdateEntry
|
|
|
|
from ..model.entry import CreateEntryPayload, Entry, UpdateEntryPayload
|
2023-04-01 16:19:12 +02:00
|
|
|
|
|
|
|
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)
|