From c99c17fa00b7d107e1d6e68b99daec1f22cd7b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 23 Feb 2025 09:55:54 +0800 Subject: [PATCH] Update SystemService.php --- plugin/think-library/src/service/SystemService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/think-library/src/service/SystemService.php b/plugin/think-library/src/service/SystemService.php index 4f3d39b91..2a34f2a01 100644 --- a/plugin/think-library/src/service/SystemService.php +++ b/plugin/think-library/src/service/SystemService.php @@ -191,8 +191,7 @@ class SystemService extends Service try { $query = Helper::buildQuery($query)->master()->where($map); if (empty($map[$key])) $query->where([$key => $data[$key] ?? null]); - $model = (clone $query)->findOrEmpty(); - return $model->isExists() ? (clone $query)->strict(false)->update($data) : $model->save($data); + return (clone $query)->count() > 1 ? $query->strict(false)->update($data) : $query->findOrEmpty()->save($data); } catch (\Exception|\Throwable $exception) { throw new Exception($exception->getMessage(), $exception->getCode()); }