feat: add schedule items CRUD API

- Add ScheduleItem Pydantic schemas with metadata support
- Add repository layer with CRUD operations
- Add service layer with authorization
- Add FastAPI router with all endpoints
- Add unit and integration tests
- Update API documentation
This commit is contained in:
qzl
2026-02-28 11:03:29 +08:00
parent dbd3f68dd4
commit 50b38de488
12 changed files with 1114 additions and 0 deletions
+114
View File
@@ -244,6 +244,120 @@
---
## Schedule Items
### POST /schedule-items
创建日历事项(需要认证)。
**Request:**
```json
{
"title": "string (1-255 chars, required)",
"description": "string? (max 2000 chars)",
"start_at": "string (ISO 8601 datetime, required)",
"end_at": "string? (ISO 8601 datetime)",
"timezone": "string? (default: UTC)",
"metadata": {
"color": "#FF6B6B",
"location": "会议室A",
"notes": "记得带身份证",
"attachments": [],
"version": 1
}
}
```
**Response:** 201 Created
```json
{
"id": "uuid",
"title": "string",
"description": "string?",
"start_at": "string",
"end_at": "string?",
"timezone": "string",
"metadata": {},
"status": "active",
"source_type": "manual",
"created_at": "string",
"updated_at": "string"
}
```
**Errors:**
- 400: end_at 早于 start_at
- 401: 未认证
- 503: 服务不可用
---
### GET /schedule-items
按时间范围查询日历事项列表(需要认证)。
**Query Parameters:**
- `start_at`: ISO 8601 date/datetime(查询范围起始)
- `end_at`: ISO 8601 date/datetime(查询范围结束)
**Response:** 200 OK
```json
[
{
"id": "uuid",
"title": "string",
"start_at": "string",
"end_at": "string?",
"timezone": "string",
"status": "active"
}
]
```
**Errors:**
- 400: end_at 早于 start_at
- 401: 未认证
---
### GET /schedule-items/{id}
获取单个日历事项详情(需要认证)。
**Response:** 200 OK
**Errors:**
- 401: 未认证
- 404: 事项不存在
---
### PATCH /schedule-items/{id}
更新日历事项(需要认证)。
**Request:** 支持 `title`/`description`/`start_at`/`end_at`/`timezone`/`metadata`/`status` 部分更新
**Response:** 200 OK
**Errors:**
- 401: 未认证
- 404: 事项不存在
---
### DELETE /schedule-items/{id}
删除日历事项(软删除,需要认证)。
**Response:** 204 No Content
**Errors:**
- 401: 未认证
- 404: 事项不存在
---
## Users
### GET /users/me