jde-server/core/handlers/profile/handlers.py

35 lines
923 B
Python

from fastapi import APIRouter, Path
from core.models.office.db import ProfileDB
from core.models.office.requests import CreateOrUpdateProfileRequest
from core.registry import profile_storage
router = APIRouter(prefix='/profiles')
# todo implement this handlers in services and storages. Then use fastapi.Depends()
@router.post('/')
async def create_profile(data: CreateOrUpdateProfileRequest):
return profile_storage.create_profile(data)
@router.get('/')
async def list_profiles() -> list[ProfileDB]:
return profile_storage.list_all_profiles()
@router.get('/{profile_id}')
async def get_profile(profile_id: int = Path()) -> ProfileDB:
return profile_storage.get_by_id(profile_id)
@router.delete('/{profile_id}')
async def delete_profile(profile_id: int = Path()):
pass
@router.put('/')
async def update_profile(data: CreateOrUpdateProfileRequest):
profile_storage.update_profile(data=data)