feat: 新增账号状态管理、头像功能与报表工具,完善账号系统
新增账号状态字段与停用校验,支持账号头像上传管理,新增物料收发汇总表合并工具,优化银行卡检查脚本,新增ERP登录复用模块,重构账号数据库迁移与管理接口
This commit is contained in:
@@ -19,6 +19,13 @@ from controlplane.core.pkgutil import _load_manifest
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
def _account_disabled(acct: str) -> bool:
|
||||
"""账号是否已停用(停用后机器侧一律不给插件/授权)。"""
|
||||
with _db() as conn:
|
||||
row = conn.execute("SELECT status FROM accounts WHERE account = ?", (acct,)).fetchone()
|
||||
return bool(row) and not bool(row["status"])
|
||||
|
||||
|
||||
@router.get("/api/plugins", response_model=dict)
|
||||
def plugins(account: str = Query(default="", description="账号(旧底座按此传)"),
|
||||
x_api_token: str = Header(default="", alias="X-API-Token"),
|
||||
@@ -34,6 +41,8 @@ def plugins(account: str = Query(default="", description="账号(旧底座按此
|
||||
acct = (account or "").strip()
|
||||
if not acct:
|
||||
raise HTTPException(400, "缺少有效会话或 account")
|
||||
if _account_disabled(acct):
|
||||
return {"account": acct, "plugins": []}
|
||||
with _db() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
@@ -59,6 +68,8 @@ def platforms_allowed(account: str = Query(default="", description="账号(旧
|
||||
acct = (account or "").strip()
|
||||
if not acct:
|
||||
raise HTTPException(400, "缺少有效会话或 account")
|
||||
if _account_disabled(acct):
|
||||
return {"account": acct, "allowed": []}
|
||||
with _db() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT platform_id FROM account_platforms WHERE account = ? ORDER BY platform_id",
|
||||
@@ -130,6 +141,8 @@ def me_license(account: str = Query(...), device: str = Query(default=""),
|
||||
_check_token(x_api_token)
|
||||
if not account.strip():
|
||||
raise HTTPException(400, "account 不能为空")
|
||||
if _account_disabled(account.strip()):
|
||||
raise HTTPException(403, "账号已停用,无法获取授权")
|
||||
with _db() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user