feat: 初始化考培练系统项目
- 从服务器拉取完整代码 - 按框架规范整理项目结构 - 配置 Drone CI 测试环境部署 - 包含后端(FastAPI)、前端(Vue3)、管理端 技术栈: Vue3 + TypeScript + FastAPI + MySQL
This commit is contained in:
122
docs/规划/后端开发拆分策略/子agent/02-Agent-User/api_contract.yaml
Normal file
122
docs/规划/后端开发拆分策略/子agent/02-Agent-User/api_contract.yaml
Normal file
@@ -0,0 +1,122 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: 用户管理模块API
|
||||
version: 1.0.0
|
||||
description: 用户与团队管理的最小契约(骨架)
|
||||
|
||||
paths:
|
||||
/api/v1/users/me:
|
||||
get:
|
||||
summary: 获取当前用户信息
|
||||
tags: [用户]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
responses:
|
||||
200:
|
||||
description: 成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ResponseUser'
|
||||
401:
|
||||
description: 未授权
|
||||
|
||||
/api/v1/users:
|
||||
get:
|
||||
summary: 用户列表
|
||||
tags: [用户]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
parameters:
|
||||
- in: query
|
||||
name: page
|
||||
schema: { type: integer, minimum: 1, default: 1 }
|
||||
- in: query
|
||||
name: size
|
||||
schema: { type: integer, minimum: 1, maximum: 100, default: 10 }
|
||||
- in: query
|
||||
name: role
|
||||
schema: { type: string }
|
||||
- in: query
|
||||
name: is_active
|
||||
schema: { type: boolean }
|
||||
responses:
|
||||
200:
|
||||
description: 成功
|
||||
403:
|
||||
description: 权限不足
|
||||
|
||||
post:
|
||||
summary: 创建用户(管理员)
|
||||
tags: [用户]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UserCreate'
|
||||
responses:
|
||||
201:
|
||||
description: 已创建
|
||||
409:
|
||||
description: 用户名或邮箱冲突
|
||||
|
||||
/api/v1/users/{id}:
|
||||
get:
|
||||
summary: 获取指定用户
|
||||
tags: [用户]
|
||||
security:
|
||||
- bearerAuth: []
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
required: true
|
||||
schema: { type: integer }
|
||||
responses:
|
||||
200:
|
||||
description: 成功
|
||||
404:
|
||||
description: 未找到
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
|
||||
schemas:
|
||||
ResponseUser:
|
||||
type: object
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
example: 200
|
||||
message:
|
||||
type: string
|
||||
example: success
|
||||
data:
|
||||
$ref: '#/components/schemas/User'
|
||||
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
id: { type: integer }
|
||||
username: { type: string }
|
||||
email: { type: string }
|
||||
role: { type: string }
|
||||
is_active: { type: boolean }
|
||||
|
||||
UserCreate:
|
||||
type: object
|
||||
required: [username, email, password]
|
||||
properties:
|
||||
username: { type: string, minLength: 3, maxLength: 20 }
|
||||
email: { type: string, format: email }
|
||||
password: { type: string, minLength: 8 }
|
||||
role:
|
||||
type: string
|
||||
enum: [trainee, manager, admin]
|
||||
|
||||
21
docs/规划/后端开发拆分策略/子agent/02-Agent-User/checklist.md
Normal file
21
docs/规划/后端开发拆分策略/子agent/02-Agent-User/checklist.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Agent-User 开发检查清单(简版)
|
||||
|
||||
## 准备
|
||||
- [ ] 阅读 `00-通用基础/base_prompt.md`、`essential_docs.md`
|
||||
- [ ] 通读 `模块分工指南.md` 与 `协作机制设计.md`
|
||||
|
||||
## 最小功能
|
||||
- [ ] `GET /api/v1/users/me` 返回当前用户
|
||||
- [ ] `GET /api/v1/users` 支持分页与筛选(role、is_active)
|
||||
- [ ] `POST /api/v1/users` 管理员创建用户(校验唯一性、加密密码)
|
||||
- [ ] `GET /api/v1/users/{id}` 获取用户详情
|
||||
|
||||
## 安全与规范
|
||||
- [ ] 认证与权限检查(`get_current_user`、`require_admin`)
|
||||
- [ ] 参数验证与统一异常
|
||||
- [ ] 结构化日志覆盖关键操作
|
||||
|
||||
## 质量
|
||||
- [ ] 单元测试覆盖率 ≥ 80%
|
||||
- [ ] 通过格式化/静态检查(Black/isort/flake8/mypy)
|
||||
- [ ] API 与 `api_contract.yaml` 一致
|
||||
29
docs/规划/后端开发拆分策略/子agent/02-Agent-User/context.md
Normal file
29
docs/规划/后端开发拆分策略/子agent/02-Agent-User/context.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Agent-User 上下文(极简版)
|
||||
|
||||
## 位置
|
||||
- 项目根:`/Users/nongjun/Desktop/Ai公司/本地开发与测试/kaopeilian-backend/`
|
||||
- 工作目录:`app/api/v1/`、`app/services/`、`app/models/`、`app/schemas/`
|
||||
|
||||
## 依赖
|
||||
- 输入依赖:Auth 认证与角色检查(`get_current_user`、`require_admin`)、数据库与Redis
|
||||
- 输出接口:用户与团队查询/维护 API 与服务方法,供 Course/Exam/Training/Analytics 使用
|
||||
|
||||
## 关键约束
|
||||
- 安全:认证必需;普通用户仅能操作自身;管理员可管理全量
|
||||
- 性能:用户列表分页查询 ≤ 200ms(本地);常用筛选字段建索引
|
||||
- 观测:登录、变更、角色调整等关键动作记录结构化日志
|
||||
|
||||
## 最小运行信息
|
||||
- 环境变量:复用通用 `.env`,无新增必需项
|
||||
- 测试账号:与 Auth 模块一致(superadmin/admin/testuser)
|
||||
- 关联模型/表:`users`、`teams`、`user_teams`
|
||||
|
||||
## 开发完成状态
|
||||
- ✅ 用户管理模块已完成
|
||||
- ✅ 数据模型:User、Team、UserTeam
|
||||
- ✅ 服务层:UserService(CRUD、认证、团队管理)
|
||||
- ✅ Auth模块:登录、令牌刷新、登出
|
||||
- ✅ API路由:用户和认证相关端点
|
||||
- ✅ 数据库表结构已创建
|
||||
- ⚠️ SQLAlchemy 2.0兼容性问题需要注意
|
||||
|
||||
17
docs/规划/后端开发拆分策略/子agent/02-Agent-User/examples/README.md
Normal file
17
docs/规划/后端开发拆分策略/子agent/02-Agent-User/examples/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Agent-User 示例(最小)
|
||||
|
||||
- users.me:返回当前登录用户信息。
|
||||
|
||||
```python
|
||||
# app/api/v1/users.py 片段(示例)
|
||||
from fastapi import APIRouter, Depends
|
||||
from app.api.deps import get_current_user
|
||||
from app.schemas.base import ResponseModel
|
||||
from app.models.user import User
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/me", response_model=ResponseModel)
|
||||
async def get_current_user_info(current_user: User = Depends(get_current_user)):
|
||||
return ResponseModel(code=200, message="success", data=current_user)
|
||||
```
|
||||
22
docs/规划/后端开发拆分策略/子agent/02-Agent-User/prompt.md
Normal file
22
docs/规划/后端开发拆分策略/子agent/02-Agent-User/prompt.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Agent-User 提示词(极简版)
|
||||
|
||||
## 必读引用
|
||||
@子agent/00-通用基础/base_prompt.md
|
||||
@子agent/00-通用基础/essential_docs.md
|
||||
@考培练系统规划/后端开发拆分策略/模块分工指南.md
|
||||
@考培练系统规划/后端开发拆分策略/协作机制设计.md
|
||||
|
||||
## 你的角色
|
||||
- 本模块职责:用户与团队管理(用户 CRUD、个人资料、角色与团队管理、列表筛选)
|
||||
- 依赖模块:Auth(认证与权限)
|
||||
- 对外输出:用户查询服务、团队查询服务、管理端用户维护 API
|
||||
|
||||
## 交付内容
|
||||
- 代码:`app/api/v1/users.py`、`app/services/user_service.py`、相关 `app/models/`、`app/schemas/`
|
||||
- 契约:本目录 `api_contract.yaml`(OpenAPI 3.0)
|
||||
- 文档与测试:`checklist.md` 全通过,单元测试覆盖率 ≥ 80%
|
||||
|
||||
## 验收标准(最小集)
|
||||
- API 与 `api_contract.yaml` 一致并通过基本集成测试
|
||||
- 认证/权限依赖正常(`get_current_user`、`require_admin`)
|
||||
- 输入校验、统一异常、结构化日志符合通用规范
|
||||
Reference in New Issue
Block a user