Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我在使用getByTag发现无法查询到数据 #637

Closed
csx-bill opened this issue Nov 24, 2023 · 20 comments
Closed

我在使用getByTag发现无法查询到数据 #637

csx-bill opened this issue Nov 24, 2023 · 20 comments

Comments

@csx-bill
Copy link
Contributor

Description

我在使用getByTag发现无法查询到数据
request 表是有这个 tag 得
image

@TommyLemon
Copy link
Collaborator

发下具体的请求参数和响应结果

@csx-bill
Copy link
Contributor Author

请求参数
tag 在url 拼接的 SysUserPage

{
"SysUser[]":{
"SysUser":{
"status()": "translateDict(sys_user_status,status)"
},
"page":0,
"count":5,
"query":2
},
"info@":"/[]/info",
"format":true
}

响应参数
image

@TommyLemon
Copy link
Collaborator

TommyLemon commented Nov 25, 2023

@explain: true 看下返回的 SQL 或控制台看日志中执行的 SQL,放数据库执行看结果

@csx-bill
Copy link
Contributor Author

image

控制台 输出的日志

2023-11-25 12:22:46.558: AbstractParser.DEBUG: parseResponse startTime = 1700886166558<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser parentPath = null; name = null; table = null; alias = null
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser type = 0; isTable = false; isArrayMainTable = false
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser isEmpty = false; tri = false; drop = false
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser parentPath = ; name = SysUserPage; table = SysUserPage; alias = null
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser type = 0; isTable = true; isArrayMainTable = false
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: AbstractObjectParser isEmpty = false; tri = false; drop = false
2023-11-25 12:22:46.558: AbstractObjectParser.DEBUG: onParse target == null >> return true;
2023-11-25 12:22:46.558: AbstractObjectParser.ERROR: onParse isTable && (key.startsWith(@) == false || JSONRequest.TABLE_KEY_LIST.contains(key)) >> return null;
2023-11-25 12:22:46.558:

AbstractParser.DEBUG: <<<<<<<<<<<<<<<<<<<<<<< close >>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2023-11-25 12:22:46.558: AbstractParser.DEBUG: GET/parseResponse request =
{"SysUserPage":{"SysUser[]":{"SysUser":{"status()":"translateDict(sys_user_status,status)"},"page":0,"count":5,"query":2},"info@":"/[]/info","format":true,"@Explain":true}}

2023-11-25 12:22:46.558: AbstractParser.DEBUG: GET/parseResponse return response =
{"ok":true,"code":200,"msg":"success","debug:info|help":" \n提 bug 请发请求和响应的【完整截屏】,没图的自行解决! \n开发者有限的时间和精力主要放在【维护项目源码和文档】上! \n【描述不详细】 或 【文档/常见问题 已有答案】 的问题可能会被忽略!! \n【态度 不文明/不友善】的可能会被踢出群,问题也可能不予解答!!! \n\n 环境信息 \n系统: Windows 11 10.0 \n数据库: DEFAULT_DATABASE = MYSQL \nJDK: 21.0.1 amd64 \nAPIJSON: 6.2.1 \n \n【常见问题】:#36 \n【通用文档】:https://github.com/Tencent/APIJSON/blob/master/Document.md \n【视频教程】:https://search.bilibili.com/all?keyword=APIJSON\n 【警告】:[Reference]: SysUserPage/info@: []/info 引用赋值获取路径对应的值为 null!请检查路径是否错误!; ","time":1700886166558,"sql:generate|cache|execute|maxExecute":"0|0|0|200","depth:count|max":"1|6","time:start|duration|end|parse|sql":"1700886166558|0|1700886166558|0|0"}

2023-11-25 12:22:46.558: AbstractParser.DEBUG: GET/parseResponse endTime = 1700886166558; duration = 0

2023-11-25 12:22:46.558: AbstractParser.INFO:
getObject: parentPath = null;
name = null; request = {"SysUserPage":{"SysUser[]":{"SysUser":{"status()":"translateDict(sys_user_status,status)"},"page":0,"count":5,"query":2},"info@":"/[]/info","format":true,"@Explain":true}}
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath path = null; name = null <<<<<<<<<<<<<
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath return >>>>>>>>>>>>>>>>
2023-11-25 12:22:46.558: AbstractParser.INFO:
getObject: parentPath = ;
name = SysUserPage; request = {"SysUser[]":{"SysUser":{"status()":"translateDict(sys_user_status,status)"},"page":0,"count":5,"query":2},"info@":"/[]/info","format":true,"@Explain":true}
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath path = ; name = SysUserPage <<<<<<<<<<<<<
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath return SysUserPage >>>>>>>>>>>>>>>>
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath path = ; name = /[]/info <<<<<<<<<<<<<
2023-11-25 12:22:46.558: AbstractParser.INFO: getPath return []/info >>>>>>>>>>>>>>>>
2023-11-25 12:22:46.558: AbstractParser.INFO: <<<<<<<<<<<<<<<
getValueByPath valuePath = []/info
<<<<<<<<<<<<<<<<<<
2023-11-25 12:22:46.558: AbstractParser.INFO: getValueByPath return null;
2023-11-25 12:22:46.558: AbstractObjectParser.INFO: onParse targetPath = []/info; target = null
2023-11-25 12:22:46.558 WARN [quick-boot-online,656176964e055840a6b76557618628ba,a6b76557618628ba] ==> [XNIO-1 task-2] DictAspect.java.doAround - 获取JSON数据 耗时:2ms
2023-11-25 12:22:46.558 WARN [quick-boot-online,656176964e055840a6b76557618628ba,a6b76557618628ba] ==> [XNIO-1 task-2] DictAspect.java.doAround - 解析注入JSON数据 耗时0ms

