feat(followup-audio): separate uploader-only recording delete permission

This commit is contained in:
2026-10-12 16:36:47 +08:00
parent 11306e6314
commit bcd42a5c39
10 changed files with 263 additions and 13 deletions
@@ -87,7 +87,8 @@ class AuthMiddleware
$action = substr($accessUri, strlen('tcm.followupaudio/'));
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
if (in_array($action, $allowed, true) && in_array('tcm.diagnosis/edit', $uris, true)
&& in_array('tcm.diagnosis/followupaudio', $uris, true)) {
&& in_array('tcm.diagnosis/followupaudio', $uris, true)
&& ($action !== 'delete' || in_array('tcm.followupaudio/delete', $uris, true))) {
return $next($request); // The service also checks the current patient scope and daily permissions.
}
return JsonService::fail('权限不足,无法访问或操作');
@@ -108,9 +108,8 @@ final class FollowupAudioLogic
{
$task = Store::task((int) $summary['id']);
$info = Access::actor($actor);
$reason = !Store::enabled() ? '回访录音功能尚未启用'
: ((int) $info['root'] !== 1 && (int) $task['actor_id'] !== $actor
? '仅上传者或超级管理员可删除录音' : Store::deleteBlockReason($task));
$reason = !Store::enabled() ? '回访录音功能尚未启用' : Access::deleteReason($task, $actor);
if ($reason === '') { $reason = Store::deleteBlockReason($task); }
$reextractReason = (int) $info['root'] !== 1 && (int) $task['actor_id'] !== $actor
? '仅上传者或超级管理员可重新提炼' : Reextract::blockReason($task);
return $summary + ['can_delete' => $reason === '', 'delete_block_reason' => $reason,