Files
dsserver/plugin/admin/app/repository/SensorRepository.php
T
zimoyin 13fd9c5f0a init
2026-04-06 20:48:32 +08:00

33 lines
712 B
PHP

<?php
namespace plugin\admin\app\repository;
use plugin\admin\app\model\OpmDsSensor;
use plugin\admin\app\repository\exception\EntityNotFoundException;
class SensorRepository extends BaseRepository
{
public function __construct()
{
$this->model = new OpmDsSensor;
}
public static function new(): SensorRepository
{
return new self();
}
/**
* 根据ID查找传感器
* @throws EntityNotFoundException
*/
public function findOrFail(int $id): OpmDsSensor
{
$sensor = $this->scopedQuery()->find($id);
if (!$sensor) {
throw new EntityNotFoundException('传感器不存在');
}
return $sensor;
}
}