2024-04-08 16:35:10 +08:00
|
|
|
|
// Package consts ...
|
|
|
|
|
//
|
|
|
|
|
// Description : consts ...
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 2024-04-08 16:33
|
|
|
|
|
package consts
|
|
|
|
|
|
2024-11-25 14:51:14 +08:00
|
|
|
|
// 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 {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
2024-11-25 14:13:50 +08:00
|
|
|
|
|
2024-04-08 16:35:10 +08:00
|
|
|
|
const (
|
2024-11-25 14:51:14 +08:00
|
|
|
|
DataTypeUnknown DataType = "unknown" // 位置数据类型
|
|
|
|
|
DataTypeNil DataType = "nil" // nil
|
|
|
|
|
DataTypePtr DataType = "ptr" // 指针
|
|
|
|
|
DataTypeInt DataType = "int" // int类型 -> int64
|
|
|
|
|
DataTypeUint DataType = "uint" // uint类型 -> uint64
|
|
|
|
|
DataTypeFloat DataType = "float" // float类型 -> 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 = "[]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指针
|
|
|
|
|
DataTypeUintPtr DataType = "uint_ptr" // *uint64, uint64指针
|
|
|
|
|
DataTypeFloatPtr DataType = "float_ptr" // *float64, float64指针
|
|
|
|
|
DataTypeBoolPtr DataType = "bool_ptr" // *bool, 字符串指针
|
2024-04-08 16:35:10 +08:00
|
|
|
|
)
|
2024-04-29 13:57:35 +08:00
|
|
|
|
|
|
|
|
|
const (
|
2024-04-29 16:02:51 +08:00
|
|
|
|
DataStatusNotFound = "NOT_FOUND"
|
|
|
|
|
DataStatusIsNil = "IS_NIL"
|
|
|
|
|
DataStatusIsZero = "IS_ZERO"
|
|
|
|
|
DataStatusIsEmpty = "IS_EMPTY"
|
|
|
|
|
DataStatusIsFalse = "IS_FALSE"
|
2024-04-29 13:57:35 +08:00
|
|
|
|
)
|
2024-04-30 21:51:09 +08:00
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
DataSliceModelReal = "REAL"
|
|
|
|
|
DataSliceModelMarshal = "MARSHAL"
|
|
|
|
|
DataSliceModelWithSplitChar = "WITH_SPLIT_CHAR"
|
|
|
|
|
)
|
2024-06-23 11:12:47 +08:00
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
DataMapModelReal = "REAL"
|
|
|
|
|
DataMapModelMarshal = "MARSHAL"
|
|
|
|
|
)
|
2024-06-23 13:51:43 +08:00
|
|
|
|
|
|
|
|
|
// DataTypeDesc 数据类型描述
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 13:22 2024/6/23
|
|
|
|
|
type DataTypeDesc struct {
|
2024-11-25 14:51:14 +08:00
|
|
|
|
Value DataType `json:"value"` // 具体数据类型
|
|
|
|
|
Description string `json:"description"` // 数据类型描述
|
2024-06-23 13:51:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
DataTypeList = []DataTypeDesc{
|
|
|
|
|
// 基础数据类型
|
|
|
|
|
getDataTypeDesc(DataTypeAny, "任意数据类型"),
|
|
|
|
|
getDataTypeDesc(DataTypeInt, "int类型 -> int64"),
|
|
|
|
|
getDataTypeDesc(DataTypeUint, "uint类型 -> uint64"),
|
|
|
|
|
getDataTypeDesc(DataTypeFloat, "float类型 -> 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序列化之后的结果"),
|
2024-07-09 21:41:22 +08:00
|
|
|
|
|
|
|
|
|
// 基础类型的指针类型
|
|
|
|
|
getDataTypeDesc(DataTypeStringPtr, "*string, 字符串指针"),
|
|
|
|
|
getDataTypeDesc(DataTypeUintPtr, "*int64, int64指针"),
|
|
|
|
|
getDataTypeDesc(DataTypeIntPtr, "*int64, *uint64, uint64指针"),
|
|
|
|
|
getDataTypeDesc(DataTypeFloatPtr, "*float64, float64指针"),
|
|
|
|
|
getDataTypeDesc(DataTypeBoolPtr, "*bool, 字符串指针"),
|
2024-06-23 13:51:43 +08:00
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// getDataTypeDesc ...
|
|
|
|
|
//
|
|
|
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
|
|
|
//
|
|
|
|
|
// Date : 13:24 2024/6/23
|
2024-11-25 14:51:14 +08:00
|
|
|
|
func getDataTypeDesc(value DataType, description string) DataTypeDesc {
|
2024-06-23 13:51:43 +08:00
|
|
|
|
return DataTypeDesc{
|
|
|
|
|
Value: value,
|
|
|
|
|
Description: description,
|
|
|
|
|
}
|
|
|
|
|
}
|