From a8717e5e3ace4dd226547faae9c3a44616bbf6f0 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 2 Oct 2017 00:52:35 +0800 Subject: Use AfterLoad instead of AfterSet on Structs (#2628) * use AfterLoad instead of AfterSet on Structs * fix the comments on AfterLoad * fix the comments on action AfterLoad --- models/status.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'models/status.go') diff --git a/models/status.go b/models/status.go index d0c4a08744..e2e8adb77b 100644 --- a/models/status.go +++ b/models/status.go @@ -71,15 +71,11 @@ type CommitStatus struct { UpdatedUnix int64 `xorm:"INDEX updated"` } -// AfterSet is invoked from XORM after setting the value of a field of +// AfterLoad is invoked from XORM after setting the value of a field of // this object. -func (status *CommitStatus) AfterSet(colName string, _ xorm.Cell) { - switch colName { - case "created_unix": - status.Created = time.Unix(status.CreatedUnix, 0).Local() - case "updated_unix": - status.Updated = time.Unix(status.UpdatedUnix, 0).Local() - } +func (status *CommitStatus) AfterLoad() { + status.Created = time.Unix(status.CreatedUnix, 0).Local() + status.Updated = time.Unix(status.UpdatedUnix, 0).Local() } func (status *CommitStatus) loadRepo(e Engine) (err error) { -- cgit v1.2.3