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

接入自定义数据库后,调试GET、POST、PUT接口的摸索实践 #189

Open
bodian520 opened this issue Jan 4, 2021 · 2 comments

Comments

@bodian520
Copy link

bodian520 commented Jan 4, 2021

接入自定义数据后数据库后,在调试GET、POST、PUT接口时遇到了一些问题,把个人的摸索经验分享一下,希望作者能梳理下文档,方便我们更好的接入,目前感觉文档没有涵盖这些接入的关键问题,都需要遇到问题之后自己到issue中查找,接入比较耗时。

前提步骤:
(必须操作,否则后续调试报错)
1.已有数据库tool,初始化时候需要把demo中的apijson.sql导入数据库tool中
2.在ACCESS表中参照其他记录,为自有的数据库表新增ACCESS记录,例如tool库中有task表,则新增task表对应记录
3.对于需要用到PUT、POST这类非公开接口的表,参照REQUEST表中其他记录,增加对应表记录,例如tool库中的task表需要用post接口,在需要在REQUEST表中新增记录
4.ACCESS、REQUEST表新增记录后,需要重新启动java应用,才能读取到更新的记录
(注意:需要用到的表都需要新增记录,否则会报错)

调试:

1.在apijson.org/api 调试 get接口 ,正常,参照文档即可
2.在apijson.org/api 调试 post、put接口
1)因为本身系统已经进行了权限校验,不需要apijson再对post、put这类接口进行权限校验,所以
参考该issue 问题 13
#36
代码实现:
image
调试结果正常:
image

2)如果数据库表是id自增设计,不需要apijson自动生成id,则参考该issue进行修改
#186
image
调试结果正常:
image

@TommyLemon
Copy link
Collaborator

TommyLemon commented Jan 4, 2021

非常感谢,如果能直接发一个 PR 就更好了,我们合并 PR 后会把你加到 APIJSON 贡献者列表中~
https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md

可以直接在首页 README.md#相关推荐 加一个文章链接,指向这个 issue,例如

[APIJSON 调试 GET、POST、PUT 接口的摸索实践](https://github.com/Tencent/APIJSON/issues/189)

@TommyLemon
Copy link
Collaborator

TommyLemon commented Jan 8, 2021

原来是腾讯同事呀,赞!

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