mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-27 18:10:32 +08:00
大量更改,主要是int,float类型支持null、字符串
This commit is contained in:
@@ -13,26 +13,32 @@ type NullInt struct {
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func EncodeInt(value any) any {
|
||||
switch v := value.(type) {
|
||||
case map[string]any:
|
||||
if v["Int"] != nil {
|
||||
val := v["Int"]
|
||||
switch i := val.(type) {
|
||||
case *int:
|
||||
return *i
|
||||
case *int64:
|
||||
return *i
|
||||
case *string:
|
||||
return *i
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
// return val
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// func EncodeInt(value any) any {
|
||||
// switch v := value.(type) {
|
||||
// case NullInt:
|
||||
// if v.Valid {
|
||||
// return *v.Int
|
||||
// } else {
|
||||
// return nil
|
||||
// }
|
||||
// case map[string]any:
|
||||
// if v["Int"] != nil {
|
||||
// val := v["Int"]
|
||||
// switch i := val.(type) {
|
||||
// case *int:
|
||||
// return *i
|
||||
// case *int64:
|
||||
// return *i
|
||||
// case *string:
|
||||
// return *i
|
||||
// default:
|
||||
// return nil
|
||||
// }
|
||||
// // return val
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
// }
|
||||
func DecodeInt(value any) (any, error) {
|
||||
switch v := value.(type) {
|
||||
case int:
|
||||
|
||||
Reference in New Issue
Block a user