From 192c0d214162b36a4d52179dd81735b9bc250e6f Mon Sep 17 00:00:00 2001 From: liujianjiang Date: Wed, 3 Dec 2025 14:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 13 +++++-------- model/model.py | 5 +++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index b8fe5e1..0a148b3 100644 --- a/main.py +++ b/main.py @@ -8,7 +8,7 @@ from typing import Dict, Any, Optional, List from fastapi import FastAPI, HTTPException, Depends, Header from public_function.auth import verify_tk_token from public_function.public_func import read_config, create_logger -from model.model import GoodsInfo, DataReceive, AccountStatus, AccountUpdate, TokenItem, CrawlerItem, ResetTask +from model.model import GoodsInfo, DataReceive, AccountStatus, AccountUpdate, TokenItem, CrawlerItem, ResetTask, AccountObtain app = FastAPI() app.middleware("http")(verify_tk_token) @@ -61,19 +61,16 @@ def get_reset_manager(): # 账号处理相关 -@app.get("/obtain_account", summary="获取可用账号") -async def obtain_account(app_name: str, region: str, account_manager: Any = Depends(get_account_manager)): +@app.post("/obtain_account", summary="获取可用账号") +async def obtain_account(account_data: AccountObtain, account_manager: Any = Depends(get_account_manager)): """ 获取指定应用的可用账号 - **app_name**: 应用名称 pad_code """ - if not app_name or not app_name.strip(): - raise HTTPException(status_code=400, detail="应用名称不能为空") - if not region or not region.strip(): - raise HTTPException(status_code=400, detail="国家不能为空会") try: - result = await account_manager.obtain_account_info(app_name, region) + param = account_data.model_dump() + result = await account_manager.obtain_account_info(param["app_name"], param["region"]) if result: # 将账号和设备进行记录 set_param = {"status": 2} diff --git a/model/model.py b/model/model.py index 9c91f06..8ebb41b 100644 --- a/model/model.py +++ b/model/model.py @@ -9,6 +9,11 @@ class AccountStatus(BaseModel): app_name: str = Field(..., description="应用名称") +class AccountObtain(BaseModel): + app_name: str = Field(..., description="应用名称") + region: str = Field(..., description="地区") + + class AccountUpdate(BaseModel): account_id: str = Field(..., description="账号ID") app_name: str = Field(..., description="应用名称")