From 310d77f9f2577dbf5a450def0b54035092964e49 Mon Sep 17 00:00:00 2001 From: zj Date: Thu, 30 Jul 2026 15:08:36 +0800 Subject: [PATCH] update --- src/Service.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Service.php b/src/Service.php index c5ffda4..d574d1b 100644 --- a/src/Service.php +++ b/src/Service.php @@ -22,11 +22,11 @@ use Hyperf\DbConnection\Db; /** * @template T of Model * @property Repository $repository - * @property Validator $validator + * @property Validator $modelValidator */ abstract class Service { - protected ?Validator $validator = null; + protected ?Validator $modelValidator = null; protected array $search = []; protected array $ignoreSearchFields = []; @@ -51,7 +51,7 @@ abstract class Service */ public function create(array $data): mixed { - $this->validator?->scene('create', $data)->check(); + $this->modelValidator?->scene('create', $data)->check(); return $this->repository->create($data); } @@ -60,7 +60,7 @@ abstract class Service */ public function save(array $data): mixed { - $this->validator?->scene('create', $data)->check(); + $this->modelValidator?->scene('create', $data)->check(); return $this->create($data); } @@ -70,7 +70,7 @@ abstract class Service public function updateById(mixed $id, array $data): mixed { // 数据验证 - $this->validator?->scene('update', $data)->check(); + $this->modelValidator?->scene('update', $data)->check(); return $this->repository->updateById($id, $data); } @@ -154,7 +154,7 @@ abstract class Service $this->checkResourceExists($resource); // 数据验证 - $this->validator?->scene('update', $data)->check(); + $this->modelValidator?->scene('update', $data)->check(); // 钩子:处理更新时的特殊逻辑(如禁止自身为父级) $this->handleUpdateSpecialLogic($id, $data);