From 352fd61f92e70a0919ce2a4bcc3b1c3b0a4101a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 22 Aug 2024 11:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api2sql/execute.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/api2sql/execute.go b/api2sql/execute.go index 3ee0fc7..3925024 100644 --- a/api2sql/execute.go +++ b/api2sql/execute.go @@ -159,6 +159,23 @@ func (e *execute) formatAndValidateInputParam(inputParam *define.Api2SqlParam) e return errors.New(inputParam.DatabaseFlag + " : table field list is empty, please enable `CacheDataTableStructureConfig` or `SetTableColumnConfig`") } // 操作字段列表为空 + if err = e.validateColumn(inputParam); nil != err { + return err + } + // 验证 force no limit + if inputParam.ForceNoLimit { + inputParam.Limit = 0 + inputParam.WithCount = false + } + return nil +} + +// validateColumn 验证表字段相关 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 11:48 2024/8/22 +func (e *execute) validateColumn(inputParam *define.Api2SqlParam) error { if len(inputParam.ColumnList) == 0 && wrapper.ArrayType[string]([]string{ consts.SqlTypeList, consts.SqlTypeDetail, }).Has(inputParam.SqlType) >= 0 { @@ -181,10 +198,5 @@ func (e *execute) formatAndValidateInputParam(inputParam *define.Api2SqlParam) e return errors.New(item.Column + " : input column in `ValueList` is not found in table column list") } } - // 验证 force no limit - if inputParam.ForceNoLimit { - inputParam.Limit = 0 - inputParam.WithCount = false - } return nil }