From de4bcd1dead50b05f716bc5718be5540bdb96783 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期日, 28 四月 2024 17:23:29 +0800 Subject: [PATCH] fix --- global/model.go | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/global/model.go b/global/model.go index 9a3d5b1..7bc5230 100644 --- a/global/model.go +++ b/global/model.go @@ -17,8 +17,16 @@ } func (m *GVA_MODEL) AfterFind(tx *gorm.DB) (err error) { - m.FormattedCreatedAt = m.CreatedAt.Format("2006-01-02 15:04:05") - m.FormattedUpdatedAt = m.UpdatedAt.Format("2006-01-02 15:04:05") + if m.CreatedAt != nil { + m.FormattedCreatedAt = m.CreatedAt.Format("2006-01-02 15:04:05") + } else { + m.FormattedCreatedAt = "--" + } + if m.UpdatedAt != nil { + m.FormattedUpdatedAt = m.UpdatedAt.Format("2006-01-02 15:04:05") + m.FormattedUpdatedAt = "--" + } + return } -- Gitblit v1.8.0