ige
This commit is contained in:
@@ -93,6 +93,19 @@ 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 reextract()
|
||||
{
|
||||
return $this->handle(true, ['id', 'version', 'channel_roles'], fn (array $p): array =>
|
||||
Logic::reextract($this->positive($p, 'id'), $this->positive($p, 'version'),
|
||||
$p['channel_roles'] ?? null, $this->adminId, $this->adminInfo), true);
|
||||
}
|
||||
|
||||
public function retry()
|
||||
{
|
||||
return $this->handle(true, ['id'], fn (array $p): array =>
|
||||
|
||||
@@ -83,10 +83,12 @@ 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', 'reextract'];
|
||||
$action = substr($accessUri, strlen('tcm.followupaudio/'));
|
||||
$uris = $this->formatUrl($adminAuthCache->getAdminUri() ?? []);
|
||||
if (in_array($action, $allowed, true) && in_array('tcm.diagnosis/edit', $uris, true)) {
|
||||
if (in_array($action, $allowed, true) && in_array('tcm.diagnosis/edit', $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('权限不足,无法访问或操作');
|
||||
|
||||
@@ -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