mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 08:07:06 +08:00
大量更改,主要是int,float类型支持null、字符串
This commit is contained in:
@@ -13,29 +13,29 @@ type NullFloat struct {
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func EncodeFloat(value any) any {
|
||||
switch v := value.(type) {
|
||||
case map[string]any:
|
||||
if v["Float"] != nil {
|
||||
val := v["Float"]
|
||||
switch f := val.(type) {
|
||||
case *float32:
|
||||
return float64(*f)
|
||||
case *float64:
|
||||
return *f
|
||||
case *int:
|
||||
return float64(*f)
|
||||
case *int64:
|
||||
return float64(*f)
|
||||
case *string:
|
||||
return *f
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// func EncodeFloat(value any) any {
|
||||
// switch v := value.(type) {
|
||||
// case map[string]any:
|
||||
// if v["Float"] != nil {
|
||||
// val := v["Float"]
|
||||
// switch f := val.(type) {
|
||||
// case *float32:
|
||||
// return float64(*f)
|
||||
// case *float64:
|
||||
// return *f
|
||||
// case *int:
|
||||
// return float64(*f)
|
||||
// case *int64:
|
||||
// return float64(*f)
|
||||
// case *string:
|
||||
// return *f
|
||||
// default:
|
||||
// return nil
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func DecodeFloat(value any) (any, error) {
|
||||
switch v := value.(type) {
|
||||
|
Reference in New Issue
Block a user