@csx-bill
Copy link
Contributor Author

看起来 SysUserPage 被当成表了

@TommyLemon
Copy link
Collaborator

TommyLemon commented Nov 25, 2023

把 SysUserPage 改成不符合 APIJSON 表名的命名,例如 sysUserPage。
符合 APIJSON 表名的 tag,如果 structure 最外层没有这个 tag 字段,则会自动给 structure 包装一层,变成 { tag: structure } ,例如 tag: SysUserPage, structure: {"SysUser[]":{"SysUser":{}}
会把 structure 包装成 { "SysUserPage": {"SysUser[]":{"SysUser":{}} }

@csx-bill
Copy link
Contributor Author

这算是bug吗?

这个版本 有全局驼峰请求,驼峰返回的配置了吗
#615 我有看到这个

这个问题 也需要你看下,APIJSON是需要 开一个分支
#636

@TommyLemon
Copy link
Collaborator

这是功能,为了简化 structure 配置。

还没发布,新版会有。

ok。

@csx-bill
Copy link
Contributor Author

还有个问题 咨询下,sysUserPageyy 这个tag 不存在 居然也能查询数据
image

@TommyLemon
Copy link
Collaborator

TommyLemon commented Nov 25, 2023

如果没用 apijson-router,GET 不限制传参结构(tag 非必传,只用来标记),GETS 才限制(tag 必传)。
用了 apijson-router,DEBUG 模式 GET 不限制传参结构(用于调试),非 DEBUG 模式则不允许自定义传参(用于上线)

@csx-bill
Copy link
Contributor Author

好的,我了解一下 apijson-router 怎么用

@csx-bill
Copy link
Contributor Author

我fork了 也是需要升级下jdk ,替换 jakarta.servlet-api 才能使用springboot3, 这个也开个分支吧,我合并过去

@csx-bill
Copy link
Contributor Author

我在使用 apijson-router 由原来的参数

{
"SysUser[]":{
"SysUser":{
"status()": "translateDict(sys_user_status,status)"
},
"page":0,
"count":5,
"query":2
},
"info@":"/SysUser[]/info",
"format":true
}

转成 apijson-router 写法
{
"SysUser[].page": 0,
"SysUser[].count": 5,
"SysUser[].SysUser.status()": "translateDict(sys_user_status,status)" ,
"format": true
}

问题1 分页 如何转成以上 apijson-router 格式?

问题2 远程函数此处在调用远程函数时,提示
image

@csx-bill
Copy link
Contributor Author

我关闭了 parser.isNeedVerifyContent, Request 表校验规则来校验
请求参数
{
"SysUser[]":{
"SysUser":{
"status()": "translateDict(sys_user_status,status)"
},
"page":0,
"count":5,
"query":2
},
"info@":"/SysUser[]/info",
"format":true
}

可以请求成功了 ,远程函数也执行了,但是 远程函数的 status 字段的值没有返回了,之前是有的

响应结果
image

远程函数 status_text 字段有了 status 丢失了
image

@TommyLemon
Copy link
Collaborator

TommyLemon commented Nov 25, 2023

用法问题,远程函数只能写在 APIJSON 格式的 JSON 参数中,不能对外暴露在类 RESTful 简单接口的 JSON 参数中

另外建议直接用 APIAuto 来配置
https://github.com/APIJSON/apijson-router#usage

@TommyLemon
Copy link
Collaborator

新增了分支 springboot3
https://github.com/Tencent/APIJSON/tree/springboot3

@csx-bill
Copy link
Contributor Author

远程函数的 status 字段的值没有返回了,之前是有的,这个问题是bug吗

@csx-bill
Copy link
Contributor Author

新增了分支 springboot3 https://github.com/Tencent/APIJSON/tree/springboot3

已提交合并请求

@TommyLemon
Copy link
Collaborator

"status()": "translateDict(sys_user_status,status)"

断点调试下,看有没有执行到,以及返回值是啥

@csx-bill
Copy link
Contributor Author

"status()": "translateDict(sys_user_status,status)"
status_text 是 translateDict 函数put的进去的一个字段

@csx-bill csx-bill closed this as completed Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants