(tx *gorm.DB)
| 29 | } |
| 30 | |
| 31 | func (s *Product) BeforeCreate(tx *gorm.DB) (err error) { |
| 32 | if s.Code == "Invalid" { |
| 33 | err = errors.New("invalid product") |
| 34 | } |
| 35 | s.BeforeCreateCallTimes = s.BeforeCreateCallTimes + 1 |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | func (s *Product) BeforeUpdate(tx *gorm.DB) (err error) { |
| 40 | if s.Code == "dont_update" { |