feat: 添加日历事件订阅者功能及权限重构
This commit is contained in:
@@ -116,11 +116,31 @@ Base URL: `/api/v1/schedule-items`
|
||||
"source_type": "ScheduleItemSourceType",
|
||||
"created_at": "datetime",
|
||||
"updated_at": "datetime",
|
||||
"permission": "int (位掩码: 1=view, 2=invite, 4=edit)",
|
||||
"is_owner": "boolean"
|
||||
"permission": "int (位掩码: 1=view, 2=invite, 4=edit, 8=delete, 15=owner)",
|
||||
"is_owner": "boolean (当前用户是否为日程所有者)",
|
||||
"subscribers": ["SubscriberInfo"]
|
||||
}
|
||||
```
|
||||
|
||||
### SubscriberInfo
|
||||
|
||||
```json
|
||||
{
|
||||
"user_id": "uuid",
|
||||
"username": "string | null",
|
||||
"avatar_url": "string | null",
|
||||
"phone": "string | null",
|
||||
"permission": "int (位掩码: 1=view, 2=invite, 4=edit, 8=delete, 15=owner)",
|
||||
"status": "string (active | pending | unsubscribed)",
|
||||
"subscribed_at": "datetime"
|
||||
}
|
||||
```
|
||||
|
||||
说明:
|
||||
- `subscribers` 列表仅包含状态为 `active` 的订阅者
|
||||
- `phone` 字段来自 Supabase Auth,用于显示订阅者手机号
|
||||
- 前端显示优先级:`phone ?? username ?? userId`
|
||||
|
||||
### ScheduleItemShareRequest
|
||||
|
||||
```json
|
||||
@@ -136,6 +156,8 @@ Base URL: `/api/v1/schedule-items`
|
||||
- `permission_view = 1`
|
||||
- `permission_invite = 2`
|
||||
- `permission_edit = 4`
|
||||
- `permission_delete = 8`
|
||||
- `permission_owner = 15`
|
||||
|
||||
### ScheduleItemShareResponse
|
||||
|
||||
@@ -194,6 +216,11 @@ Base URL: `/api/v1/schedule-items`
|
||||
|
||||
更新日程(部分更新)。
|
||||
|
||||
### Authorization
|
||||
|
||||
- **Owner**: 可更新所有字段
|
||||
- **Subscriber (EDIT permission)**: 可更新所有字段(权限位掩码包含 `4`)
|
||||
|
||||
### Path Parameters
|
||||
|
||||
- `item_id`: 日程 UUID
|
||||
@@ -206,12 +233,24 @@ Base URL: `/api/v1/schedule-items`
|
||||
|
||||
`ScheduleItemResponse` 对象。
|
||||
|
||||
### Error Responses
|
||||
|
||||
| Status | Code | 说明 |
|
||||
|--------|------|------|
|
||||
| 403 | `SCHEDULE_ITEM_FORBIDDEN` | 当前用户无权编辑此日程 |
|
||||
| 404 | `SCHEDULE_ITEM_NOT_FOUND` | 日程不存在或用户既不是 owner 也没有订阅 |
|
||||
|
||||
---
|
||||
|
||||
## 5) DELETE `/{item_id}`
|
||||
|
||||
删除日程。
|
||||
|
||||
### Authorization
|
||||
|
||||
- **Owner**: 可删除日程(权限位掩码包含 `8`)
|
||||
- **Subscriber (DELETE permission)**: 可删除日程(权限位掩码包含 `8`)
|
||||
|
||||
### Path Parameters
|
||||
|
||||
- `item_id`: 日程 UUID
|
||||
@@ -220,6 +259,13 @@ Base URL: `/api/v1/schedule-items`
|
||||
|
||||
204 No Content。
|
||||
|
||||
### Error Responses
|
||||
|
||||
| Status | Code | 说明 |
|
||||
|--------|------|------|
|
||||
| 403 | `SCHEDULE_ITEM_FORBIDDEN` | 当前用户无权删除此日程 |
|
||||
| 404 | `SCHEDULE_ITEM_NOT_FOUND` | 日程不存在或用户既不是 owner 也没有订阅 |
|
||||
|
||||
---
|
||||
|
||||
## 6) POST `/{item_id}/share`
|
||||
|
||||
Reference in New Issue
Block a user