ige
This commit is contained in:
@@ -12,6 +12,7 @@ use app\common\service\followupaudio\FollowupAudioProviderConfig as ProviderConf
|
||||
use app\common\service\followupaudio\FollowupAudioStore as Store;
|
||||
use app\common\service\followupaudio\FollowupAudioUpload as Upload;
|
||||
use DomainException;
|
||||
use app\common\service\followupaudio\FollowupAudioReextract as Reextract;
|
||||
|
||||
final class FollowupAudioLogic
|
||||
{
|
||||
@@ -70,7 +71,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 +98,30 @@ 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() ? '回访录音功能尚未启用' : 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,
|
||||
'can_reextract' => $reextractReason === '', 'reextract_block_reason' => $reextractReason];
|
||||
}
|
||||
|
||||
public static function reextract(int $id, int $version, $roles, int $actor, array $info): array
|
||||
{
|
||||
self::requireEnabled(true);
|
||||
return self::protectDetail(Reextract::queue($id, $version, $roles, $actor, $info), $actor, $info);
|
||||
}
|
||||
|
||||
public static function retry(int $id, int $actor, array $info): array
|
||||
{
|
||||
self::requireEnabled(true);
|
||||
@@ -160,7 +186,7 @@ final class FollowupAudioLogic
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
return $detail;
|
||||
return self::withDeleteCapability($detail, $actor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user