-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback_delete.go
More file actions
executable file
·45 lines (36 loc) · 868 Bytes
/
callback_delete.go
File metadata and controls
executable file
·45 lines (36 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package huh
import (
"context"
)
var DestroyCallback *Callback
func init() {
DestroyCallback = DefaultCallback.Destroy()
DestroyCallback.Processor.Register(BeforeDestroyHandler)
DestroyCallback.Processor.Register(DestroyHandler)
DestroyCallback.Processor.Register(AfterDestroyHandler)
}
func BeforeDestroyHandler(ctx context.Context, o *Orm) (*Orm, error) {
err := o.CallMethod("BeforeDestroy")
return o, err
}
func DestroyHandler(ctx context.Context, o *Orm) (*Orm, error) {
o, err := o.ParseStatement()
if err != nil {
return o, err
}
if !o.do {
return o, nil
}
err = o.Exec(o.String())
if err != nil {
return o, ErrInvalidSQL
}
return o, nil
}
func AfterDestroyHandler(ctx context.Context, o *Orm) (*Orm, error) {
err := o.CallMethod("AfterDestroy")
return o, err
}
type DestroyCallbackProcessor struct {
CommonCallbackProcessor
}