From d52af7e3f4f7295bb556661e38c89c9d9a2d12f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 4 Jul 2022 12:30:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- filter.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/filter.go b/filter.go index bb7192b..99151ff 100644 --- a/filter.go +++ b/filter.go @@ -7,7 +7,10 @@ // Date : 2022-07-04 11:45 package util -import "github.com/Jeffail/gabs" +import ( + "github.com/Jeffail/gabs" + "github.com/pkg/errors" +) // MapRule 映射规则 // @@ -61,5 +64,54 @@ func (f *filter) Deal() ([]byte, error) { // // Date : 12:25 2022/7/4 func (f *filter) getDefaultValue(dataType string, defaultValue string) (interface{}, error) { - return nil, nil + switch dataType { + case "int8": + fallthrough + case "int16": + fallthrough + case "int32": + fallthrough + case "int64": + fallthrough + case "int": + var ( + err error + val int64 + ) + err = ConvertAssign(&val, defaultValue) + return val, err + case "uint8": + fallthrough + case "uint16": + fallthrough + case "uint32": + fallthrough + case "uint64": + fallthrough + case "uint": + var ( + err error + val uint64 + ) + err = ConvertAssign(&val, defaultValue) + return val, err + case "bool": + var ( + err error + val bool + ) + err = ConvertAssign(&val, defaultValue) + return val, err + case "float32": + fallthrough + case "float64": + var ( + err error + val float64 + ) + err = ConvertAssign(&val, defaultValue) + return val, err + default: + return nil, errors.New(dataType + " is not support!") + } }