feat: add history helper

master
Evan Chen 2021-12-16 23:58:02 +08:00
parent a5322f8d92
commit ae12649984
2 changed files with 20 additions and 7 deletions

View File

@ -25,3 +25,16 @@ func getBase() *History {
} }
return h 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
}

View File

@ -21,16 +21,16 @@ const (
type History struct { type History struct {
ID uint `gorm:"primaryKey"` ID uint `gorm:"primaryKey"`
CreatedAt time.Time CreatedAt time.Time
Module string Module string
Type string Type string
Message string
BodyJson string
Body interface{} `gorm:"-"`
Issuer string
Caller string Caller string
Trace string Trace string
Message string
Body interface{} `gorm:"-"`
Issuer string
BodyJson string
} }
func (h *History) BeforeCreate(tx *gorm.DB) (err error) { func (h *History) BeforeCreate(tx *gorm.DB) (err error) {