+ find
This commit is contained in:
parent
9686dd142e
commit
914b230847
2 changed files with 31 additions and 0 deletions
|
|
@ -43,3 +43,16 @@ func TestProcessSearch(t *testing.T) {
|
|||
assert.Equal(t, 1, res.Get("page"))
|
||||
assert.Equal(t, 2, res.Get("pagesize"))
|
||||
}
|
||||
|
||||
func TestProcessFind(t *testing.T) {
|
||||
args := []interface{}{
|
||||
"service",
|
||||
1,
|
||||
&gin.Context{},
|
||||
}
|
||||
process := gou.NewProcess("xiang.table.Find", args...)
|
||||
response := table.ProcessFind(process)
|
||||
assert.NotNil(t, response)
|
||||
res := any.Of(response).Map()
|
||||
assert.Equal(t, any.Of(res.Get("id")).CInt(), 1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
func init() {
|
||||
// 注册处理器
|
||||
gou.RegisterProcessHandler("xiang.table.Search", ProcessSearch)
|
||||
gou.RegisterProcessHandler("xiang.table.Find", ProcessFind)
|
||||
}
|
||||
|
||||
// ProcessSearch xiang.table.Search
|
||||
|
|
@ -28,3 +29,20 @@ func ProcessSearch(process *gou.Process) interface{} {
|
|||
|
||||
return gou.NewProcess(api.Process, param, page, pagesize).Run()
|
||||
}
|
||||
|
||||
// ProcessFind xiang.table.Find
|
||||
// 按主键值查询单条数据, 请求成功返回对应主键的数据记录
|
||||
func ProcessFind(process *gou.Process) interface{} {
|
||||
process.ValidateArgNums(2)
|
||||
name := process.ArgsString(0)
|
||||
table := Select(name)
|
||||
api := table.APIs["find"].ValidateLoop("xiang.table.find")
|
||||
if process.NumOfArgsIs(3) && api.IsAllow(process.Args[2]) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 参数表
|
||||
id := process.Args[1]
|
||||
param := api.MergeDefaultQueryParam(gou.QueryParam{}, 1)
|
||||
return gou.NewProcess(api.Process, id, param).Run()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue