afterhook with payload
This commit is contained in:
parent
cb49dc3654
commit
b9e8f972ce
2 changed files with 11 additions and 10 deletions
|
|
@ -59,7 +59,7 @@ func ProcessSearch(process *gou.Process) interface{} {
|
|||
response := gou.NewProcess(api.Process, param, page, pagesize).Run()
|
||||
|
||||
// After Hook
|
||||
return table.After(table.Hooks.AfterSearch, response, process.Sid)
|
||||
return table.After(table.Hooks.AfterSearch, response, []interface{}{param, page, pagesize}, process.Sid)
|
||||
}
|
||||
|
||||
// ProcessFind xiang.table.Find
|
||||
|
|
@ -86,7 +86,7 @@ func ProcessFind(process *gou.Process) interface{} {
|
|||
response := gou.NewProcess(api.Process, id, param).Run()
|
||||
|
||||
// After Hook
|
||||
return table.After(table.Hooks.AfterFind, response, process.Sid)
|
||||
return table.After(table.Hooks.AfterFind, response, []interface{}{id, param}, process.Sid)
|
||||
}
|
||||
|
||||
// ProcessSave xiang.table.Save
|
||||
|
|
@ -98,9 +98,9 @@ func ProcessSave(process *gou.Process) interface{} {
|
|||
name := process.ArgsString(0)
|
||||
table := Select(name)
|
||||
api := table.APIs["save"].ValidateLoop("xiang.table.save")
|
||||
if process.NumOfArgsIs(3) && api.IsAllow(process.Args[2]) {
|
||||
return nil
|
||||
}
|
||||
// if process.NumOfArgsIs(3) && api.IsAllow(process.Args[2]) {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
// Before Hook
|
||||
process.Args = table.Before(table.Hooks.BeforeSave, process.Args, process.Sid)
|
||||
|
|
@ -112,7 +112,7 @@ func ProcessSave(process *gou.Process) interface{} {
|
|||
response := gou.NewProcess(api.Process, process.Args[1]).Run()
|
||||
|
||||
// After Hook
|
||||
return table.After(table.Hooks.AfterSave, response, process.Sid)
|
||||
return table.After(table.Hooks.AfterSave, response, []interface{}{process.Args[1]}, process.Sid)
|
||||
}
|
||||
|
||||
// ProcessDelete xiang.table.Delete
|
||||
|
|
@ -328,5 +328,5 @@ func ProcessSelect(process *gou.Process) interface{} {
|
|||
response := gou.NewProcess(api.Process, process.Args[1:]...).Run()
|
||||
|
||||
// After Hook
|
||||
return table.After(table.Hooks.AfterSelect, response, process.Sid)
|
||||
return table.After(table.Hooks.AfterSelect, response, process.Args[1:], process.Sid)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,13 +177,14 @@ func (table *Table) Before(process string, processArgs []interface{}, sid string
|
|||
}
|
||||
|
||||
// After 运行 After hook
|
||||
func (table *Table) After(process string, data interface{}, sid string) interface{} {
|
||||
func (table *Table) After(process string, data interface{}, args []interface{}, sid string) interface{} {
|
||||
if process == "" {
|
||||
return data
|
||||
}
|
||||
response, err := gou.NewProcess(process, data).WithSID(sid).Exec()
|
||||
args = append([]interface{}{data}, args...)
|
||||
response, err := gou.NewProcess(process, args...).WithSID(sid).Exec()
|
||||
if err != nil {
|
||||
xlog.Println("Hook执行失败: ", err.Error(), maps.StrAny{"process": process, "data": data})
|
||||
xlog.Println("Hook执行失败: ", err.Error(), maps.StrAny{"process": process, "args": args})
|
||||
return data
|
||||
}
|
||||
return response
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue