444 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			444 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Package consts ...
 | 
						||
//
 | 
						||
// Description : consts ...
 | 
						||
//
 | 
						||
// Author : go_developer@163.com<白茶清欢>
 | 
						||
//
 | 
						||
// Date : 2024-04-08 16:33
 | 
						||
package consts
 | 
						||
 | 
						||
import "time"
 | 
						||
 | 
						||
// DataType 数据类型枚举值
 | 
						||
//
 | 
						||
// Author : go_developer@163.com<白茶清欢>
 | 
						||
//
 | 
						||
// Date : 14:10 2024/11/25
 | 
						||
type DataType string
 | 
						||
 | 
						||
func (df DataType) String() string {
 | 
						||
	return string(df)
 | 
						||
}
 | 
						||
 | 
						||
func (df DataType) MarshalJSON() ([]byte, error) {
 | 
						||
	return []byte(`"` + df.String() + `"`), nil
 | 
						||
}
 | 
						||
 | 
						||
// IsValid 判断枚举值是否有效
 | 
						||
//
 | 
						||
// Author : go_developer@163.com<白茶清欢>
 | 
						||
//
 | 
						||
// Date : 14:45 2024/11/25
 | 
						||
func (df DataType) IsValid() bool {
 | 
						||
	for _, item := range DataTypeList {
 | 
						||
		if item.Value == df || item.Value.String() == df.String() {
 | 
						||
			return true
 | 
						||
		}
 | 
						||
	}
 | 
						||
	return false
 | 
						||
}
 | 
						||
 | 
						||
