From bab15debe4beef0f6250cc66b776fe76fbf944d6 Mon Sep 17 00:00:00 2001 From: Redsandyg Date: Sat, 7 Jun 2025 13:32:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=82=D0=B5=D0=B3=D0=B8=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=8D=D0=BD=D0=B4=D0=BF=D0=BE=D0=B8=D0=BD=D1=82=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B2=20main.py,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=B3=D0=BE=D1=80=D0=B8=D0=B8=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BE=D1=80=D0=B3=D0=B0=D0=BD=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20API:=20"token",=20"dashboard",=20"stat",=20"billing"?= =?UTF-8?q?=20=D0=B8=20"account".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/main.py b/main.py index 145acf3..fac30a3 100644 --- a/main.py +++ b/main.py @@ -255,7 +255,7 @@ def create_access_token(data: dict, expires_delta: timedelta = None): encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM) return encoded_jwt -@app.post("/token", response_model=Token, tags=["bff"]) +@app.post("/token", response_model=Token, tags=["bff", "token"]) def login_account_for_access_token( # login: str = Body(...), # password: str = Body(...), @@ -330,7 +330,7 @@ def get_stat(current_tg_agent: TgAgent = Depends(get_current_tg_agent), db: Sess "availableWithdrawal": availableWithdrawal } -@app.get("/dashboard/cards", tags=["bff"]) +@app.get("/dashboard/cards", tags=["bff", "dashboard"]) def get_dashboard_cards(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # 1. Общий доход - сумма всех Sale.cost total_revenue = db.exec(select(Sale).where(Sale.company_id == current_account.company_id)).all() @@ -358,7 +358,7 @@ def get_dashboard_cards(current_account: Account = Depends(get_current_account), "totalSales": totalSales } -@app.get("/dashboard/chart/total", tags=["bff"]) +@app.get("/dashboard/chart/total", tags=["bff", "dashboard"]) def get_dashboard_chart_total(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # Группируем продажи по дате (день) result = db.exec( @@ -376,7 +376,7 @@ def get_dashboard_chart_total(current_account: Account = Depends(get_current_acc ] return JSONResponse(content=data) -@app.get("/dashboard/chart/agent", tags=["bff"]) +@app.get("/dashboard/chart/agent", tags=["bff", "dashboard"]) def get_dashboard_chart_agent(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # Получаем всех агентов agents = db.exec(select(TgAgent).where(TgAgent.company_id == current_account.company_id)).all() @@ -403,7 +403,7 @@ def get_dashboard_chart_agent(current_account: Account = Depends(get_current_acc }) return JSONResponse(content=result) -@app.get("/stat/agents", tags=["bff"]) +@app.get("/stat/agents", tags=["bff", "stat"]) def get_agents_stat( db: Session = Depends(get_db), date_start: str = Query(None), @@ -443,7 +443,7 @@ def get_agents_stat( }) return JSONResponse(content=result) -@app.get("/stat/referrals", tags=["bff"]) +@app.get("/stat/referrals", tags=["bff", "stat"]) def get_referrals_stat( db: Session = Depends(get_db), date_start: str = Query(None), @@ -471,7 +471,7 @@ def get_referrals_stat( }) return JSONResponse(content=result) -@app.get("/stat/sales", tags=["bff"]) +@app.get("/stat/sales", tags=["bff", "stat"]) def get_sales_stat( db: Session = Depends(get_db), date_start: str = Query(None), @@ -503,7 +503,7 @@ def get_sales_stat( }) return JSONResponse(content=result) -@app.get("/billing/cards", tags=["bff"]) +@app.get("/billing/cards", tags=["bff", "billing"]) def get_billing_cards(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # 1. cost - Общий заработок (сумма всех Sale.cost) sales = db.exec(select(Sale).where(Sale.company_id == current_account.company_id)).all() @@ -523,7 +523,7 @@ def get_billing_cards(current_account: Account = Depends(get_current_account), d "pendingPayouts": pendingPayouts } -@app.get("/billing/payouts/transactions", tags=["bff"]) +@app.get("/billing/payouts/transactions", tags=["bff", "billing"]) def get_billing_payouts_transactions( db: Session = Depends(get_db), date_start: str = Query(None), @@ -554,7 +554,7 @@ def get_billing_payouts_transactions( }) return result -@app.get("/billing/chart/stat", tags=["bff"]) +@app.get("/billing/chart/stat", tags=["bff", "billing"]) def get_billing_chart_stat(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # Группируем агентские транзакции по дате (день) и статусу result = db.exec( @@ -576,7 +576,7 @@ def get_billing_chart_stat(current_account: Account = Depends(get_current_accoun ] return JSONResponse(content=data) -@app.get("/billing/chart/pie", tags=["bff"]) +@app.get("/billing/chart/pie", tags=["bff", "billing"]) def get_billing_chart_pie(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): # Группируем агентские транзакции по статусу result = db.exec( @@ -612,14 +612,14 @@ def get_account_by_login(db: Session, login: str) -> Optional[Account]: -@app.get("/account", tags=["bff"]) +@app.get("/account", tags=["bff", "account"]) def get_account(current_account: Account = Depends(get_current_account)): return { "firstName": current_account.firstName, "surname": current_account.surname } -@app.get("/account/profile", tags=["bff"]) +@app.get("/account/profile", tags=["bff", "account"]) def get_account_profile(current_account: Account = Depends(get_current_account), db: Session = Depends(get_db)): company = db.exec(select(Company).where(Company.id == current_account.company_id)).first() if not company: @@ -637,7 +637,7 @@ def get_account_profile(current_account: Account = Depends(get_current_account), } } -@app.post("/account/profile", tags=["bff"]) +@app.post("/account/profile", tags=["bff", "account"]) def update_account_profile( req: AccountProfileUpdateRequest, current_account: Account = Depends(get_current_account), @@ -656,7 +656,7 @@ def update_account_profile( db.refresh(current_account) return {"msg": "Профиль обновлён успешно"} -@app.post("/account/password", tags=["bff"]) +@app.post("/account/password", tags=["bff", "account"]) def change_account_password( req: AccountPasswordChangeRequest, current_account: Account = Depends(get_current_account), @@ -679,7 +679,7 @@ def change_account_password( # --- Новый функционал для агентских транзакций партнера --- -@app.get("/account/agent-transaction", response_model=List[AgentTransactionResponse], tags=["bff"]) +@app.get("/account/agent-transaction", response_model=List[AgentTransactionResponse], tags=["bff", "account"]) def get_account_agent_transactions( statuses: Optional[List[TransactionStatus]] = Query(None), # Изменено на List[TransactionStatus] date_start: str = Query(None), # Добавлен параметр date_start @@ -733,7 +733,7 @@ class AutoApproveSettingsRequest(BaseModel): auto_approve: bool apply_to_current: Optional[bool] = False -@app.get("/account/auto-approve", tags=["bff"]) +@app.get("/account/auto-approve", tags=["bff", "account"]) def get_auto_approve_settings( current_account: Account = Depends(get_current_account), db: Session = Depends(get_db) @@ -746,7 +746,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"]) +@app.post("/account/auto-approve", tags=["bff", "account"]) def update_auto_approve_settings( req: AutoApproveSettingsRequest, current_account: Account = Depends(get_current_account), @@ -798,7 +798,7 @@ def update_auto_approve_settings( class ApproveTransactionsRequest(BaseModel): transaction_ids: List[uuid.UUID] -@app.post("/account/approve-transactions", tags=["bff"]) +@app.post("/account/approve-transactions", tags=["bff", "account"]) def approve_agent_transactions( req: ApproveTransactionsRequest, current_account: Account = Depends(get_current_account),