first commit
This commit is contained in:
24
app/services/example_service.py
Normal file
24
app/services/example_service.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
|
||||
class ExampleService:
|
||||
def __init__(self):
|
||||
self._store: Dict[str, dict] = {}
|
||||
|
||||
async def list_all(self) -> List[dict]:
|
||||
return list(self._store.values())
|
||||
|
||||
async def get_by_id(self, example_id: str) -> Optional[dict]:
|
||||
return self._store.get(example_id)
|
||||
|
||||
async def create(self, data: dict) -> dict:
|
||||
example_id = str(uuid.uuid4())
|
||||
item = {
|
||||
"id": example_id,
|
||||
"created_at": datetime.utcnow().isoformat(),
|
||||
**data,
|
||||
}
|
||||
self._store[example_id] = item
|
||||
return item
|
||||
Reference in New Issue
Block a user