更新
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLibraryLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionLibraryValidate;
|
||||
|
||||
/**
|
||||
* 处方库控制器
|
||||
*/
|
||||
class PrescriptionLibraryController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 处方库列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new \app\adminapi\lists\tcm\PrescriptionLibraryLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加处方库
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->post()->goCheck('add');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
$params['creator_name'] = $this->adminInfo['name'] ?? '';
|
||||
$id = PrescriptionLibraryLogic::add($params);
|
||||
if ($id === null) {
|
||||
return $this->fail(PrescriptionLibraryLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑处方库
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->post()->goCheck('edit');
|
||||
$result = PrescriptionLibraryLogic::edit($params, $this->adminId);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLibraryLogic::getError());
|
||||
}
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除处方库
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->post()->goCheck('delete');
|
||||
$result = PrescriptionLibraryLogic::delete($params['id'], $this->adminId);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLibraryLogic::getError());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 处方库详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->get()->goCheck('detail');
|
||||
$detail = PrescriptionLibraryLogic::detail((int)$params['id'], $this->adminId);
|
||||
if (!$detail) {
|
||||
return $this->fail('处方不存在或无权限查看');
|
||||
}
|
||||
return $this->data($detail);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user