var (
 | 
						||
	DataTypeUnknown                      DataType = "unknown"                   // 位置数据类型
 | 
						||
	DataTypeNil                          DataType = "nil"                       // nil
 | 
						||
	DataTypePtr                          DataType = "ptr"                       // 指针
 | 
						||
	DataTypeInt                          DataType = "int"                       // int类型 -> int64
 | 
						||
	DataTypeInt8                         DataType = "int8"                      // int8类型
 | 
						||
	DataTypeInt16                        DataType = "int16"                     // int16类型
 | 
						||
	DataTypeInt32                        DataType = "int32"                     // int32类型
 | 
						||
	DataTypeInt64                        DataType = "int64"                     // int64类型
 | 
						||
	DataTypeUint                         DataType = "uint"                      // uint类型 -> uint64
 | 
						||
	DataTypeUint8                        DataType = "uint8"                     // uint8类型
 | 
						||
	DataTypeUint16                       DataType = "uint16"                    // uint16类型
 | 
						||
	DataTypeUint32                       DataType = "uint32"                    // uint32类型
 | 
						||
	DataTypeUint64                       DataType = "uint64"                    // uint64类型
 | 
						||
	DataTypeFloat32                      DataType = "float32"                   // float32类型
 | 
						||
	DataTypeFloat64                      DataType = "float64"                   // float64类型
 | 
						||
	DataTypeBool                         DataType = "bool"                      // bool类型
 | 
						||
	DataTypeString                       DataType = "string"                    // 字符串类型
 | 
						||
	DataTypeSliceAny                     DataType = "[]any"                     // any数组 -> []any
 | 
						||
	DataTypeSliceAnyWithMarshal          DataType = "[]any_marshal"             // any数组 -> []any, json序列化之后的结构
 | 
						||
	DataTypeSliceInt                     DataType = "[]int"                     // int数组 -> []int64
 | 
						||
	DataTypeSliceIntWithChar             DataType = "[]int_split"               // int数组 -> []int64, 按照指定字符切割
 | 
						||
	DataTypeSliceIntWithMarshal          DataType = "[]int_marshal"             // int数组 -> []int64, json序列化之后的结果
 | 
						||
	DataTypeSliceUint                    DataType = "[]uint"                    // uint数组 -> []uint64
 | 
						||
	DataTypeSliceUintWithChar            DataType = "[]uint_split"              // uint数组 -> []uint64, 指定字符切割
 | 
						||
	DataTypeSliceUintWithMarshal         DataType = "[]uint_marshal"            // uint数组 -> []uint64, json序列化之后的结果
 | 
						||
	DataTypeSliceFloat                   DataType = "[]float"                   // float数组 -> []float64
 | 
						||
	DataTypeSliceFloatWithChar           DataType = "[]float_split"             // float数组 -> []float64, 指定字符切割
 | 
						||
	DataTypeSliceFloatWithMarshal        DataType = "[]float_marshal"           // float数组 -> []float64, json序列化之后的结果
 | 
						||
	DataTypeSliceBool                    DataType = "[]bool"                    // bool数组 -> []bool
 | 
						||
	DataTypeSliceBoolWithChar            DataType = "[]bool_split"              // bool数组 -> []bool, 指定字符切割
 | 
						||
	DataTypeSliceBoolWithMarshal         DataType = "[]bool_marshal"            // bool数组 -> []bool, json序列化之后的结果
 | 
						||
	DataTypeSliceString                  DataType = "[]string"                  // 字符串数组 -> []string
 | 
						||
	DataTypeSliceStringWithChar          DataType = "[]string_split"            // 字符串数组 -> []string, 指定字符切割
 | 
						||
	DataTypeSliceStringWithMarshal       DataType = "[]string_marshal"          // 字符串数组 -> []string, json序列化之后的结果
 | 
						||
	DataTypeSliceSlice                   DataType = "[][]any"                   // 字符串数组 -> [][]any
 | 
						||
	DataTypeSliceSliceWithMarshal        DataType = "[][]any_marshal"           // 字符串数组 -> [][]any,json序列化之后的结果
 | 
						||
	DataTypeSliceMapAnyAny               DataType = "[]map[any]any"             // 字符串数组 -> []map[any]any, slice对象
 | 
						||
	DataTypeSliceMapAnyAnyWithMarshal    DataType = "[]map[any]any_marshal"     // 字符串数组 -> []map[any]any, json序列化后的结果
 | 
						||
	DataTypeSliceMapStringAny            DataType = "[]map[string]any"          // 字符串数组 -> map[string]any, slice对象
 | 
						||
	DataTypeSliceMapStringAnyWithMarshal DataType = "[]map[string]any_marshal"  // 字符串数组 -> []map[string]any, slice对象, json序列化之后的结果
 | 
						||
	DataTypeMapStrInt                    DataType = "map[string]int"            // map -> map[string]int64
 | 
						||
	DataTypeMapStrIntWithMarshal         DataType = "map[string]int_marshal"    // map -> map[string]int64,json序列化之后的结果
 | 
						||
	DataTypeMapStrUint                   DataType = "map[string]uint"           // map -> map[string]uint64
 | 
						||
	DataTypeMapStrUintWithMarshal        DataType = "map[string]uint_marshal"   // map -> map[string]uint64, json序列化之后的结果
 | 
						||
	DataTypeMapStrFloat                  DataType = "map[string]float"          // map -> map[string]float64
 | 
						||
	DataTypeMapStrFloatWithMarshal       DataType = "map[string]float_marshal"  // map -> map[string]float64, json序列化之后的结果
 | 
						||
	DataTypeMapStrBool                   DataType = "map[string]bool"           // map -> map[string]bool
 | 
						||
	DataTypeMapStrBoolWithMarshal        DataType = "map[string]bool_marshal"   // map -> map[string]bool,json序列换之后的结果
 | 
						||
	DataTypeMapStrAny                    DataType = "map[string]any"            // map -> map[string]any
 | 
						||
	DataTypeMapStrAnyWithMarshal         DataType = "map[string]any_marshal"    // map -> map[string]any, json序列化之后的结果
 | 
						||
	DataTypeMapStrStr                    DataType = "map[string]string"         // map -> map[string]string
 | 
						||
	DataTypeMapStrStrWithMarshal         DataType = "map[string]string_marshal" // map -> map[string]string, json序列化之后的结果
 | 
						||
	DataTypeMapAnyAny                    DataType = "map[any]any"               // map -> map[any]any
 | 
						||
	DataTypeMapAnyAnyWithMarshal         DataType = "map[any]any_marshal"       // map -> map[any]any, json序列化之后的结果
 | 
						||
	DataTypeMapStrSlice                  DataType = "map[string][]any"          // map -> map[string][]any
 | 
						||
	DataTypeMapStrSliceWithMarshal       DataType = "map[string][]any_marshal"  // map -> map[string][]any, json 序列化之后的结果
 | 
						||
	DataTypeAny                          DataType = "any"                       // 任意类型 -> any
 | 
						||
	DataTypeStringPtr                    DataType = "string_ptr"                // *string, 字符串指针
 | 
						||
	DataTypeIntPtr                       DataType = "int_ptr"                   // *int64, int64指针
 | 
						||
	DataTypeInt8Ptr                      DataType = "int8_ptr"                  // *int8, int8指针
 | 
						||
	DataTypeInt16Ptr                     DataType = "int16_ptr"                 // *int16, int16指针
 | 
						||
	DataTypeInt32Ptr                     DataType = "int32_ptr"                 // *int32, int32指针
 | 
						||
	DataTypeInt64Ptr                     DataType = "int64_ptr"                 // *int64, int64指针
 | 
						||
	DataTypeUintPtr                      DataType = "uint_ptr"                  // *uint64, uint64指针
 | 
						||
	DataTypeUint8Ptr                     DataType = "uint8_ptr"                 // *uint8, uint8指针
 | 
						||
	DataTypeUint16Ptr                    DataType = "uint16_ptr"                // *uint16, uint16指针
 | 
						||
	DataTypeUint32Ptr                    DataType = "uint32_ptr"                // *uint32, uint32指针
 | 
						||
	DataTypeUint64Ptr                    DataType = "uint64_ptr"                // *uint64, uint64指针
 | 
						||
	DataTypeFloat32Ptr                   DataType = "float32_ptr"               // *float32, float32指针
 | 
						||
	DataTypeFloat64Ptr                   DataType = "float64_ptr"               // *float64, float64指针
 | 
						||
	DataTypeBoolPtr                      DataType = "bool_ptr"                  // *bool, 字符串指针
 | 
						||
	DataTypeTime                         DataType = "time.Time"                 // time.Time, json类型
 | 
						||
	DataTypeJson                         DataType = "json"                      // json, json类型, 特殊的字符串
 | 
						||
)
 | 
						||
 | 
						||
