feat: v0.9 样板数据完整性验证/解析加固/报表统计
- 双源确认样板库完整性: search接口与画图编辑器for_ht目录均为254条, 0遗漏 - 全量体检: 6套样板含7个畸形段(缺ps/pe)导致解析报错 前后端重放/算料统一加固过滤, 254样板0异常/1046窗格 - 报表统计模块(/chart): 近N天订单数金额按日柱图+8项总量+状态分布 - 样板库官方/我的样板双Tab(is_default过滤) - 使用指南接入帮助文章接口(种子8篇), seed分类树幂等修复 - 全接口回归18/18通过
This commit is contained in:
@@ -27,9 +27,9 @@ async def seed() -> None:
|
||||
# 2) 分类树(来自 default_windoor_catelog.json,取目标站原始 id 便于对照)
|
||||
cat_file = DATA / "api-samples" / "default_windoor_catelog.json"
|
||||
if cat_file.exists():
|
||||
from sqlalchemy import select as _sel
|
||||
cats = json.load(open(cat_file, encoding="utf-8"))["data"]
|
||||
existing = {c.id for c in (await db.execute(
|
||||
__import__("sqlalchemy").select(WindoorCatelog.id))).scalars()}
|
||||
existing = set((await db.execute(_sel(WindoorCatelog.id))).scalars())
|
||||
for top in cats:
|
||||
if top["id"] not in existing:
|
||||
db.add(WindoorCatelog(id=top["id"], name=top["name"], fid=0, company_id=1))
|
||||
@@ -71,6 +71,17 @@ async def seed() -> None:
|
||||
await db.commit()
|
||||
print("种子数据完成")
|
||||
|
||||
# 4) 帮助文章(幂等:按标题去重)
|
||||
async with SessionLocal() as db:
|
||||
from huamenchuang.models.extend import Article
|
||||
from huamenchuang.scripts.article_seed_data import ARTICLES
|
||||
existing = {t for (t,) in (await db.execute(select(Article.title))).all()}
|
||||
for i, (cat, title, content) in enumerate(ARTICLES):
|
||||
if title not in existing:
|
||||
db.add(Article(title=title, category=cat, content=content, sort=i))
|
||||
await db.commit()
|
||||
print("帮助文章就绪")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(seed())
|
||||
|
||||
Reference in New Issue
Block a user