From 8ff44eea2fb0f9c3dc9957efa1962e19151f3e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Sun, 17 Aug 2025 22:05:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=20=5Fquery=20?= =?UTF-8?q?=E5=92=8C=20=5Fvali=20=E5=BF=AB=E6=8D=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/think-library/src/common.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/plugin/think-library/src/common.php b/plugin/think-library/src/common.php index 8d4cef31e..668c29eeb 100644 --- a/plugin/think-library/src/common.php +++ b/plugin/think-library/src/common.php @@ -19,13 +19,16 @@ declare (strict_types=1); use think\admin\extend\CodeExtend; use think\admin\extend\HttpExtend; use think\admin\Helper; +use think\admin\helper\QueryHelper; use think\admin\helper\TokenHelper; +use think\admin\helper\ValidateHelper; use think\admin\Library; use think\admin\service\AdminService; use think\admin\service\QueueService; use think\admin\service\RuntimeService; use think\admin\service\SystemService; use think\admin\Storage; +use think\db\BaseQuery; use think\db\Query; use think\helper\Str; use think\Model; @@ -82,6 +85,31 @@ if (!function_exists('admuri')) { return sysuri('admin/index/index', [], $suffix, $domain) . '#' . url($url, $vars)->build(); } } +if (!function_exists('_vali')) { + /** + * 快捷输入并验证( 支持 规则 # 别名 ) + * @param array $rules 验证规则( 验证信息数组 ) + * @param string|array $type 输入方式 ( post. 或 get. ) + * @param callable|null $callable 异常处理操作 + * @return array + */ + function _vali(array $rules, $type = '', ?callable $callable = null): array + { + return ValidateHelper::instance()->init($rules, $type, $callable); + } +} +if (!function_exists('_query')) { + /** + * 快捷查询逻辑器 + * @param BaseQuery|Model|string $dbQuery + * @param array|string|null $input + * @return QueryHelper + */ + function _query($dbQuery, $input = null): QueryHelper + { + return QueryHelper::instance()->init($dbQuery, $input); + } +} if (!function_exists('sysvar')) { /** * 读写单次请求的内存缓存