From fe6ec94516b58a232a07784747aef6560b3870f6 Mon Sep 17 00:00:00 2001 From: xiangheng <11675084@qq.com> Date: Fri, 16 Aug 2024 12:33:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96null=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/null_int.go | 13 ++++++++++++- server/util/null_time.go | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/server/core/null_int.go b/server/core/null_int.go index 07b8b1f..6026067 100644 --- a/server/core/null_int.go +++ b/server/core/null_int.go @@ -17,7 +17,18 @@ func EncodeInt(value any) any { switch v := value.(type) { case map[string]any: if v["Int"] != nil { - return v["Int"] + val := v["Int"] + switch i := val.(type) { + case *int: + return *i + case *int64: + return *i + case *string: + return *i + default: + return "" + } + // return val } } return "" diff --git a/server/util/null_time.go b/server/util/null_time.go index bf3b703..455ca2f 100644 --- a/server/util/null_time.go +++ b/server/util/null_time.go @@ -27,10 +27,20 @@ func (t nullTimeUtil) EncodeTime(value any) any { var str = "" switch v := value.(type) { case map[string]interface{}: - tt := v["Time"] + val := v["Time"] + switch tt := val.(type) { + case *string: + ttt, _ := t.Parse(*tt) + str = ttt.String() + case *time.Time: + if tt != nil { + ttt, _ := t.Parse(*tt) + str = ttt.String() + } else { + str = "" + } + } - ttt, _ := t.Parse(tt) - str = ttt.String() } return str }