|
|
hace 3 meses | |
|---|---|---|
| .. | ||
| FINAL_SUMMARY.md | hace 3 meses | |
| README.md | hace 3 meses | |
| REFACTOR_COMPLETE.md | hace 3 meses | |
| 项目结构.md | hace 3 meses | |
| 项目记录信息.md | hace 3 meses | |
| 项目追加开发说明.md | hace 3 meses | |
LQAdminPlatform 是一个基于 FastAPI 的 OAuth2 单点登录认证中心,提供统一的用户认证、授权管理和样本中心功能。
# 使用 conda
conda create --name lq_oauth2 python=3.12
conda activate lq_oauth2
# 或使用 venv
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
pip install -r requirements/base.txt
# 开发环境额外依赖
pip install -r requirements/dev.txt
复制 .env.example 到 .env 并配置:
# 数据库配置
DATABASE_URL=mysql://user:password@localhost:3306/sso_db
# Redis配置
REDIS_HOST=localhost
REDIS_PORT=6379
# 应用配置
APP_NAME=LQAdminPlatform
HOST=0.0.0.0
PORT=8000
DEBUG=True
# JWT配置
JWT_SECRET_KEY=your-secret-key
ACCESS_TOKEN_EXPIRE_MINUTES=30
python scripts/init_db.py
# 使用新的启动脚本(自动查找可用端口)
python run_server.py
# 或者使用旧的启动方式
python full_server.py
# 使用 uvicorn
uvicorn app.server.app:app --host 0.0.0.0 --port 8000
# 使用 gunicorn(推荐)
gunicorn app.server.app:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
LQAdminPlatform/
├── src/
│ ├── app/
│ │ ├── server/ # 服务器启动模块
│ │ ├── logger/ # 日志配置
│ │ ├── base/ # 基础连接(MySQL、Redis、Milvus)
│ │ ├── core/ # 核心模块(异常等)
│ │ ├── models/ # 数据模型
│ │ ├── schemas/ # 数据结构
│ │ ├── utils/ # 工具类
│ │ ├── config/ # 配置文件
│ │ ├── system/ # 系统管理模块
│ │ ├── oauth/ # 授权管理模块
│ │ └── sample/ # 样本中心模块
│ └── views/ # 视图路由
├── scripts/ # 脚本文件
├── test/ # 测试文件
├── requirements/ # 依赖文件
├── run_server.py # 启动脚本(新)
└── full_server.py # 启动脚本(旧,保留兼容)
详细的项目结构说明请查看 REFACTOR_README.md
cd LQAdminPlatform
python run_server.py
# 访问: http://localhost:8000/docs
cd LQAdminFront
npm install
npm run dev
# 访问: http://localhost:3000
# 默认账号: admin / Admin123456
cd subsystem-demo/backend
python main.py
# 访问: http://localhost:8001/docs
cd subsystem-demo/frontend
npm install
npm run dev
# 访问: http://localhost:3001
在子系统中配置以下环境变量:
CLIENT_ID=eqhoIdAyAWbA8MsYHsNqQqNLJbCayTjY
CLIENT_SECRET=LKJm5XHJFhhgxSv9nQhoQNNI3wrKyWGZCaPQ4qc43Lf5qfXdLAHoGAHhCYqApEpr
SSO_SERVER_URL=http://localhost:8000
GET /api/v1/system/dashboard - 仪表盘GET /api/v1/system/users - 用户列表GET /api/v1/system/roles - 角色列表GET /api/v1/system/menus - 菜单列表GET /api/v1/system/logs - 系统日志GET /api/v1/oauth/authorize - OAuth2 授权POST /api/v1/oauth/token - 获取令牌GET /api/v1/oauth/userinfo - 用户信息POST /api/v1/oauth/revoke - 撤销令牌GET /api/v1/sample/knowledge-bases - 知识库列表GET /api/v1/sample/documents - 文档列表POST /api/v1/sample/documents - 上传文档POST /api/v1/sample/search - 检索文档# 运行所有测试
pytest
# 运行特定测试
pytest test/test_auth.py
# 查看覆盖率
pytest --cov=app
项目使用以下工具保证代码质量:
mypy: 类型检查
# 格式化代码
black src/
# 排序导入
isort src/
# 检查代码
flake8 src/
# 构建镜像
docker build -t lqadmin:latest .
# 运行容器
docker run -d -p 8000:8000 --env-file .env lqadmin:latest
docker-compose up -d
启动脚本会自动查找可用端口(8000-8010),或手动指定:
PORT=8001 python run_server.py
检查 .env 文件中的 DATABASE_URL 配置是否正确。
Redis 为可选组件,连接失败不会影响核心功能,但会影响缓存和会话管理。
详细更新日志请查看 REFACTOR_README.md
欢迎提交 Issue 和 Pull Request!
MIT License
如有问题,请联系开发团队。