92 lines
3.0 KiB
Python
92 lines
3.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys
|
|
import requests
|
|
import json
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
TOKEN = "afxp_fa4137GfIzJtlOCeQHjpCXc83SFWmeAOrZnq"
|
|
PROJECT_ID = "6037107"
|
|
BASE_URL = "https://api.apifox.com/api/v1"
|
|
STORE_FOLDER_ID = "78015216" # 门店端-新版
|
|
|
|
headers = {
|
|
"X-Apifox-Api-Version": "2024-03-28",
|
|
"Authorization": f"Bearer {TOKEN}",
|
|
"Content-Type": "application/json; charset=utf-8"
|
|
}
|
|
|
|
def get_folder_tree():
|
|
"""获取项目目录树"""
|
|
try:
|
|
response = requests.get(
|
|
f"{BASE_URL}/projects/{PROJECT_ID}/api-tree-list",
|
|
headers=headers,
|
|
timeout=30
|
|
)
|
|
if response.status_code == 200:
|
|
result = response.json()
|
|
if result.get('success'):
|
|
return result.get('data', [])
|
|
return []
|
|
except Exception as e:
|
|
print(f"获取目录树失败: {e}")
|
|
return []
|
|
|
|
def print_tree(tree, indent=0):
|
|
"""打印目录树"""
|
|
for item in tree:
|
|
if item.get('type') == 'folder':
|
|
print(" " * indent + f"📁 {item.get('name')} (ID: {item.get('id')})")
|
|
children = item.get('children', [])
|
|
if children:
|
|
print_tree(children, indent + 1)
|
|
elif item.get('type') == 'httpApi':
|
|
print(" " * indent + f" 📄 {item.get('name')} (ID: {item.get('id')})")
|
|
|
|
print("=" * 60)
|
|
print("检查目录结构...")
|
|
print("=" * 60)
|
|
|
|
tree = get_folder_tree()
|
|
if tree:
|
|
print("\n当前目录结构:")
|
|
print_tree(tree)
|
|
|
|
# 查找门店端-新版目录
|
|
print("\n查找'门店端-新版'目录及其子目录...")
|
|
def find_store_folder(items, parent_name=""):
|
|
for item in items:
|
|
if item.get('type') == 'folder':
|
|
name = item.get('name', '')
|
|
item_id = item.get('id')
|
|
full_path = f"{parent_name}/{name}" if parent_name else name
|
|
|
|
if '门店端-新版' in full_path or 'store' in name.lower():
|
|
print(f"\n找到目录: {full_path} (ID: {item_id})")
|
|
children = item.get('children', [])
|
|
if children:
|
|
print(" 子目录:")
|
|
for child in children:
|
|
if child.get('type') == 'folder':
|
|
print(f" - {child.get('name')} (ID: {child.get('id')})")
|
|
|
|
# 递归查找
|
|
children = item.get('children', [])
|
|
if children:
|
|
find_store_folder(children, full_path)
|
|
|
|
find_store_folder(tree)
|
|
else:
|
|
print("❌ 无法获取目录树")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("⚠️ Apifox API可能不支持直接创建目录")
|
|
print("请手动在Apifox Web界面创建目录:")
|
|
print(" 1. 打开: https://app.apifox.com/project/6037107")
|
|
print(" 2. 找到'门店端-新版'目录")
|
|
print(" 3. 右键 → 新建文件夹 → 命名为'流量采购管理'")
|
|
print(" 4. 将7个流量采购接口拖拽到该目录")
|
|
print("=" * 60)
|
|
|