Skip to content

查询调用远程函数各种使用场景说明 #467

Open
@cloudAndMonkey

Description

@cloudAndMonkey

比如获取当前用户 函数, 示例代码已经有了
1、新增function
/***
* 获取当前用户id
* @param current
* @return
*/
public String getCurrentUserId(@NotNull JSONObject current) {
return FormVerifier.getVisitorId(getSession());
}
2、配置数据库function权限
image

3、GET调用远程函数

独立调用远程函数

{
"name": "jerry",
"aaa":"demoa",
"id()": "sayHello(name)"
}

获取当前用户id

{
"id()": "getCurrentUserId()"
}

# 简化版调用
{
"id@-()": "getCurrentUserId()",
"User": {
"id@": "/id"
},
"tag": "User",
"@Explain": true
}

查询引用

{
"func": {
"@name": "23",
"id()": "sayHello(@name)"
},
"User": {
"id@": "/func/id"
},
"tag": "User"
}

获取当前用户详细信息

{
"func": {
"id()": "getCurrentUserId()"
},
"User:data": {
"id@": "/func/id"
},
"tag": "User",
"@Explain": true
}

# 子查询引用(注意路径,/ 开头是查询 /sql@/xxx, func/xxx 从顶层查询)
{
"func": {
"@name": "23",
"id()": "sayHello(@name)"
},
"sql@": {
"with": true,
"from": "Sys_user_role",
"Sys_user_role": {
"@column": "role_id",
"user_id@": "func/id"
}
},
"Sys_role[]": {
"Sys_role": {
"id{}@": "sql"
},
"page": 0,
"count": 10
},
"@Explain": true
}

inner join引用

{
"@show_reponse": true,
//"@show_reponse_keys": "func,data",
//"@show_reponse_exclude_keys": "func,tag",
"id@-()": "getCurrentUserId()",
"User[]": {
"User": {
"@from@": {
"from": "User_address",
"join": "&/User/id@",
"User_address": {
"user_id@": "id",
"@column": "id:addr_id,user_id,addr"
},
"User": {
"id@": "/User_address/user_id",
"@column": "id,username"
}
}
}
},
"@Explain": true
}

分组引用

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions