Files
DjangoAdmin_Flask_EleVue/重构设计.txt
T
DjangoAdmin DevandClaude 15f2a5e097 chore: 基线提交(重构前代码快照)
- git 初始化 + .gitignore 补全(根 .env / logs / instance / __pycache__ 等)
- 修复 utils/.gitignore 误将整个 utils/ 源码层忽略的问题,补入全部工具源码(含 ip2region.xdb)
- 含后端全部代码:application / extensions / utils / config / migrations
- 含前端 ui/(后续整体迁走)
- 不含根 .env(含密钥,本地保留)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-07 12:12:06 +08:00

366 lines
23 KiB
Plaintext
Raw 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.
DjangoAdmin_Flask_EleVue/
│
├── .env # 环境变量(保持)
├── .env.example # ✨ 新增:环境变量模板
├── .gitignore # 保持
├── .pre-commit-config.yaml # ✨ 新增:代码规范钩子
├── .flake8 # ✨ 新增:PEP8检查配置
├── .editorconfig # ✨ 新增:编辑器统一配置
│
├── pyproject.toml # ✨ 新增:现代化项目管理(替代setup.py)
├── pytest.ini # ✨ 新增:测试配置
├── Makefile # ✨ 新增:常用命令集
│
├── requirements.txt # ✅ 保留(生产依赖)
├── requirements-dev.txt # ✨ 新增:开发依赖(pytest, black, flake8等)
│
├── README.md # 保持(中文)
├── README.en.md # 保持(英文)
├── CHANGELOG.md # ✨ 新增:版本更新日志
├── CONTRIBUTING.md # ✨ 新增:贡献指南
├── LICENSE # 保持
├── USAGE.md # 保持(使用说明)
├── CLAUDE.md # 保持(项目指引)
│
├── Dockerfile # 优化(多阶段构建)
├── docker-compose.yml # 优化(完整服务编排)
├── .dockerignore # ✨ 新增:Docker忽略文件
├── gunicorn.conf.py # 保持(生产WSGI配置)
├── gunicorn_dev.conf.py # ✨ 新增:开发环境WSGI配置
│
├── src/ # 🔥 核心源码目录(原application/)
│ ├── __init__.py
│ ├── app.py # 📦 应用工厂(从application/__init__.py迁移)
│ ├── wsgi.py # ✨ 新增:生产WSGI入口
│ ├── extensions.py # ✨ 新增:扩展统一管理(原extensions/合并)
│ │
│ ├── core/ # 🔥 核心基础设施层
│ │ ├── __init__.py
│ │ ├── database.py # 📦 从extensions/sqlalchemy.py迁移
│ │ ├── redis_client.py # 📦 从extensions/redis.py迁移
│ │ ├── scheduler.py # 📦 从extensions/scheduler.py迁移
│ │ ├── mail.py # 📦 从extensions/mail.py迁移
│ │ ├── jwt.py # 📦 从utils/jwt.py迁移
│ │ ├── password.py # 📦 从utils/password.py迁移
│ │ ├── security.py # 📦 从utils/security.py迁移
│ │ ├── response.py # 📦 从utils/response.py迁移
│ │ ├── exceptions.py # 🔥 自定义异常(整合error_handler.py)
│ │ ├── middleware.py # 🔥 中间件(整合middleware/*.py)
│ │ ├── logger.py # ✨ 新增:结构化日志配置
│ │ └── context.py # ✨ 新增:请求上下文管理
│ │
│ ├── common/ # 🔥 共享层
│ │ ├── __init__.py
│ │ ├── constants/ # 📦 常量(原application/constants/ + constant/)
│ │ │ ├── __init__.py
│ │ │ ├── common.py # 通用常量
│ │ │ ├── dict.py # 字典常量
│ │ │ └── error_code.py # ✨ 错误码定义
│ │ ├── enums.py # ✨ 枚举定义(统一管理)
│ │ ├── pagination.py # ✨ 分页统一封装
│ │ ├── base_model.py # 📦 从application/models/base_model.py迁移
│ │ ├── base_repository.py # ✨ 新增:Repository基类
│ │ ├── base_service.py # ✨ 新增:Service基类
│ │ ├── base_form.py # 📦 从application/forms/base_form.py迁移
│ │ ├── decorators.py # ✨ 新增:统一装饰器
│ │ ├── utils/ # 📦 工具函数(原utils/)
│ │ │ ├── __init__.py
│ │ │ ├── request.py # 请求解析
│ │ │ ├── model_utils.py # 模型工具
│ │ │ ├── case_converter.py # 命名转换
│ │ │ ├── regular.py # 正则/错误提取
│ │ │ ├── captcha.py # 验证码
│ │ │ ├── file.py # 文件操作
│ │ │ ├── rich_text.py # 富文本处理
│ │ │ ├── ip.py # IP查询
│ │ │ ├── user_agent.py # UA解析
│ │ │ ├── formatter.py # 格式化
│ │ │ ├── json.py # JSON工具
│ │ │ ├── dict.py # 字典工具
│ │ │ └── ip2region/ # IP数据库
│ │ │ ├── __init__.py
│ │ │ └── ip2region.xdb
│ │ └── validators.py # ✨ 自定义验证器
│ │
│ ├── modules/ # 🔥 业务模块(按领域划分)
│ │ ├── __init__.py
│ │ │
│ │ ├── auth/ # 🔐 认证授权模块
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/login.py迁移
│ │ │ ├── schema.py # 📦 从forms/login.py迁移(Marshmallow)
│ │ │ ├── service.py # 📦 从services/login.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ ├── models.py # 📦 从models/login_log.py迁移
│ │ │ └── deps.py # ✨ 依赖注入
│ │ │
│ │ ├── system/ # ⚙️ 系统管理模块组
│ │ │ ├── __init__.py
│ │ │ │
│ │ │ ├── user/ # 👤 用户管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/user.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/user.py迁移
│ │ │ │ ├── service.py # 📦 从services/user.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/user.py迁移
│ │ │ │
│ │ │ ├── role/ # 🎭 角色管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/role.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/role.py迁移
│ │ │ │ ├── service.py # 📦 从services/role.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/role.py迁移
│ │ │ │
│ │ │ ├── menu/ # 📋 菜单管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/menu.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/menu.py迁移
│ │ │ │ ├── service.py # 📦 从services/menu.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/menu.py迁移
│ │ │ │
│ │ │ ├── dept/ # 🏢 部门管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/dept.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/dept.py迁移
│ │ │ │ ├── service.py # 📦 从services/dept.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/dept.py迁移
│ │ │ │
│ │ │ ├── position/ # 💼 岗位管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/position.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/position.py迁移
│ │ │ │ ├── service.py # 📦 从services/position.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/position.py迁移
│ │ │ │
│ │ │ ├── level/ # 📊 职级管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/level.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/level.py迁移
│ │ │ │ ├── service.py # 📦 从services/level.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/level.py迁移
│ │ │ │
│ │ │ └── tenant/ # 🏬 租户管理
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/tenant.py迁移
│ │ │ ├── schema.py # 📦 从forms/tenant.py迁移
│ │ │ ├── service.py # 📦 从services/tenant.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/tenant.py迁移
│ │ │
│ │ ├── dictionary/ # 📚 字典管理(合并dict + dict_item)
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/dict.py + dict_item.py迁移
│ │ │ ├── schema.py # 📦 从forms/dict.py + dict_item.py迁移
│ │ │ ├── service.py # 📦 从services/dict.py + dict_item.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/dict.py + dict_item.py迁移
│ │ │
│ │ ├── configuration/ # ⚙️ 配置管理(合并config + config_item)
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/config.py + config_item.py迁移
│ │ │ ├── schema.py # 📦 从forms/config.py + config_item.py迁移
│ │ │ ├── service.py # 📦 从services/config.py + config_item.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/config.py + config_item.py迁移
│ │ │
│ │ ├── cms/ # 📝 内容管理模块组
│ │ │ ├── __init__.py
│ │ │ ├── article/ # 📄 文章管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/article.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/article.py迁移
│ │ │ │ ├── service.py # 📦 从services/article.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/article.py迁移
│ │ │ ├── category/ # 🏷️ 分类管理
│ │ │ │ ├── __init__.py
│ │ │ │ ├── router.py # 📦 从views/category.py迁移
│ │ │ │ ├── schema.py # 📦 从forms/category.py迁移
│ │ │ │ ├── service.py # 📦 从services/category.py迁移
│ │ │ │ ├── repository.py # ✨ 新增
│ │ │ │ └── models.py # 📦 从models/category.py迁移
│ │ │ └── link/ # 🔗 友链管理
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/link.py迁移
│ │ │ ├── schema.py # 📦 从forms/link.py迁移
│ │ │ ├── service.py # 📦 从services/link.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/link.py迁移
│ │ │
│ │ ├── notice/ # 📢 通知公告
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/notice.py迁移
│ │ │ ├── schema.py # 📦 从forms/notice.py迁移
│ │ │ ├── service.py # 📦 从services/notice.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/notice.py迁移
│ │ │
│ │ ├── param/ # 🔧 参数配置
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/param.py迁移
│ │ │ ├── schema.py # 📦 从forms/param.py迁移
│ │ │ ├── service.py # 📦 从services/param.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/param.py迁移
│ │ │
│ │ ├── city/ # 🏙️ 城市管理
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/city.py迁移
│ │ │ ├── schema.py # 📦 从forms/city.py迁移
│ │ │ ├── service.py # 📦 从services/city.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/city.py迁移
│ │ │
│ │ ├── job/ # ⏰ 定时任务
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/job.py迁移
│ │ │ ├── schema.py # 📦 从forms/job.py迁移
│ │ │ ├── service.py # 📦 从services/job.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ ├── models.py # 📦 从models/job.py迁移
│ │ │ └── executor.py # 📦 从services/job_executor.py迁移
│ │ │
│ │ ├── log/ # 📊 日志管理(合并login_log + operation_log)
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/login_log.py + operation_log.py迁移
│ │ │ ├── schema.py # 📦 从forms/login_log.py迁移
│ │ │ ├── service.py # 📦 从services/login_log.py + operation_log.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/login_log.py + operation_log.py迁移
│ │ │
│ │ ├── file_template/ # 📁 文件模板管理
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/file_template.py迁移
│ │ │ ├── schema.py # 📦 从forms/file_template.py迁移
│ │ │ ├── service.py # 📦 从services/file_template.py迁移
│ │ │ ├── repository.py # ✨ 新增
│ │ │ └── models.py # 📦 从models/file_template.py迁移
│ │ │
│ │ ├── upload/ # 📤 文件上传(无数据库)
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/upload.py迁移
│ │ │ ├── schema.py # 📦 从forms/upload.py迁移(如有)
│ │ │ └── service.py # 📦 从services/upload.py迁移
│ │ │
│ │ └── association/ # 🔗 关联关系模块
│ │ ├── __init__.py
│ │ ├── user_role/ # 👤🎭 用户-角色关联
│ │ │ ├── __init__.py
│ │ │ ├── router.py # 📦 从views/user_role.py迁移
│ │ │ ├── service.py # 📦 从services/user_role.py迁移
│ │ │ └── models.py # 📦 从models/user_role.py迁移
│ │ └── role_menu/ # 🎭📋 角色-菜单关联
│ │ ├── __init__.py
│ │ ├── router.py # 📦 从views/role_menu.py迁移
│ │ ├── service.py # 📦 从services/role_menu.py迁移
│ │ └── models.py # 📦 从models/role_menu.py迁移
│ │
│ ├── routes/ # 🔥 路由注册中心
│ │ ├── __init__.py
│ │ └── v1.py # API v1路由注册(所有Blueprint)
│ │
│ └── templates/ # 📄 模板文件
│ ├── base.html
│ └── error/
│ ├── 404.html
│ └── 500.html
│
├── config/ # ⚙️ 配置模块(保持并优化)
│ ├── __init__.py # 保持(加载.env)
│ ├── app.py # 保持
│ ├── auth.py # 保持
│ ├── captcha.py # 保持
│ ├── database.py # 保持
│ ├── redis.py # 保持
│ ├── mail.py # 保持
│ ├── sms.py # 保持
│ └── logging.py # ✨ 新增:日志配置
│
├── migrations/ # 📦 数据库迁移(保持)
│ ├── README
│ ├── alembic.ini
│ ├── env.py
│ ├── script.py.mako
│ └── versions/
│ ├── 72d1886c9903_.py
│ ├── 8291c8683c19_.py
│ └── 9d75730d2484_.py
│
├── tests/ # 🔥 测试目录(全新)
│ ├── __init__.py
│ ├── conftest.py # Pytest fixtures
│ ├── unit/ # 单元测试
│ │ ├── __init__.py
│ │ ├── test_core/
│ │ │ ├── test_jwt.py
│ │ │ ├── test_password.py
│ │ │ └── test_response.py
│ │ ├── test_common/
│ │ │ ├── test_utils.py
│ │ │ └── test_decorators.py
│ │ └── test_modules/
│ │ ├── test_auth.py
│ │ └── test_user.py
│ └── integration/ # 集成测试
│ ├── __init__.py
│ ├── test_api/
│ │ ├── test_auth_api.py
│ │ ├── test_user_api.py
│ │ └── test_role_api.py
│ └── test_database.py
│
├── scripts/ # 🔧 运维脚本
│ ├── __init__.py
│ ├── init_db.py # 数据库初始化
│ ├── seed_data.py # 种子数据
│ ├── migrate_structure.py # ✨ 新增:结构迁移脚本
│ ├── backup_db.py # ✨ 新增:数据库备份
│ └── health_check.py # ✨ 新增:健康检查
│
├── static/ # 🎨 静态资源(保持)
│ ├── favicon.ico
│ └── fonts/
│ └── Vera.ttf
│
├── uploads/ # 📁 上传目录(保持)
│ ├── article/
│ │ └── 20260418/
│ ├── file_template/
│ │ ├── 20260418/
│ │ └── 20260506/
│ ├── temp/
│ │ ├── 20260418/
│ │ └── 20260506/
│ └── level.xlsx
│
├── logs/ # 📋 日志目录(新增)
│ ├── .gitkeep
│ ├── app.log
│ └── error.log
│
├── instance/ # 🔒 实例配置(新增,Git忽略)
│ ├── .gitkeep
│ └── config.py # 本地私有配置
│
├── docker/ # 🐳 容器化(保持并优化)
│ ├── Dockerfile # 优化(多阶段构建)
│ ├── docker-compose.yml # 优化(完整服务)
│ ├── nginx/ # ✨ 新增:Nginx配置
│ │ ├── Dockerfile
│ │ └── nginx.conf
│ └── entrypoint.sh # ✨ 新增:容器启动脚本
│
└── document/ # 📚 文档(保持)
├── .gitignore
├── djangoadmin.flask.elevue.sql # 数据库初始化SQL
├── 开发笔记.txt
├── 版本更新说明.txt
├── 版权声明.png
└── api/ # ✨ 新增:API文档
└── postman_collection.json