feat(followup-audio): soft delete unadopted recordings and expose extraction doubts
This commit is contained in:
@@ -93,6 +93,12 @@ final class FollowupAudioController extends BaseAdminController
|
||||
$this->items($p), $this->adminId, $this->adminInfo), true);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
return $this->handle(true, ['id', 'version'], fn (array $p): array =>
|
||||
Logic::delete($this->positive($p, 'id'), $this->positive($p, 'version'), $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
public function retry()
|
||||
{
|
||||
return $this->handle(true, ['id'], fn (array $p): array =>
|
||||
|
||||
@@ -83,7 +83,7 @@ class AuthMiddleware
|
||||
// This group must never use the legacy unregistered-route bypass.
|
||||
if (str_starts_with($accessUri, 'tcm.followupaudio/')) {
|
||||
$allowed = ['capabilities', 'uploadsession', 'uploadchunk', 'uploadcomplete',
|
||||
'create', 'lists', 'detail', 'savedraft', 'apply', 'retry', 'audio'];
|
||||
'create', 'lists', 'detail', 'savedraft', 'apply', 'retry', 'audio', 'delete'];
|
||||
$action = substr($accessUri, strlen('tcm.followupaudio/'));
|
||||
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
|
||||
if (in_array($action, $allowed, true) && in_array('tcm.diagnosis/edit', $uris, true)) {
|
||||
|
||||
@@ -70,7 +70,8 @@ final class FollowupAudioLogic
|
||||
public static function lists(int $diagnosisId, int $actor, array $info): array
|
||||
{
|
||||
Access::diagnosis($diagnosisId, $actor, $info);
|
||||
return ['items' => Store::enabled() ? Store::lists($diagnosisId) : []];
|
||||
return ['items' => Store::enabled() ? array_map(static fn (array $task): array =>
|
||||
self::withDeleteCapability($task, $actor), Store::lists($diagnosisId)) : []];
|
||||
}
|
||||
|
||||
public static function detail(int $id, int $actor, array $info): array
|
||||
@@ -96,6 +97,22 @@ final class FollowupAudioLogic
|
||||
return Apply::apply($id, $version, $items, $actor, $info);
|
||||
}
|
||||
|
||||
public static function delete(int $id, int $version, int $actor, array $info): array
|
||||
{
|
||||
self::requireEnabled();
|
||||
return Store::delete($id, $version, $actor, $info);
|
||||
}
|
||||
|
||||
private static function withDeleteCapability(array $summary, int $actor): array
|
||||
{
|
||||
$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));
|
||||
return $summary + ['can_delete' => $reason === '', 'delete_block_reason' => $reason];
|
||||
}
|
||||
|
||||
public static function retry(int $id, int $actor, array $info): array
|
||||
{
|
||||
self::requireEnabled(true);
|
||||
@@ -160,7 +177,7 @@ final class FollowupAudioLogic
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
return $detail;
|
||||
return self::withDeleteCapability($detail, $actor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user