From d0360ef2ea7def99cf56fffdf3bb268cfac3a713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=87=82=E4=B8=8D=E8=83=BD=E6=87=82?= <295047320@qq.com> Date: Fri, 16 May 2025 03:24:02 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 懂不能懂 <295047320@qq.com> --- app/common/controller/Backend.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/common/controller/Backend.php b/app/common/controller/Backend.php index 8e1a266f..fba417b1 100644 --- a/app/common/controller/Backend.php +++ b/app/common/controller/Backend.php @@ -52,7 +52,11 @@ class Backend extends Api * @var string|array id,desc 或 ['id' => 'desc'] */ protected string|array $defaultSortField = []; - + /** + * 默认排序 + * @var array ['id', '=', 1] + */ + protected array $defaultWhere = []; /** * 有序保证 * 查询数据时总是需要指定 ORDER BY 子句,否则 MySQL 不保证排序,即先查到哪行就输出哪行且不保证多次查询中的输出顺序 @@ -186,7 +190,7 @@ class Backend extends Api $initValue = $this->request->get("initValue", ''); $initOperator = $this->request->get("initOperator/s", 'in'); - $where = []; + $where = $this->defaultWhere; $modelTable = strtolower($this->model->getTable()); $alias[$modelTable] = parse_name(basename(str_replace('\\', '/', get_class($this->model)))); $mainTableAlias = $alias[$modelTable] . '.'; -- Gitee