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!") + } }