[fix] 移除类型转换 ToValue

This commit is contained in:
what 2023-07-31 20:48:24 +08:00
parent 3f9461d2de
commit cd4e1b4789

View File

@ -1,7 +1,6 @@
package base package base
import ( import (
"encoding/json"
"fmt" "fmt"
"reflect" "reflect"
"strconv" "strconv"
@ -117,17 +116,17 @@ func (this ResField) ToValue(v any) any {
case contracts.ResDataType_Json: case contracts.ResDataType_Json:
if v == nil { if v == nil {
if this.Default != "" && this.Default[0:1] == "[" { if this.Default != "" && this.Default[0:1] == "[" {
return "[]" return db.Raw("'[]'")
} else if this.Default != "" && this.Default[0:1] == "{" { } else if this.Default != "" && this.Default[0:1] == "{" {
return "{}" return db.Raw("'{}'")
} else if this.Default == "" { } else if this.Default == "" {
return "{}" return db.Raw("'{}'")
} }
return this.Default return this.Default
} }
b, _ := json.Marshal(v)
return string(b) return v
} }
return strings.Trim(cast.ToString(v), " ") return strings.Trim(cast.ToString(v), " ")