const (
 | 
						||
	DataStatusNotFound = "NOT_FOUND"
 | 
						||
	DataStatusIsNil    = "IS_NIL"
 | 
						||
	DataStatusIsZero   = "IS_ZERO"
 | 
						||
	DataStatusIsEmpty  = "IS_EMPTY"
 | 
						||
	DataStatusIsFalse  = "IS_FALSE"
 | 
						||
)
 | 
						||
 | 
						||
const (
 | 
						||
	DataSliceModelReal          = "REAL"
 | 
						||
	DataSliceModelMarshal       = "MARSHAL"
 | 
						||
	DataSliceModelWithSplitChar = "WITH_SPLIT_CHAR"
 | 
						||
)
 | 
						||
 | 
						||
const (
 | 
						||
	DataMapModelReal    = "REAL"
 | 
						||
	DataMapModelMarshal = "MARSHAL"
 | 
						||
)
 | 
						||
 | 
						||
// DataTypeDesc 数据类型描述
 | 
						||
//
 | 
						||
// Author : go_developer@163.com<白茶清欢>
 | 
						||
//
 | 
						||
// Date : 13:22 2024/6/23
 | 
						||
type DataTypeDesc struct {
 | 
						||
	Value       DataType `json:"value"`       // 具体数据类型
 | 
						||
	Description string   `json:"description"` // 数据类型描述
 | 
						||
}
 | 
						||
 | 
						||
