Обновлены теги для эндпоинтов в main.py, добавлены новые категории для улучшения организации API: "token", "dashboard", "stat", "billing" и "account".
This commit is contained in:
parent
6b8b4ac059
commit
bab15debe4
38
main.py
38
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),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user