64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace plugin\admin\app\controller;
|
|
|
|
use plugin\admin\app\model\OpmDsSensor;
|
|
use plugin\admin\app\model\OpmMwDepartment;
|
|
use plugin\admin\app\model\OpmMwHospital;
|
|
use plugin\admin\app\repository\SensorRepository;
|
|
use support\Request;
|
|
use support\Response;
|
|
|
|
/**
|
|
* 传感器管理
|
|
*/
|
|
class SensorController extends Crud
|
|
{
|
|
use WithDataPermission;
|
|
|
|
/**
|
|
* @var OpmDsSensor
|
|
*/
|
|
protected $model = null;
|
|
|
|
private SensorRepository $repository;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->model = new OpmDsSensor;
|
|
$this->repository = SensorRepository::new();
|
|
}
|
|
|
|
public function index(): Response
|
|
{
|
|
return raw_view('sensor/index');
|
|
}
|
|
|
|
public function insert(Request $request): Response
|
|
{
|
|
if ($request->method() === 'POST') {
|
|
return parent::insert($request);
|
|
}
|
|
return raw_view('sensor/insert');
|
|
}
|
|
|
|
public function update(Request $request): Response
|
|
{
|
|
if ($request->method() === 'POST') {
|
|
return parent::update($request);
|
|
}
|
|
return raw_view('sensor/update');
|
|
}
|
|
|
|
protected function afterQuery($items)
|
|
{
|
|
foreach ($items as &$item) {
|
|
$hospital = OpmMwHospital::find($item->hospital_id);
|
|
$department = OpmMwDepartment::find($item->department_id);
|
|
$item->hospital_name = $hospital->organ_name ?? '未知';
|
|
$item->department_name = $department->dept_name ?? '未知';
|
|
}
|
|
return $items;
|
|
}
|
|
}
|