From ad71c80f486e5f9d50e255c716cf05443b504a9b Mon Sep 17 00:00:00 2001 From: laoyang Date: Wed, 28 Oct 2026 22:10:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=85=B1=E4=BA=AB=EF=BC=9A?= =?UTF-8?q?=E8=A1=A5=20/tasks//shares=20API=20=E7=AB=AF=E7=82=B9=20#26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户原话(2026-10-28):「鸿蒙端对齐网页端」。任务端上无「共享给谁」入口, Task::shares/setShare/dropShare 模型早就有(Web 端 tasks/share、tasks/unshare 在用), 只缺 API 子端点。 · GET/POST/DELETE /api/v1/tasks//shares —— 共享列表 / 加 / 取消 (canWrite 才允许;Task::find 本来就带 shares 字段,详情一次就能拿到) 判据:_i26_task_share_api.py 13/0(共享增/列/删 · 越权被拒), _i26_falsify.py 注掉 shares 分支变红。 --- app/ApiHandler.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/ApiHandler.php b/app/ApiHandler.php index 5dc56dc..1ed663d 100644 --- a/app/ApiHandler.php +++ b/app/ApiHandler.php @@ -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):「鸿蒙端的功能,也需要同样适配…… 任务模块的功能需要完善。」