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

查询的json ,前端不传递 @schema时,是否可以默认 是application.yml 配置数据源的schema呢。 #364

Open
huangkaiyan10 opened this issue Feb 7, 2022 · 4 comments

Comments

@huangkaiyan10
Copy link

huangkaiyan10 commented Feb 7, 2022

环境信息

  • 系统:
  • JDK:
  • 数据库:
  • APIJSON:

问题描述

查询的json中配置了 @Datasource ,但没有配置@Schema时。能不能 就默认是后台配置数据源时带的schema呢?
5 HZXFMPJ`AZ4C_6FV1S}H0

查询报错,如下图
3~`)@R5YUY N(}UFF_1 H 8

如果在查询的json 中传递了 @Schema , 可以查询出正确的结果,如下图:
R UP4MAJS`AQXMAD$R%S_BR

但我期望,查询json中但没有配置@Schema时,能不能 就默认是后台配置数据源时带的schema (base_nn4)呢?

@TommyLemon
Copy link
Collaborator

TommyLemon commented Feb 7, 2022

DemoSQLConfig 重写 getSchema,判断 getDatasource 的值不为空就 return null,或者登录接口 defaults 里传 "@Schema":""

@huangkaiyan10
Copy link
Author

huangkaiyan10 commented Feb 7, 2022 via email

@huangkaiyan10
Copy link
Author

尝试了,不成功。报了另外的错误,如下截图:
image

image

{
"Dic_station[]": {
"Dic_station": {}
},
"ok": false,
"code": 500,
"msg": "No database selected \n\n\n浏览器打开以下链接查看解答 \n\n【Google】:\n https://www.google.com/search?q=No+database+selected \n\n【百度】:\n https://www.baidu.com/s?ie=UTF-8&wd=No+database+selected\n【APIAuto】: \n http://apijson.cn/api?type=JSON&url=http%3A%2F%2Flocalhost%3A8080%2Fget&json=%7B%22Dic_station%5B%5D%22%3A%7B%22Dic_station%22%3A%7B%7D%7D%7D \n\n【GitHub】: \n https://www.google.com/search?q=site%3Agithub.com%2FTencent%2FAPIJSON+++No+database+selected \n\n都没找到答案?打开这个链接 \n https://github.com/Tencent/APIJSON/issues/new?assignees=&labels=&template=--bug.md \n然后提交问题,推荐用以下模板修改,注意要换行保持清晰可读。\n【标题】:No database selected\n【内容】:环境信息 \n系统: Windows 10 10.0\n数据库: MYSQL 5.7.22\nJDK: 1.8.0_101 amd64\nAPIJSON: 4.8.0\n\n问题描述\nNo database selected\n\n\n\nPOST http://localhost:8080/get\n请求 Request JSON:\n js\n 请填写,例如 { \"Users\":{} }\n\n\n返回结果 Response JSON:\n js\n 请填写,例如 { \"Users\": {}, \"code\": 401, \"msg\": \"Users 不允许 UNKNOWN 用户的 GET 请求!\" }\n",
"sql:generate|cache|execute|maxExecute": "1|0|0|200",
"depth:count|max": "3|5",
"time:start|duration|end": "1644286360988|29155|1644286390143",
"throw": "java.sql.SQLException",
"trace": [
{
"className": "sun.reflect.NativeConstructorAccessorImpl",
"fileName": "NativeConstructorAccessorImpl.java",
"lineNumber": -2,
"methodName": "newInstance0",
"nativeMethod": true
},
{
"className": "sun.reflect.NativeConstructorAccessorImpl",
"fileName": "NativeConstructorAccessorImpl.java",
"lineNumber": 62,
"methodName": "newInstance",
"nativeMethod": false
},
{
"className": "sun.reflect.DelegatingConstructorAccessorImpl",
"fileName": "DelegatingConstructorAccessorImpl.java",
"lineNumber": 45,
"methodName": "newInstance",
"nativeMethod": false
},
{
"className": "java.lang.reflect.Constructor",
"fileName": "Constructor.java",
"lineNumber": 423,
"methodName": "newInstance",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 1804,
"methodName": "executeSQL",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 895,
"methodName": "onSQLExecute",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 762,
"methodName": "executeSQL",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 1,
"methodName": "executeSQL",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 1021,
"methodName": "onObjectParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 565,
"methodName": "onChildParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 268,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 1,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 957,
"methodName": "onObjectParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 1156,
"methodName": "onArrayParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 545,
"methodName": "onChildParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 268,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractObjectParser",
"fileName": "AbstractObjectParser.java",
"lineNumber": 1,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 957,
"methodName": "onObjectParse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 413,
"methodName": "parseResponse",
"nativeMethod": false
},
{
"className": "apijson.framework.APIJSONParser",
"fileName": "APIJSONParser.java",
"lineNumber": 115,
"methodName": "parseResponse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 342,
"methodName": "parseResponse",
"nativeMethod": false
},
{
"className": "apijson.orm.AbstractParser",
"fileName": "AbstractParser.java",
"lineNumber": 314,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.framework.APIJSONController",
"fileName": "APIJSONController.java",
"lineNumber": 90,
"methodName": "parse",
"nativeMethod": false
},
{
"className": "apijson.framework.APIJSONController",
"fileName": "APIJSONController.java",
"lineNumber": 102,
"methodName": "get",
"nativeMethod": false
},
{
"className": "apijson.boot.controller.DemoController",
"fileName": "DemoController.java",
"lineNumber": 85,
"methodName": "get",
"nativeMethod": false
},
{
"className": "sun.reflect.NativeMethodAccessorImpl",
"fileName": "NativeMethodAccessorImpl.java",
"lineNumber": -2,
"methodName": "invoke0",
"nativeMethod": true
},
{
"className": "sun.reflect.NativeMethodAccessorImpl",
"fileName": "NativeMethodAccessorImpl.java",
"lineNumber": 62,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "sun.reflect.DelegatingMethodAccessorImpl",
"fileName": "DelegatingMethodAccessorImpl.java",
"lineNumber": 43,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "java.lang.reflect.Method",
"fileName": "Method.java",
"lineNumber": 498,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.springframework.web.method.support.InvocableHandlerMethod",
"fileName": "InvocableHandlerMethod.java",
"lineNumber": 197,
"methodName": "doInvoke",
"nativeMethod": false
},
{
"className": "org.springframework.web.method.support.InvocableHandlerMethod",
"fileName": "InvocableHandlerMethod.java",
"lineNumber": 141,
"methodName": "invokeForRequest",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod",
"fileName": "ServletInvocableHandlerMethod.java",
"lineNumber": 106,
"methodName": "invokeAndHandle",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter",
"fileName": "RequestMappingHandlerAdapter.java",
"lineNumber": 894,
"methodName": "invokeHandlerMethod",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter",
"fileName": "RequestMappingHandlerAdapter.java",
"lineNumber": 808,
"methodName": "handleInternal",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter",
"fileName": "AbstractHandlerMethodAdapter.java",
"lineNumber": 87,
"methodName": "handle",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.DispatcherServlet",
"fileName": "DispatcherServlet.java",
"lineNumber": 1060,
"methodName": "doDispatch",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.DispatcherServlet",
"fileName": "DispatcherServlet.java",
"lineNumber": 962,
"methodName": "doService",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.FrameworkServlet",
"fileName": "FrameworkServlet.java",
"lineNumber": 1006,
"methodName": "processRequest",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.FrameworkServlet",
"fileName": "FrameworkServlet.java",
"lineNumber": 909,
"methodName": "doPost",
"nativeMethod": false
},
{
"className": "javax.servlet.http.HttpServlet",
"fileName": "HttpServlet.java",
"lineNumber": 665,
"methodName": "service",
"nativeMethod": false
},
{
"className": "org.springframework.web.servlet.FrameworkServlet",
"fileName": "FrameworkServlet.java",
"lineNumber": 883,
"methodName": "service",
"nativeMethod": false
},
{
"className": "javax.servlet.http.HttpServlet",
"fileName": "HttpServlet.java",
"lineNumber": 750,
"methodName": "service",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 227,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.tomcat.websocket.server.WsFilter",
"fileName": "WsFilter.java",
"lineNumber": 53,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 189,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.RequestContextFilter",
"fileName": "RequestContextFilter.java",
"lineNumber": 100,
"methodName": "doFilterInternal",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.OncePerRequestFilter",
"fileName": "OncePerRequestFilter.java",
"lineNumber": 119,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 189,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.FormContentFilter",
"fileName": "FormContentFilter.java",
"lineNumber": 93,
"methodName": "doFilterInternal",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.OncePerRequestFilter",
"fileName": "OncePerRequestFilter.java",
"lineNumber": 119,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 189,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.CharacterEncodingFilter",
"fileName": "CharacterEncodingFilter.java",
"lineNumber": 201,
"methodName": "doFilterInternal",
"nativeMethod": false
},
{
"className": "org.springframework.web.filter.OncePerRequestFilter",
"fileName": "OncePerRequestFilter.java",
"lineNumber": 119,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 189,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.ssssssss.magicapi.config.MagicCorsFilter",
"fileName": "MagicCorsFilter.java",
"lineNumber": 47,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 189,
"methodName": "internalDoFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.ApplicationFilterChain",
"fileName": "ApplicationFilterChain.java",
"lineNumber": 162,
"methodName": "doFilter",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.StandardWrapperValve",
"fileName": "StandardWrapperValve.java",
"lineNumber": 202,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.StandardContextValve",
"fileName": "StandardContextValve.java",
"lineNumber": 97,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.authenticator.AuthenticatorBase",
"fileName": "AuthenticatorBase.java",
"lineNumber": 542,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.StandardHostValve",
"fileName": "StandardHostValve.java",
"lineNumber": 143,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.valves.ErrorReportValve",
"fileName": "ErrorReportValve.java",
"lineNumber": 92,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.core.StandardEngineValve",
"fileName": "StandardEngineValve.java",
"lineNumber": 78,
"methodName": "invoke",
"nativeMethod": false
},
{
"className": "org.apache.catalina.connector.CoyoteAdapter",
"fileName": "CoyoteAdapter.java",
"lineNumber": 357,
"methodName": "service",
"nativeMethod": false
},
{
"className": "org.apache.coyote.http11.Http11Processor",
"fileName": "Http11Processor.java",
"lineNumber": 374,
"methodName": "service",
"nativeMethod": false
},
{
"className": "org.apache.coyote.AbstractProcessorLight",
"fileName": "AbstractProcessorLight.java",
"lineNumber": 65,
"methodName": "process",
"nativeMethod": false
},
{
"className": "org.apache.coyote.AbstractProtocol$ConnectionHandler",
"fileName": "AbstractProtocol.java",
"lineNumber": 893,
"methodName": "process",
"nativeMethod": false
},
{
"className": "org.apache.tomcat.util.net.NioEndpoint$SocketProcessor",
"fileName": "NioEndpoint.java",
"lineNumber": 1707,
"methodName": "doRun",
"nativeMethod": false
},
{
"className": "org.apache.tomcat.util.net.SocketProcessorBase",
"fileName": "SocketProcessorBase.java",
"lineNumber": 49,
"methodName": "run",
"nativeMethod": false
},
{
"className": "java.util.concurrent.ThreadPoolExecutor",
"fileName": "ThreadPoolExecutor.java",
"lineNumber": 1142,
"methodName": "runWorker",
"nativeMethod": false
},
{
"className": "java.util.concurrent.ThreadPoolExecutor$Worker",
"fileName": "ThreadPoolExecutor.java",
"lineNumber": 617,
"methodName": "run",
"nativeMethod": false
},
{
"className": "org.apache.tomcat.util.threads.TaskThread$WrappingRunnable",
"fileName": "TaskThread.java",
"lineNumber": 61,
"methodName": "run",
"nativeMethod": false
},
{
"className": "java.lang.Thread",
"fileName": "Thread.java",
"lineNumber": 745,
"methodName": "run",
"nativeMethod": false
}
]
}

@huangkaiyan10
Copy link
Author

我的错。忘记在 java 代码中增加数据源。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants