From ae126499840b9ac9d3a99bb3030f59000d97c83b Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Thu, 16 Dec 2021 23:58:02 +0800 Subject: [PATCH] feat: add history helper --- history/helper.go | 13 +++++++++++++ history/history.go | 14 +++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/history/helper.go b/history/helper.go index f1bf463..da97d2a 100644 --- a/history/helper.go +++ b/history/helper.go @@ -25,3 +25,16 @@ func getBase() *History { } return h } + +func (h *History) Msg(msg string) *History { + h.Message = msg + return h +} +func (h *History) Bd(body interface{}) *History { + h.Body = body + return h +} +func (h *History) Iss(issuer string) *History { + h.Issuer = issuer + return h +} diff --git a/history/history.go b/history/history.go index 0e06433..12205e8 100644 --- a/history/history.go +++ b/history/history.go @@ -21,16 +21,16 @@ const ( type History struct { ID uint `gorm:"primaryKey"` CreatedAt time.Time + Module string + Type string + Caller string + Trace string - Module string - Type string + Message string + Body interface{} `gorm:"-"` + Issuer string - Message string BodyJson string - Body interface{} `gorm:"-"` - Issuer string - Caller string - Trace string } func (h *History) BeforeCreate(tx *gorm.DB) (err error) {