1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

оптимизация сборки фронтенда2

This commit is contained in:
MoonTestUse1
2025-01-03 04:01:50 +06:00
parent 5327b86a7d
commit d898532154
3 changed files with 61 additions and 28 deletions

View File

@@ -1,9 +1,10 @@
"""Admin routes"""
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from typing import List
from ..database import get_db
from ..crud import statistics, requests
from ..utils.loggers import request_logger
from .. import crud, schemas
from ..utils.auth import get_current_admin
router = APIRouter()
@@ -16,11 +17,33 @@ async def get_statistics(period: str = "week", db: Session = Depends(get_db)):
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"""
@router.get("/requests", response_model=List[schemas.Request])
async def get_all_requests(
skip: int = 0,
limit: int = 100,
db: Session = Depends(get_db),
_: dict = Depends(get_current_admin)
):
"""
Получить список всех заявок (только для админа)
"""
try:
return requests.get_requests(db, skip=skip, limit=limit)
requests = crud.requests.get_requests(db, skip=skip, limit=limit)
return requests
except Exception as e:
request_logger.error(f"Error getting requests: {e}")
raise HTTPException(status_code=500, detail="Ошибка при получении заявок")
print(f"Error getting requests: {str(e)}")
raise HTTPException(status_code=500, detail="Internal server error")
@router.get("/requests/{request_id}", response_model=schemas.Request)
async def get_request_by_id(
request_id: int,
db: Session = Depends(get_db),
_: dict = Depends(get_current_admin)
):
"""
Получить заявку по ID (только для админа)
"""
request = crud.requests.get_request(db, request_id)
if request is None:
raise HTTPException(status_code=404, detail="Request not found")
return request