类型使用枚举值适配
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/consts/enums"
|
||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||
"git.zhangdeman.cn/zhangdeman/wrapper"
|
||||
"reflect"
|
||||
@ -196,7 +197,7 @@ func (f *filter) Parse(receiver interface{}) error {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:25 2022/7/4
|
||||
func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValue string) (any, error) {
|
||||
func (f *filter) getValue(dataType enums.DataType, sourceValue gjson.Result, defaultValue string) (any, error) {
|
||||
sourceValueStr := defaultValue
|
||||
if sourceValue.Exists() {
|
||||
str := sourceValue.String()
|
||||
@ -282,7 +283,7 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu
|
||||
sliceVal := strVal.ToStringSlice(",")
|
||||
return sliceVal.Value, sliceVal.Err
|
||||
case consts.DataTypeSliceSlice, consts.DataTypeMapAnyAny:
|
||||
return nil, errors.New(consts.DataTypeSliceSlice + " : data type is not support")
|
||||
return nil, errors.New(consts.DataTypeSliceSlice.String() + " : data type is not support")
|
||||
case consts.DataTypeSliceMapStringAny:
|
||||
if !sourceValue.IsArray() {
|
||||
return nil, errors.New("data type is not array")
|
||||
@ -340,6 +341,6 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu
|
||||
err := strVal.ToStruct(&res)
|
||||
return res, err
|
||||
default:
|
||||
return nil, errors.New(dataType + " is not support!")
|
||||
return nil, errors.New(dataType.String() + " is not support!")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user