任务共享:补 /tasks/<id>/shares API 端点 #26
用户原话(2026-10-28):「鸿蒙端对齐网页端」。任务端上无「共享给谁」入口, Task::shares/setShare/dropShare 模型早就有(Web 端 tasks/share、tasks/unshare 在用), 只缺 API 子端点。 · GET/POST/DELETE /api/v1/tasks/<id>/shares —— 共享列表 / 加 / 取消 (canWrite 才允许;Task::find 本来就带 shares 字段,详情一次就能拿到) 判据:_i26_task_share_api.py 13/0(共享增/列/删 · 越权被拒), _i26_falsify.py 注掉 shares 分支变红。
This commit is contained in:
@@ -1765,6 +1765,36 @@ final class ApiHandler
|
||||
}
|
||||
}
|
||||
|
||||
/* 🔴 工单 #26(用户 2026-10-28「鸿蒙端对齐网页端」):任务共享。
|
||||
端上没有「共享给谁」入口;`Task::shares/setShare/dropShare` 模型早就齐
|
||||
(Web 端 tasks/share、tasks/unshare 在用),只缺 API 子端点。 */
|
||||
if ($sub === 'shares') {
|
||||
if ($method === 'GET') {
|
||||
Api::ok(['items' => Task::shares($id)]);
|
||||
}
|
||||
Api::requireWrite();
|
||||
if (!Task::canWrite($t, $pid)) {
|
||||
Api::fail('这项任务不能共享。', 'forbidden', 403);
|
||||
}
|
||||
if ($method === 'POST') {
|
||||
$who = Api::int('person_id');
|
||||
if ($who <= 0) {
|
||||
Api::fail('要共享给谁?缺 `person_id`。', 'unprocessable', 422);
|
||||
}
|
||||
Task::setShare($id, $who, Api::str('perm', 'write'));
|
||||
Api::ok(['items' => Task::shares($id)]);
|
||||
}
|
||||
if ($method === 'DELETE') {
|
||||
$who = Api::int('person_id');
|
||||
if ($who <= 0) {
|
||||
Api::fail('要取消谁的共享?缺 `person_id`。', 'unprocessable', 422);
|
||||
}
|
||||
Task::dropShare($id, $who);
|
||||
Api::ok(['items' => Task::shares($id)]);
|
||||
}
|
||||
Api::fail('不支持的方法。', 'method_not_allowed', 405);
|
||||
}
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════
|
||||
v79(用户 2026-10-22):「鸿蒙端的功能,也需要同样适配……
|
||||
任务模块的功能需要完善。」
|
||||
|
||||
Reference in New Issue
Block a user