uncommited changes
This commit is contained in:
18
backend/routers/auditories.py
Normal file
18
backend/routers/auditories.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
auditories = APIRouter(prefix="/auditories", tags=["auditories"])
|
||||
|
||||
@auditories.post("/", response_model=schemas.AuditoryRead)
|
||||
def create_auditory(item: schemas.AuditoryCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.Auditory(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@auditories.get("/", response_model=list[schemas.AuditoryRead])
|
||||
def list_auditories(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.Auditory).all()
|
||||
|
||||
18
backend/routers/components.py
Normal file
18
backend/routers/components.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
|
||||
components = APIRouter(prefix="/components", tags=["components"])
|
||||
|
||||
@components.post("/", response_model=schemas.ComponentRead)
|
||||
def create_component(item: schemas.ComponentCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.Component(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@components.get("/", response_model=list[schemas.ComponentRead])
|
||||
def list_components(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.Component).all()
|
||||
17
backend/routers/equipment_types.py
Normal file
17
backend/routers/equipment_types.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
equipment_types = APIRouter(prefix="/equipment-types", tags=["equipment_types"])
|
||||
|
||||
@equipment_types.post("/", response_model=schemas.EquipmentTypeRead)
|
||||
def create_equipment_type(item: schemas.EquipmentTypeCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.EquipmentType(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@equipment_types.get("/", response_model=list[schemas.EquipmentTypeRead])
|
||||
def list_equipment_types(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.EquipmentType).all()
|
||||
24
backend/routers/oboruds.py
Normal file
24
backend/routers/oboruds.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
oboruds = APIRouter(prefix="/oboruds", tags=["oboruds"])
|
||||
|
||||
@oboruds.post("/", response_model=schemas.OborudRead)
|
||||
def create_oborud(item: schemas.OborudCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.Oboruds(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@oboruds.get("/", response_model=list[schemas.OborudRead])
|
||||
def list_oboruds(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.Oboruds).all()
|
||||
|
||||
@oboruds.get("/{oborud_id}", response_model=schemas.OborudRead)
|
||||
def get_oborud(oborud_id: int, db: Session = Depends(database.get_db)):
|
||||
obj = db.query(models.Oboruds).filter(models.Oboruds.id == oborud_id).first()
|
||||
if not obj:
|
||||
raise HTTPException(status_code=404, detail="Oborud not found")
|
||||
return obj
|
||||
17
backend/routers/rashodniki.py
Normal file
17
backend/routers/rashodniki.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
consumables = APIRouter(prefix="/consumables", tags=["consumables"])
|
||||
|
||||
@consumables.post("/", response_model=schemas.ConsumableRead)
|
||||
def create_consumable(item: schemas.ConsumableCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.Consumable(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@consumables.get("/", response_model=list[schemas.ConsumableRead])
|
||||
def list_consumables(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.Consumable).all()
|
||||
17
backend/routers/zametki.py
Normal file
17
backend/routers/zametki.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
from .. import models, schemas, database
|
||||
|
||||
zametki = APIRouter(prefix="/zametki", tags=["zametki"])
|
||||
|
||||
@zametki.post("/", response_model=schemas.ZametkaRead)
|
||||
def create_zametka(item: schemas.ZametkaCreate, db: Session = Depends(database.get_db)):
|
||||
obj = models.Zametki(**item.dict())
|
||||
db.add(obj)
|
||||
db.commit()
|
||||
db.refresh(obj)
|
||||
return obj
|
||||
|
||||
@zametki.get("/", response_model=list[schemas.ZametkaRead])
|
||||
def list_zametki(db: Session = Depends(database.get_db)):
|
||||
return db.query(models.Zametki).all()
|
||||
Reference in New Issue
Block a user