41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from typing import Annotated
 | 
						|
 | 
						|
from fastapi import APIRouter, Depends
 | 
						|
from sqlalchemy.ext.asyncio import AsyncSession
 | 
						|
 | 
						|
from backend.session import get_session
 | 
						|
from schemas.statistics import GetProfitChartDataRequest, GetProfitChartDataResponse, GetProfitTableDataResponse, \
 | 
						|
    GetProfitTableDataRequest
 | 
						|
from services.auth import authorized_user
 | 
						|
from services.statistics import StatisticsService
 | 
						|
 | 
						|
statistics_router = APIRouter(
 | 
						|
    prefix="/statistics",
 | 
						|
    tags=["statistics"],
 | 
						|
    dependencies=[Depends(authorized_user)]
 | 
						|
)
 | 
						|
 | 
						|
 | 
						|
@statistics_router.post(
 | 
						|
    '/get-profit-chart-data',
 | 
						|
    response_model=GetProfitChartDataResponse,
 | 
						|
    operation_id='get_profit_chart_data',
 | 
						|
)
 | 
						|
async def get_profit_chart_data(
 | 
						|
        session: Annotated[AsyncSession, Depends(get_session)],
 | 
						|
        request: GetProfitChartDataRequest
 | 
						|
):
 | 
						|
    return await StatisticsService(session).get_profit_chart_data(request)
 | 
						|
 | 
						|
 | 
						|
@statistics_router.post(
 | 
						|
    '/get-profit-table-data',
 | 
						|
    response_model=GetProfitTableDataResponse,
 | 
						|
    operation_id='get_profit_table_data',
 | 
						|
)
 | 
						|
async def get_profit_table_data(
 | 
						|
        session: Annotated[AsyncSession, Depends(get_session)],
 | 
						|
        request: GetProfitTableDataRequest
 | 
						|
):
 | 
						|
    return await StatisticsService(session).get_profit_table_data(request)
 |