[Add] xiang.table.Find query DSL support

This commit is contained in:
Max 2022-04-14 07:47:20 +08:00
parent 486fd702c0
commit 8bd280bb6b
6 changed files with 120 additions and 3 deletions

View file

@ -27,6 +27,6 @@ func check(t *testing.T) {
wskeys = append(wskeys, key)
}
assert.Equal(t, 4, len(keys))
assert.Equal(t, 5, len(keys))
assert.Equal(t, 1, len(wskeys))
}

View file

@ -20,5 +20,5 @@ func check(t *testing.T) {
for key := range gou.Flows {
keys = append(keys, key)
}
assert.Equal(t, 24, len(keys))
assert.Equal(t, 26, len(keys))
}

View file

@ -75,7 +75,11 @@ func ProcessFind(process *gou.Process) interface{} {
// 参数表
process.ValidateArgNums(2)
id := process.Args[1]
param := api.MergeDefaultQueryParam(gou.QueryParam{}, 2, process.Sid)
queryParam := gou.QueryParam{}
if process.NumOfArgs() == 3 {
queryParam = process.ArgsQueryParams(2)
}
param := api.MergeDefaultQueryParam(queryParam, 1, process.Sid)
// 查询数据
response := gou.NewProcess(api.Process, id, param).

39
tests/apis/demo.http.json Normal file
View file

@ -0,0 +1,39 @@
{
"name": "Demo",
"version": "1.0.0",
"description": "demo",
"group": "demo",
"guard": "-",
"paths": [
{
"path": "/user",
"method": "GET",
"process": "flows.demo.user",
"in": ["$query.id"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/admin",
"method": "GET",
"process": "flows.demo.admin",
"in": ["$query.id"],
"out": {
"status": 200,
"type": "application/json"
}
},
{
"path": "/token",
"method": "GET",
"process": "flows.demo.token",
"in": ["$query.id"],
"out": {
"status": 200,
"type": "application/json"
}
}
]
}

View file

@ -0,0 +1,61 @@
{
"label": "Auto Login",
"version": "1.0.0",
"description": "Auto Login for demo",
"nodes": [
{
"name": "User",
"process": "models.xiang.user.Get",
"args": [
{
"select": ["id", "email", "name", "type"],
"wheres": [{ "column": "id", "value": 1 }],
"limit": 1
}
]
},
{
"name": "Menu",
"process": "flows.xiang.menu",
"args": ["{{$res.User.0.id}}"]
},
{
"name": "SID",
"process": "session.start"
},
{
"name": "JWT",
"process": "xiang.helper.JWTMake",
"args": [
"{{$res.User.0.id}}",
{},
{
"timeout": 3600,
"sid": "{{$res.SID}}"
}
]
},
{
"name": "Set User",
"process": "session.set",
"args": ["user", "{{$res.User.0}}"]
},
{
"name": "Set issuer",
"process": "session.set",
"args": ["issuer", "xiang"]
},
{
"name": "Set User ID",
"process": "session.set",
"args": ["user_id", "{{$res.User.0.id}}"]
}
],
"output": {
"sid": "{{$res.SID}}",
"user": "{{$res.User.0}}",
"menus": "{{$res.Menu}}",
"token": "{{$res.JWT.token}}",
"expires_at": "{{$res.JWT.expires_at}}"
}
}

View file

@ -0,0 +1,13 @@
{
"label": "Auto Login",
"version": "1.0.0",
"description": "Auto Login for demo",
"nodes": [
{
"name": "User",
"process": "flows.demo.admin",
"args": []
}
],
"output": "{{$res.User.token}}"
}