From 3f5aa5f14c56e55a05902c7e3b9b112eb23ee80d Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期三, 03 一月 2024 17:27:04 +0800 Subject: [PATCH] 采购类型修改 --- global/model.go | 30 ++++++++++++++++++++++++------ 1 files changed, 24 insertions(+), 6 deletions(-) diff --git a/global/model.go b/global/model.go index b4594ee..7bc5230 100644 --- a/global/model.go +++ b/global/model.go @@ -7,17 +7,35 @@ ) type GVA_MODEL struct { - ID uint `gorm:"primarykey"` // 涓婚敭ID - CreatedAt *time.Time `json:"-"` // 鍒涘缓鏃堕棿 - UpdatedAt *time.Time `json:"-"` // 鏇存柊鏃堕棿 - DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 鍒犻櫎鏃堕棿 + ID uint `json:"id" gorm:"primarykey"` // 涓婚敭ID + CreatedAt *time.Time `json:"-"` // 鍒涘缓鏃堕棿 + UpdatedAt *time.Time `json:"-"` // 鏇存柊鏃堕棿 + DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 鍒犻櫎鏃堕棿 FormattedCreatedAt string `gorm:"-" json:"created_at"` FormattedUpdatedAt string `gorm:"-" json:"updated_at"` } 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 } + +type GVA_MODEL_INT struct { + ID uint `json:"id,string" gorm:"primarykey"` // 涓婚敭ID + CreatedAt *time.Time `json:"-"` // 鍒涘缓鏃堕棿 + UpdatedAt *time.Time `json:"-"` // 鏇存柊鏃堕棿 + DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 鍒犻櫎鏃堕棿 + + FormattedCreatedAt string `gorm:"-" json:"created_at"` + FormattedUpdatedAt string `gorm:"-" json:"updated_at"` +} -- Gitblit v1.8.0