61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\adminapi\controller\pharmacy;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\lists\pharmacy\MedicineMappingLists;
|
|
use app\adminapi\logic\pharmacy\MedicineMappingLogic;
|
|
use app\adminapi\validate\pharmacy\MedicineMappingValidate;
|
|
|
|
class MedicineMappingController extends BaseAdminController
|
|
{
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new MedicineMappingLists());
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
return $this->data(MedicineMappingLogic::status());
|
|
}
|
|
|
|
public function catalogOptions()
|
|
{
|
|
return $this->data(MedicineMappingLogic::catalogOptions(
|
|
(string) $this->request->get('keyword', ''),
|
|
(int) $this->request->get('limit', 30)
|
|
));
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$params = (new MedicineMappingValidate())->post()->goCheck('save');
|
|
$name = (string) ($this->adminInfo['name'] ?? $this->adminInfo['nickname'] ?? '');
|
|
if (!MedicineMappingLogic::save($params, $this->adminId, $name)) {
|
|
return $this->fail(MedicineMappingLogic::getError());
|
|
}
|
|
return $this->success('映射已保存', [], 1, 1);
|
|
}
|
|
|
|
public function unlink()
|
|
{
|
|
$params = (new MedicineMappingValidate())->post()->goCheck('unlink');
|
|
$name = (string) ($this->adminInfo['name'] ?? $this->adminInfo['nickname'] ?? '');
|
|
if (!MedicineMappingLogic::unlink((int) $params['local_medicine_id'], $this->adminId, $name)) {
|
|
return $this->fail(MedicineMappingLogic::getError());
|
|
}
|
|
return $this->success('映射已解除', [], 1, 1);
|
|
}
|
|
|
|
public function sync()
|
|
{
|
|
$result = MedicineMappingLogic::sync();
|
|
if ($result === false) {
|
|
return $this->fail(MedicineMappingLogic::getError());
|
|
}
|
|
return $this->success('目录同步完成', $result);
|
|
}
|
|
}
|