feat(followup-audio): soft delete unadopted recordings and expose extraction doubts
This commit is contained in:
@@ -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