Files
shutiaozhao127-boop cfdeeb5e41 chore: 初始化项目结构并添加基础配置文件
添加后端API和前端项目的初始目录结构,包括应用层模块、工具模块和模型定义
配置前后端的.dockerignore文件以排除开发环境文件
添加前端样式文件,包括字体、Tailwind CSS和主题配置
初始化Python虚拟环境中的类型标记文件
2026-04-01 16:55:24 +08:00

48 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
清理旧的共享 demo_web_user 及其关联数据。
部署新版 demo 登录逻辑后运行一次即可:
python -m scripts.cleanup_demo_users
"""
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient
from beanie import init_beanie
from app.config import Settings
from app.models.user import User
from app.models.report import Report
from app.models.analysis import Analysis
from app.models.chat import ChatSession
from app.models.checkup import CheckupPlan
async def main():
settings = Settings()
client = AsyncIOMotorClient(settings.mongodb_url)
db = client[settings.database_name]
await init_beanie(database=db, document_models=[User, Report, Analysis, ChatSession, CheckupPlan])
user = await User.find_one(User.openid == "demo_web_user")
if not user:
print("未找到 demo_web_user,无需清理。")
return
uid = user.id
r = await Report.find(Report.user_id == uid).delete()
a = await Analysis.find(Analysis.user_id == uid).delete()
c = await ChatSession.find(ChatSession.user_id == uid).delete()
p = await CheckupPlan.find(CheckupPlan.user_id == uid).delete()
await user.delete()
print(f"已清理 demo_web_user (id={uid}):")
print(f" Reports: {r.deleted_count if r else 0}")
print(f" Analyses: {a.deleted_count if a else 0}")
print(f" ChatSessions: {c.deleted_count if c else 0}")
print(f" CheckupPlans: {p.deleted_count if p else 0}")
if __name__ == "__main__":
asyncio.run(main())