Skip to content

Commit

Permalink
[Add] xiang.table.Find query DSL support
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Apr 13, 2022
1 parent 486fd70 commit 8bd280b
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion flow/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
6 changes: 5 additions & 1 deletion table/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
39 changes: 39 additions & 0 deletions tests/apis/demo.http.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
61 changes: 61 additions & 0 deletions tests/flows/demo/admin.flow.json
Original file line number Diff line number Diff line change
@@ -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}}"
}
}
13 changes: 13 additions & 0 deletions tests/flows/demo/token.flow.json
Original file line number Diff line number Diff line change
@@ -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}}"
}

0 comments on commit 8bd280b

Please sign in to comment.