[fix] 类型转换

This commit is contained in:
what 2023-07-30 18:52:59 +08:00
parent c7cfd1e6f7
commit 3f9461d2de

View File

@ -101,36 +101,6 @@ func (this ResField) GetQueryDataType() contracts.QueryDataType {
} }
func (this ResField) ToValue(v any) any { func (this ResField) ToValue(v any) any {
// 类型转换, 填补 cast 未知的类型
switch data := v.(type) {
case res_type.ResFieldByInteger:
v = int64(data)
case res_type.ResFieldByFloat:
v = float64(data)
case res_type.ResFieldByNumber:
v = float64(data)
case string:
v = strings.Trim(string(data), " ")
case []any, []string, []int, []float64, []float32, []int64:
if v != nil {
b, _ := json.Marshal(v)
return string(b)
}
v = data
case map[string]any, map[string]string, map[string]int:
if v != nil {
b, _ := json.Marshal(v)
return string(b)
}
v = data
default:
if v != nil {
b, _ := json.Marshal(v)
return string(b)
}
v = data
}
switch this.DataType { switch this.DataType {
case contracts.ResDataType_String, contracts.ResDataType_Text, contracts.ResDataType_Enum, case contracts.ResDataType_String, contracts.ResDataType_Text, contracts.ResDataType_Enum,
contracts.ResDataType_Timestamp, contracts.ResDataType_Date, contracts.ResDataType_Datetime: contracts.ResDataType_Timestamp, contracts.ResDataType_Date, contracts.ResDataType_Datetime: