- 后端分层架构: api(Controller)/services(业务)/repositories(数据)/models(ORM)
- 订单模块: 创建(契约对齐目标站{contract_id,drawing_data,pic_url})、搜索、
详情、更新、删除、状态机(意向单→正式单→生产中→完工/取消,非法迁移拒绝)、
7节点生产进度、审计日志
- 认证模块: JWT签发(HS256/24h)、PBKDF2密码、注册登录
- 样板库API: 分类树/模板搜索/模板详情, drawing_data 与采集样本同构
- 254张样板二维平面图全部采集并静态挂载 /static/windoor-images/
- 种子脚本: 管理员+分类树+254套样板入库
- 统一响应envelope与付费墙(code=10086)/权限(code=210)语义
- 端到端冒烟测试7/7通过, 更新API.md §12自研接口规范
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""下载 254 套样板的二维平面图(pic_url,公开 OSS)。限速 0.2s。"""
|
|
import json, os, time, urllib.request, urllib.error
|
|
|
|
templates = json.load(open(r"D:\Code\huamenchuang\data\api-samples\windoor-templates-clean.json", encoding="utf-8"))
|
|
OUT = r"D:\Code\huamenchuang\data\windoor-images"
|
|
os.makedirs(OUT, exist_ok=True)
|
|
ok, skip, fail = 0, 0, []
|
|
for i, t in enumerate(templates):
|
|
ext = ".png"
|
|
url = t["pic_url"]
|
|
if url.lower().endswith((".jpg", ".jpeg")):
|
|
ext = ".jpg"
|
|
out = os.path.join(OUT, f"{t['id']}{ext}")
|
|
if os.path.exists(out) and os.path.getsize(out) > 100:
|
|
skip += 1
|
|
continue
|
|
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=20) as r:
|
|
data = r.read()
|
|
open(out, "wb").write(data)
|
|
ok += 1
|
|
except Exception as e:
|
|
fail.append((t["id"], str(e)[:60]))
|
|
if (i + 1) % 50 == 0:
|
|
print(f"进度 {i+1}/{len(templates)} 成功{ok} 跳过{skip}", flush=True)
|
|
time.sleep(0.2)
|
|
print(f"完成: 新下载 {ok}, 已存在 {skip}, 失败 {len(fail)}")
|
|
if fail:
|
|
print(fail[:10])
|