(tx *gorm.DB)
| 37 | } |
| 38 | |
| 39 | func (s *Product) BeforeUpdate(tx *gorm.DB) (err error) { |
| 40 | if s.Code == "dont_update" { |
| 41 | err = errors.New("can't update") |
| 42 | } |
| 43 | s.BeforeUpdateCallTimes = s.BeforeUpdateCallTimes + 1 |
| 44 | return |
| 45 | } |
| 46 | |
| 47 | func (s *Product) BeforeSave(tx *gorm.DB) (err error) { |
| 48 | if s.Code == "dont_save" { |