修正log记录,数据库自动更新

This commit is contained in:
2023-06-13 11:26:23 +08:00
parent 91e3d72873
commit 708873087f
3 changed files with 24 additions and 49 deletions
+7
View File
@@ -79,3 +79,10 @@ func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
return nil
}
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}