init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user