summaryrefslogtreecommitdiff
path: root/api/routes/measures.py
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-11-03 08:29:33 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-11-03 08:29:33 -0300
commit6319a9dc2913f005c735835ac4b46301d6885c64 (patch)
treedb25b78d0013e3cf3c0759575b76dc0bbcc92752 /api/routes/measures.py
parent9e5e5da02b4a9704543e0efd7eb568b31a77a369 (diff)
outros routes
Diffstat (limited to 'api/routes/measures.py')
-rw-r--r--api/routes/measures.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/api/routes/measures.py b/api/routes/measures.py
index e69de29..f98c203 100644
--- a/api/routes/measures.py
+++ b/api/routes/measures.py
@@ -0,0 +1,25 @@
+from fastapi import APIRouter
+from sqlalchemy import select
+from ..database import SessionLocal
+from ..models import Measure
+
+router = APIRouter(
+ prefix='/measures',
+ tags=['measures']
+)
+
+@router.get('/')
+async def get_measures():
+ dc = {'measures': []}
+ session = SessionLocal()
+ stmt = select(Measure)
+ measures = session.execute(stmt)
+ for measure in measures.scalars():
+ mem = {
+ 'id': measure.id,
+ 'name': measure.name,
+ 'unit_code': measure.unit_code
+ }
+ dc['measures'].append(mem)
+ dc['size'] = len(dc['measures'])
+ return dc