var (
 | 
						||
	DataTypeList = []DataTypeDesc{
 | 
						||
		// 基础数据类型
 | 
						||
		getDataTypeDesc(DataTypeAny, "任意数据类型"),
 | 
						||
		getDataTypeDesc(DataTypeInt, "int类型"),
 | 
						||
		getDataTypeDesc(DataTypeInt8, "int8类型"),
 | 
						||
		getDataTypeDesc(DataTypeInt16, "int16类型"),
 | 
						||
		getDataTypeDesc(DataTypeInt32, "int32类型"),
 | 
						||
		getDataTypeDesc(DataTypeInt64, "int64类型"),
 | 
						||
		getDataTypeDesc(DataTypeUint, "uint类型"),
 | 
						||
		getDataTypeDesc(DataTypeUint8, "uint8类型"),
 | 
						||
		getDataTypeDesc(DataTypeUint16, "uint16类型"),
 | 
						||
		getDataTypeDesc(DataTypeUint32, "uint32类型"),
 | 
						||
		getDataTypeDesc(DataTypeUint64, "uint64类型"),
 | 
						||
		getDataTypeDesc(DataTypeFloat32, "float32类型"),
 | 
						||
		getDataTypeDesc(DataTypeFloat64, "float64类型"),
 | 
						||
		getDataTypeDesc(DataTypeBool, "bool类型"),
 | 
						||
		getDataTypeDesc(DataTypeString, "字符串类型"),
 | 
						||
 | 
						||
		// map数据类型
 | 
						||
		getDataTypeDesc(DataTypeMapStrAny, "map[string]any"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrAnyWithMarshal, "map[string]any json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrInt, "map[string]int64"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrIntWithMarshal, "map[string]int64 json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrUint, "map[string]uint64"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrUintWithMarshal, "map[string]uint64 json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrFloat, "map[string]float64"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrFloatWithMarshal, "map[string]float64 json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrBool, "map[string]bool"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrBoolWithMarshal, "map[string]bool json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrStr, "map[string]string"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrStrWithMarshal, "map[string]string json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapAnyAny, "map[any]any"),
 | 
						||
		getDataTypeDesc(DataTypeMapAnyAnyWithMarshal, "map[any]any json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrSlice, "map[string][]any"),
 | 
						||
		getDataTypeDesc(DataTypeMapStrSliceWithMarshal, "map[string][]any json序列化之后的结果"),
 | 
						||
 | 
						||
		// slice数据类型
 | 
						||
		getDataTypeDesc(DataTypeSliceAny, "[]any"),
 | 
						||
		getDataTypeDesc(DataTypeSliceString, "[]string"),
 | 
						||
		getDataTypeDesc(DataTypeSliceStringWithChar, "[]string 按照指定字符切割"),
 | 
						||
		getDataTypeDesc(DataTypeSliceStringWithMarshal, "[]string json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceAnyWithMarshal, "[]any json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceInt, "[]int"),
 | 
						||
		getDataTypeDesc(DataTypeSliceIntWithChar, "[]int 按照指定字符切割"),
 | 
						||
		getDataTypeDesc(DataTypeSliceIntWithMarshal, "[]int json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceUint, "[]uint"),
 | 
						||
		getDataTypeDesc(DataTypeSliceUintWithChar, "[]uint 按照指定字符切割"),
 | 
						||
		getDataTypeDesc(DataTypeSliceUintWithMarshal, "[]uint json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceFloat, "[]float"),
 | 
						||
		getDataTypeDesc(DataTypeSliceFloatWithChar, "[]float 按照指定字符切割"),
 | 
						||
		getDataTypeDesc(DataTypeSliceFloatWithMarshal, "[]float json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceBool, "[]bool"),
 | 
						||
		getDataTypeDesc(DataTypeSliceBoolWithChar, "[]bool 按照指定字符切割"),
 | 
						||
		getDataTypeDesc(DataTypeSliceBoolWithMarshal, "[]bool json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceSlice, "[][]any"),
 | 
						||
		getDataTypeDesc(DataTypeSliceSliceWithMarshal, "[][]any json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceMapStringAny, "[][]map[string]any"),
 | 
						||
		getDataTypeDesc(DataTypeSliceMapStringAnyWithMarshal, "[][]map[string]any json序列化之后的结果"),
 | 
						||
		getDataTypeDesc(DataTypeSliceMapAnyAny, "[]map[any]any"),
 | 
						||
		getDataTypeDesc(DataTypeSliceMapAnyAnyWithMarshal, "[]map[any]any json序列化之后的结果"),
 | 
						||
 | 
						||
		// 基础类型的指针类型
 | 
						||
		getDataTypeDesc(DataTypeStringPtr, "*string, 字符串指针"),
 | 
						||
		getDataTypeDesc(DataTypeUintPtr, "*uint, uint指针"),
 | 
						||
		getDataTypeDesc(DataTypeUintPtr, "*uint8, uint8指针"),
 | 
						||
		getDataTypeDesc(DataTypeUintPtr, "*uint16, uint16指针"),
 | 
						||
		getDataTypeDesc(DataTypeUintPtr, "*uint32, uint32指针"),
 | 
						||
		getDataTypeDesc(DataTypeUintPtr, "*uint64, uint64指针"),
 | 
						||
		getDataTypeDesc(DataTypeIntPtr, "*int, int指针"),
 | 
						||
		getDataTypeDesc(DataTypeIntPtr, "*int8, int8指针"),
 | 
						||
		getDataTypeDesc(DataTypeIntPtr, "*int16, int16指针"),
 | 
						||
		getDataTypeDesc(DataTypeIntPtr, "*int32, int32指针"),
 | 
						||
		getDataTypeDesc(DataTypeIntPtr, "*int64, int64指针"),
 | 
						||
		getDataTypeDesc(DataTypeFloat32Ptr, "*float32, float32指针"),
 | 
						||
		getDataTypeDesc(DataTypeFloat32Ptr, "*float64, float64指针"),
 | 
						||
		getDataTypeDesc(DataTypeBoolPtr, "*bool, 字符串指针"),
 | 
						||
 | 
						||
		getDataTypeDesc(DataTypeTime, "time.Time, 时间类型"),
 | 
						||
		getDataTypeDesc(DataTypeJson, "json, json数据结构, 特殊的字符串"),
 | 
						||
	}
 | 
						||
)
 | 
						||
 | 
						||
// getDataTypeDesc ...
 | 
						||
//
 | 
						||
// Author : go_developer@163.com<白茶清欢>
 | 
						||
//
 | 
						||
// Date : 13:24 2024/6/23
 | 
						||
func getDataTypeDesc(value DataType, description string) DataTypeDesc {
 | 
						||
	return DataTypeDesc{
 | 
						||
		Value:       value,
 | 
						||
		Description: description,
 | 
						||
	}
 | 
						||
}
 | 
						||
 | 
						||
var (
 | 
						||
	// DataTypeBaseNumber 基础的int类型
 | 
						||
	DataTypeBaseNumber = []DataType{
 | 
						||
		DataTypeInt, DataTypeInt8, DataTypeInt16, DataTypeInt32, DataTypeInt64,
 | 
						||
		DataTypeUint, DataTypeUint8, DataTypeUint16, DataTypeUint32, DataTypeUint64,
 | 
						||
		DataTypeFloat32, DataTypeFloat64,
 | 
						||
		DataTypeIntPtr, DataTypeInt8Ptr, DataTypeInt16Ptr, DataTypeInt32Ptr, DataTypeInt64Ptr,
 | 
						||
		DataTypeUintPtr, DataTypeUint8Ptr, DataTypeUint16Ptr, DataTypeUint32Ptr, DataTypeUint64Ptr,
 | 
						||
		DataTypeFloat32Ptr, DataTypeFloat64Ptr,
 | 
						||
	}
 | 
						||
	DataTypeBaseInt = []DataType{
 | 
						||
		DataTypeInt, DataTypeInt8, DataTypeInt16, DataTypeInt32, DataTypeInt64,
 | 
						||
		DataTypeIntPtr, DataTypeInt8Ptr, DataTypeInt16Ptr, DataTypeInt32Ptr, DataTypeInt64Ptr,
 | 
						||
	}
 | 
						||
	DataTypeBaseUint = []DataType{
 | 
						||
		DataTypeUint, DataTypeUint8, DataTypeUint16, DataTypeUint32, DataTypeUint64,
 | 
						||
		DataTypeUintPtr, DataTypeUint8Ptr, DataTypeUint16Ptr, DataTypeUint32Ptr, DataTypeUint64Ptr,
 | 
						||
	}
 | 
						||
	DataTypeBaseFloat    = []DataType{DataTypeFloat32, DataTypeFloat64, DataTypeFloat32Ptr, DataTypeFloat64Ptr}
 | 
						||
	DataTypeBaseString   = []DataType{DataTypeString, DataTypeStringPtr}
 | 
						||
	DataTypeBaseBool     = []DataType{DataTypeBool, DataTypeBoolPtr}
 | 
						||
	DataTypeSliceMarshal = []DataType{
 | 
						||
		DataTypeSliceAnyWithMarshal,
 | 
						||
		DataTypeSliceIntWithMarshal,
 | 
						||
		DataTypeSliceUintWithMarshal,
 | 
						||
		DataTypeSliceFloatWithMarshal,
 | 
						||
		DataTypeSliceBoolWithMarshal,
 | 
						||
		DataTypeSliceMapAnyAnyWithMarshal,
 | 
						||
		DataTypeSliceMapStringAnyWithMarshal,
 | 
						||
		DataTypeSliceAnyWithMarshal,
 | 
						||
		DataTypeSliceSliceWithMarshal,
 | 
						||
	}
 | 
						||
	DataTypeSliceSplit = []DataType{
 | 
						||
		DataTypeSliceIntWithChar,
 | 
						||
		DataTypeSliceUintWithChar,
 | 
						||
		DataTypeSliceFloatWithChar,
 | 
						||
		DataTypeSliceBoolWithChar,
 | 
						||
		DataTypeSliceStringWithChar,
 | 
						||
	}
 | 
						||
	DataTypeSlice = []DataType{
 | 
						||
		DataTypeSliceString,
 | 
						||
		DataTypeSliceAny,
 | 
						||
		DataTypeSliceBool,
 | 
						||
		DataTypeSliceMapStringAny,
 | 
						||
		DataTypeSliceInt,
 | 
						||
		DataTypeSliceUint,
 | 
						||
		DataTypeSliceFloat,
 | 
						||
		DataTypeSliceMapAnyAny,
 | 
						||
		DataTypeSliceSlice,
 | 
						||
	}
 | 
						||
	DataTypeMap = []DataType{
 | 
						||
		DataTypeMapStrAny,
 | 
						||
		DataTypeMapAnyAny,
 | 
						||
		DataTypeMapStrBool,
 | 
						||
		DataTypeMapStrInt,
 | 
						||
		DataTypeMapStrFloat,
 | 
						||
		DataTypeMapStrUint,
 | 
						||
		DataTypeMapStrSlice,
 | 
						||
		DataTypeMapStrStr,
 | 
						||
	}
 | 
						||
	DataTypeMapMarshal = []DataType{
 | 
						||
		DataTypeMapStrAnyWithMarshal,
 | 
						||
		DataTypeMapAnyAnyWithMarshal,
 | 
						||
		DataTypeMapStrBoolWithMarshal,
 | 
						||
		DataTypeMapStrIntWithMarshal,
 | 
						||
		DataTypeMapStrFloatWithMarshal,
 | 
						||
		DataTypeMapStrUintWithMarshal,
 | 
						||
		DataTypeMapStrSliceWithMarshal,
 | 
						||
		DataTypeMapStrStrWithMarshal,
 | 
						||
	}
 | 
						||
)
 | 
						||
 | 
						||
func getMergeDataTypeList(dataTypeList ...[]DataType) []DataType {
 | 
						||
	var res []DataType
 | 
						||
	for _, dataTypeItemList := range dataTypeList {
 | 
						||
		res = append(res, dataTypeItemList...)
 | 
						||
	}
 | 
						||
	return res
 | 
						||
}
 | 
						||
 | 
						||
// GetDataTypeDefaultValue 获取不同类型的默认值
 | 
						||
func GetDataTypeDefaultValue(dataType DataType) any {
 | 
						||
	switch dataType {
 | 
						||
	case DataTypeInt:
 | 
						||
		return int(0)
 | 
						||
	case DataTypeInt8:
 | 
						||
		return int8(0)
 | 
						||
	case DataTypeInt16:
 | 
						||
		return int16(0)
 | 
						||
	case DataTypeInt32:
 | 
						||
		return int32(0)
 | 
						||
	case DataTypeInt64:
 | 
						||
		return int64(0)
 | 
						||
	case DataTypeUint:
 | 
						||
		return uint(0)
 | 
						||
	case DataTypeUint8:
 | 
						||
		return uint8(0)
 | 
						||
	case DataTypeUint16:
 | 
						||
		return uint16(0)
 | 
						||
	case DataTypeUint32:
 | 
						||
		return uint32(0)
 | 
						||
	case DataTypeUint64:
 | 
						||
		return uint64(0)
 | 
						||
	case DataTypeFloat32:
 | 
						||
		return float32(0)
 | 
						||
	case DataTypeFloat64:
 | 
						||
		return float64(0)
 | 
						||
	case DataTypeBool:
 | 
						||
		return false
 | 
						||
	case DataTypeString:
 | 
						||
		return ""
 | 
						||
	case DataTypeIntPtr:
 | 
						||
		return new(int)
 | 
						||
	case DataTypeInt8Ptr:
 | 
						||
		return new(int8)
 | 
						||
	case DataTypeInt16Ptr:
 | 
						||
		return new(int16)
 | 
						||
	case DataTypeInt32Ptr:
 | 
						||
		return new(int32)
 | 
						||
	case DataTypeInt64Ptr:
 | 
						||
		return new(int64)
 | 
						||
	case DataTypeUintPtr:
 | 
						||
		return new(uint)
 | 
						||
	case DataTypeUint8Ptr:
 | 
						||
		return new(uint8)
 | 
						||
	case DataTypeUint16Ptr:
 | 
						||
		return new(uint16)
 | 
						||
	case DataTypeUint32Ptr:
 | 
						||
		return new(uint32)
 | 
						||
	case DataTypeUint64Ptr:
 | 
						||
		return new(uint64)
 | 
						||
	case DataTypeFloat32Ptr:
 | 
						||
		return new(float32)
 | 
						||
	case DataTypeFloat64Ptr:
 | 
						||
		return new(float64)
 | 
						||
	case DataTypeBoolPtr:
 | 
						||
		return new(bool)
 | 
						||
	case DataTypeMapStrAny:
 | 
						||
		return map[string]any{}
 | 
						||
	case DataTypeMapAnyAny:
 | 
						||
		return map[any]any{}
 | 
						||
	case DataTypeMapStrBool:
 | 
						||
		return map[string]bool{}
 | 
						||
	case DataTypeMapStrInt:
 | 
						||
		return map[string]int{}
 | 
						||
	case DataTypeMapStrFloat:
 | 
						||
		return map[string]float64{}
 | 
						||
	case DataTypeMapStrUint:
 | 
						||
		return map[string]uint{}
 | 
						||
	case DataTypeMapStrSlice:
 | 
						||
		return map[string][]any{}
 | 
						||
	case DataTypeMapStrStr:
 | 
						||
		return map[string]string{}
 | 
						||
	case DataTypeSliceAny:
 | 
						||
		return []any{}
 | 
						||
	case DataTypeSliceString:
 | 
						||
		return []string{}
 | 
						||
	case DataTypeSliceBool:
 | 
						||
		return []bool{}
 | 
						||
	case DataTypeSliceInt:
 | 
						||
		return []int{}
 | 
						||
	case DataTypeSliceUint:
 | 
						||
		return []uint{}
 | 
						||
	case DataTypeSliceFloat:
 | 
						||
		return []float64{}
 | 
						||
	case DataTypeSliceMapAnyAny:
 | 
						||
		// map[any]any 序列化会有问题,当做 map[string]any 处理
 | 
						||
		return []map[string]any{}
 | 
						||
	case DataTypeSliceMapStringAny:
 | 
						||
		return []map[string]any{}
 | 
						||
	case DataTypeTime:
 | 
						||
		return time.Now() // 时间类型的默认值
 | 
						||
	case DataTypeJson: // json类型默认值
 | 
						||
		return "{}"
 | 
						||
	default:
 | 
						||
		// 序列化之后的map
 | 
						||
		for _, dataTypeItem := range DataTypeMapMarshal {
 | 
						||
			if dataTypeItem == dataType {
 | 
						||
				return "{}"
 | 
						||
			}
 | 
						||
		}
 | 
						||
		// 序列化之后的slice
 | 
						||
		for _, dataTypeItem := range DataTypeSliceMarshal {
 | 
						||
			if dataTypeItem == dataType {
 | 
						||
				return "[]"
 | 
						||
			}
 | 
						||
		}
 | 
						||
		// 指定分隔符分割的slice
 | 
						||
		for _, dataTypeItem := range DataTypeSliceSplit {
 | 
						||
			if dataTypeItem == dataType {
 | 
						||
				return ""
 | 
						||
			}
 | 
						||
		}
 | 
						||
		// 未枚举的slice类型用any接收
 | 
						||
		for _, dataTypeItem := range DataTypeSlice {
 | 
						||
			if dataTypeItem == dataType {
 | 
						||
				return []any{}
 | 
						||
			}
 | 
						||
		}
 | 
						||
	}
 | 
						||
	// 未枚举的一律用any接收
 | 
						||
	return *new(any)
 | 
						||
}
 |