mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Починка adm
This commit is contained in:
26
backend/app/routers/admin.py
Normal file
26
backend/app/routers/admin.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Admin routes"""
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
from ..database import get_db
|
||||
from ..crud import statistics, requests
|
||||
from ..utils.loggers import request_logger
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/statistics")
|
||||
async def get_statistics(period: str = "week", db: Session = Depends(get_db)):
|
||||
"""Get request statistics"""
|
||||
try:
|
||||
return statistics.get_statistics(db, period)
|
||||
except Exception as e:
|
||||
request_logger.error(f"Error getting statistics: {e}")
|
||||
raise HTTPException(status_code=500, detail="Ошибка при получении статистики")
|
||||
|
||||
@router.get("/requests")
|
||||
async def get_all_requests(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
|
||||
"""Get all requests with employee details"""
|
||||
try:
|
||||
return requests.get_requests(db, skip=skip, limit=limit)
|
||||
except Exception as e:
|
||||
request_logger.error(f"Error getting requests: {e}")
|
||||
raise HTTPException(status_code=500, detail="Ошибка при получении заявок")
|
Reference in New Issue
Block a user