33 lines
722 B
PHP
33 lines
722 B
PHP
<?php
|
|
|
|
namespace plugin\admin\app\repository;
|
|
|
|
use plugin\admin\app\model\OpmDsWarnRule;
|
|
use plugin\admin\app\repository\exception\EntityNotFoundException;
|
|
|
|
class WarnRuleRepository extends BaseRepository
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->model = new OpmDsWarnRule;
|
|
}
|
|
|
|
public static function new(): WarnRuleRepository
|
|
{
|
|
return new self();
|
|
}
|
|
|
|
/**
|
|
* 根据ID查找报警规则
|
|
* @throws EntityNotFoundException
|
|
*/
|
|
public function findOrFail(int $id): OpmDsWarnRule
|
|
{
|
|
$rule = $this->scopedQuery()->find($id);
|
|
if (!$rule) {
|
|
throw new EntityNotFoundException('报警规则不存在');
|
|
}
|
|
return $rule;
|
|
}
|
|
}
|