55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\adminapi\controller\tcm;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\logic\tcm\MobileRecordingLogic;
|
|
use DomainException;
|
|
|
|
/** Authenticated metadata sync; no upload, transcript or arbitrary file URL endpoint. */
|
|
final class MobileRecordingController extends BaseAdminController
|
|
{
|
|
public function bind()
|
|
{
|
|
return $this->handle(true, fn (array $params): array => MobileRecordingLogic::bind($params, $this->adminId));
|
|
}
|
|
|
|
public function unbind()
|
|
{
|
|
return $this->handle(true, fn (array $params): array => MobileRecordingLogic::unbind($params, $this->adminId));
|
|
}
|
|
|
|
public function deviceLists()
|
|
{
|
|
return $this->handle(false, fn (array $params): array => MobileRecordingLogic::deviceLists($params, $this->adminId));
|
|
}
|
|
|
|
public function patientLists()
|
|
{
|
|
return $this->handle(false, fn (array $params): array => MobileRecordingLogic::patientLists($params, $this->adminId));
|
|
}
|
|
|
|
private function handle(bool $post, callable $operation)
|
|
{
|
|
if ($post ? !$this->request->isPost() : !$this->request->isGet()) {
|
|
return $this->fail('请求方式错误');
|
|
}
|
|
try {
|
|
// Explicit current page permission, including before any row lookup.
|
|
MobileRecordingLogic::actor((int) $this->adminId);
|
|
if ($this->request->file()) {
|
|
throw new DomainException('手机录音关联不接受文件上传');
|
|
}
|
|
$params = $post ? $this->request->post('', null, null) : $this->request->get();
|
|
return $this->data($operation($params));
|
|
} catch (DomainException $e) {
|
|
return $this->fail($e->getMessage());
|
|
} catch (\Throwable $e) {
|
|
// Do not expose SQL, identifiers, paths or server configuration on schema/deployment errors.
|
|
return $this->fail('手机录音关联服务暂不可用,请稍后重试或联系管理员');
|
|
}
|
|
}
|
|
}
|