代码优化
This commit is contained in:
parent
b005d3a903
commit
192c0d2141
13
main.py
13
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}
|
||||
|
|
|
|||
|
|
@ -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="应用名称")
|
||||
|
|
|
|||
Loading…
Reference in New Issue