@ -79,7 +79,7 @@ app = FastAPI()
@app.post ( " /token " , response_model = Token , tags = [ " bff " , " token " ] )
@app.post ( " /token " , response_model = Token , tags = [ " token " ] )
def login_account_for_access_token (
form_data : OAuth2PasswordRequestForm = Depends ( ) ,
db : Session = Depends ( get_db )
@ -103,7 +103,7 @@ def login_account_for_access_token(
return Token ( access_token = access_token , token_type = " bearer " )
@app.get ( " /dashboard/cards " , tags = [ " bff " , " dashboard " ] , response_model = DashboardCardsResponse )
@app.get ( " /dashboard/cards " , tags = [ " dashboard " ] , response_model = DashboardCardsResponse )
def get_dashboard_cards ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает данные для карточек на главной панели ( dashboard ) пользователя , включая общий доход , выплаты , активных рефералов , ожидающие выплаты и общее количество продаж .
@ -134,7 +134,7 @@ def get_dashboard_cards(current_account: Account = Depends(get_current_account),
" totalSales " : totalSales
}
@app.get ( " /dashboard/chart/total " , tags = [ " bff " , " dashboard " ] , response_model = DashboardChartTotalResponse )
@app.get ( " /dashboard/chart/total " , tags = [ " dashboard " ] , response_model = DashboardChartTotalResponse )
def get_dashboard_chart_total ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает данные для графика " Общий доход и продажи по датам " на главной панели ( dashboard ) .
@ -155,7 +155,7 @@ def get_dashboard_chart_total(current_account: Account = Depends(get_current_acc
]
return DashboardChartTotalResponse ( items = data )
@app.get ( " /dashboard/chart/agent " , tags = [ " bff " , " dashboard " ] , response_model = DashboardChartAgentResponse )
@app.get ( " /dashboard/chart/agent " , tags = [ " dashboard " ] , response_model = DashboardChartAgentResponse )
def get_dashboard_chart_agent ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает данные для графика " Продажи по агентам " на главной панели ( dashboard ) .
@ -185,7 +185,7 @@ def get_dashboard_chart_agent(current_account: Account = Depends(get_current_acc
} )
return DashboardChartAgentResponse ( items = result )
@app.get ( " /stat/agents " , tags = [ " bff " , " stat " ] , response_model = StatAgentsResponse )
@app.get ( " /stat/agents " , tags = [ " stat " ] , response_model = StatAgentsResponse )
def get_agents_stat (
db : Session = Depends ( get_db ) ,
date_start : str = Query ( None ) ,
@ -229,7 +229,7 @@ def get_agents_stat(
} )
return StatAgentsResponse ( items = result )
@app.get ( " /stat/referrals " , tags = [ " bff " , " stat " ] , response_model = StatReferralsResponse )
@app.get ( " /stat/referrals " , tags = [ " stat " ] , response_model = StatReferralsResponse )
def get_referrals_stat (
db : Session = Depends ( get_db ) ,
date_start : str = Query ( None ) ,
@ -262,7 +262,7 @@ def get_referrals_stat(
} )
return StatReferralsResponse ( items = result )
@app.get ( " /stat/sales " , tags = [ " bff " , " stat " ] , response_model = StatSalesResponse )
@app.get ( " /stat/sales " , tags = [ " stat " ] , response_model = StatSalesResponse )
def get_sales_stat (
db : Session = Depends ( get_db ) ,
date_start : str = Query ( None ) ,
@ -298,7 +298,7 @@ def get_sales_stat(
} )
return StatSalesResponse ( items = result )
@app.get ( " /billing/cards " , tags = [ " bff " , " billing " ] , response_model = BillingCardsResponse )
@app.get ( " /billing/cards " , tags = [ " billing " ] , response_model = BillingCardsResponse )
def get_billing_cards ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает ключевые показатели биллинга для компании , включая общий заработок , общие выплаты и доступные к выводу средства .
@ -321,7 +321,7 @@ def get_billing_cards(current_account: Account = Depends(get_current_account), d
" pendingPayouts " : pendingPayouts
}
@app.get ( " /billing/payouts/transactions " , tags = [ " bff " , " billing " ] , response_model = BillingPayoutsTransactionsResponse )
@app.get ( " /billing/payouts/transactions " , tags = [ " billing " ] , response_model = BillingPayoutsTransactionsResponse )
def get_billing_payouts_transactions (
db : Session = Depends ( get_db ) ,
date_start : str = Query ( None ) ,
@ -361,7 +361,7 @@ def get_billing_payouts_transactions(
} )
return BillingPayoutsTransactionsResponse ( items = result )
@app.get ( " /billing/chart/stat " , tags = [ " bff " , " billing " ] , response_model = BillingChartStatResponse )
@app.get ( " /billing/chart/stat " , tags = [ " billing " ] , response_model = BillingChartStatResponse )
def get_billing_chart_stat ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает статистику выплат по датам и статусам для компании текущего пользователя .
@ -386,7 +386,7 @@ def get_billing_chart_stat(current_account: Account = Depends(get_current_accoun
]
return BillingChartStatResponse ( items = data )
@app.get ( " /billing/chart/pie " , tags = [ " bff " , " billing " ] , response_model = BillingChartPieResponse )
@app.get ( " /billing/chart/pie " , tags = [ " billing " ] , response_model = BillingChartPieResponse )
def get_billing_chart_pie ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает круговую диаграмму статистики выплат по статусам для компании текущего пользователя .
@ -406,7 +406,7 @@ def get_billing_chart_pie(current_account: Account = Depends(get_current_account
@app.get ( " /account " , tags = [ " bff " , " account " ] , response_model = AccountResponse )
@app.get ( " /account " , tags = [ " account " ] , response_model = AccountResponse )
def get_account ( current_account : Account = Depends ( get_current_account ) ) :
"""
Возвращает базовую информацию о б аккаунте текущего пользователя ( имя и фамилию ) .
@ -416,7 +416,7 @@ def get_account(current_account: Account = Depends(get_current_account)):
" surname " : current_account . surname
}
@app.get ( " /account/profile " , tags = [ " bff " , " account " ] , response_model = AccountProfileResponse )
@app.get ( " /account/profile " , tags = [ " account " ] , response_model = AccountProfileResponse )
def get_account_profile ( current_account : Account = Depends ( get_current_account ) , db : Session = Depends ( get_db ) ) :
"""
Возвращает полную информацию о профиле аккаунта текущего пользователя , включая данные компании .
@ -434,11 +434,10 @@ def get_account_profile(current_account: Account = Depends(get_current_account),
" name " : company . name ,
" key " : company . key ,
" commission " : company . commission ,
" agent_commission " : company . agent_commission
}
}
@app.post ( " /account/profile " , tags = [ " bff " , " account " ] , response_model = AccountProfileUpdateResponse )
@app.post ( " /account/profile " , tags = [ " account " ] , response_model = AccountProfileUpdateResponse )
def update_account_profile (
req : AccountProfileUpdateRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -460,7 +459,7 @@ def update_account_profile(
db . refresh ( current_account )
return { " msg " : " Профиль обновлён успешно " }
@app.post ( " /account/password " , tags = [ " bff " , " account " ] , response_model = AccountPasswordChangeResponse )
@app.post ( " /account/password " , tags = [ " account " ] , response_model = AccountPasswordChangeResponse )
def change_account_password (
req : AccountPasswordChangeRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -486,7 +485,7 @@ def change_account_password(
# --- Новый функционал для агентских транзакций партнера ---
@app.get ( " /account/agent-transaction " , response_model = List [ AgentTransactionResponse ] , tags = [ " bff " , " account " ] )
@app.get ( " /account/agent-transaction " , response_model = List [ AgentTransactionResponse ] , tags = [ " account " ] )
def get_account_agent_transactions (
statuses : Optional [ List [ TransactionStatus ] ] = Query ( None ) ,
date_start : str = Query ( None ) ,
@ -543,7 +542,7 @@ def get_account_agent_transactions(
@app.get ( " /account/auto-approve " , tags = [ " bff " , " account " ] , response_model = AutoApproveSettingsGetResponse )
@app.get ( " /account/auto-approve " , tags = [ " account " ] , response_model = AutoApproveSettingsGetResponse )
def get_auto_approve_settings (
current_account : Account = Depends ( get_current_account ) ,
db : Session = Depends ( get_db )
@ -556,7 +555,7 @@ def get_auto_approve_settings(
raise HTTPException ( status_code = 404 , detail = " Компания не найдена " )
return { " auto_approve_transactions " : company . auto_approve_transactions }
@app.post ( " /account/auto-approve " , tags = [ " bff " , " account " ] , response_model = AutoApproveSettingsUpdateResponse )
@app.post ( " /account/auto-approve " , tags = [ " account " ] , response_model = AutoApproveSettingsUpdateResponse )
def update_auto_approve_settings (
req : AutoApproveSettingsRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -606,7 +605,7 @@ def update_auto_approve_settings(
@app.post ( " /account/approve-transactions " , tags = [ " bff " , " account " ] , response_model = ApproveTransactionsResult )
@app.post ( " /account/approve-transactions " , tags = [ " account " ] , response_model = ApproveTransactionsResult )
def approve_agent_transactions (
req : ApproveTransactionsRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -643,7 +642,7 @@ def approve_agent_transactions(
# --- Новый функционал для интеграционных токенов ---
@app.get ( " /account/integration-tokens " , tags = [ " bff " , " account " ] , response_model = List [ IntegrationTokenResponse ] )
@app.get ( " /account/integration-tokens " , tags = [ " account " ] , response_model = List [ IntegrationTokenResponse ] )
def get_integration_tokens (
current_account : Account = Depends ( get_current_account ) ,
db : Session = Depends ( get_db )
@ -655,7 +654,7 @@ def get_integration_tokens(
return tokens # Позволяем FastAPI самостоятельно сериализовать объекты IntegrationToken в IntegrationTokenResponse
@app.post ( " /account/integration-tokens " , tags = [ " bff " , " account " ] , response_model = IntegrationTokenResponse )
@app.post ( " /account/integration-tokens " , tags = [ " account " ] , response_model = IntegrationTokenResponse )
def create_integration_token (
req : IntegrationTokenCreateRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -688,7 +687,7 @@ def create_integration_token(
return response_token
@app.post ( " /account/integration-tokens/update-description " , tags = [ " bff " , " account " ] , response_model = Dict [ str , str ] )
@app.post ( " /account/integration-tokens/update-description " , tags = [ " account " ] , response_model = Dict [ str , str ] )
def update_integration_token_description (
req : IntegrationTokenUpdateRequest ,
current_account : Account = Depends ( get_current_account ) ,
@ -711,7 +710,7 @@ def update_integration_token_description(
db . refresh ( token )
return { " msg " : " Описание токена обновлено успешно " }
@app.delete ( " /account/integration-tokens/ {token_id} " , tags = [ " bff " , " account " ] , response_model = Dict [ str , str ] )
@app.delete ( " /account/integration-tokens/ {token_id} " , tags = [ " account " ] , response_model = Dict [ str , str ] )
def delete_integration_token (
token_id : int ,
current_account : Account = Depends ( get_current_account ) ,
@ -733,7 +732,7 @@ def delete_integration_token(
# --- Категории продаж ---
@app.get ( " / account/ category" , tags = [ " bff" , " account " ] , response_model = List [ SaleCategoryResponse ] )
@app.get ( " / category" , tags = [ " category " ] , response_model = List [ SaleCategoryResponse ] )
def get_sale_categories (
current_account : Account = Depends ( get_current_account ) ,
db : Session = Depends ( get_db )
@ -744,7 +743,7 @@ def get_sale_categories(
categories = db . exec ( select ( SaleCategory ) . where ( SaleCategory . company_id == current_account . company_id ) ) . all ( )
return categories
@app.post ( " / account/ category" , tags = [ " bff" , " account " ] , response_model = SaleCategoryResponse )
@app.post ( " / category" , tags = [ " category " ] , response_model = SaleCategoryResponse )
def create_or_update_sale_category (
req : SaleCategoryRequest ,
current_account : Account = Depends ( get_current_account ) ,