├── .gitignore ├── LICENSE ├── README.md ├── deploy.sh ├── docs ├── .vuepress │ ├── config.js │ └── public │ │ ├── APIJSON_Logo.png │ │ └── assets │ │ ├── 1542338464474.png │ │ ├── 1542350219020.png │ │ ├── 1542357146401.png │ │ ├── 1542357265371.png │ │ ├── 1543975054594.png │ │ ├── 1543975563775.png │ │ ├── 1543978123163.png │ │ ├── 1543983739325.png │ │ ├── 1543983787388.png │ │ ├── 1544515879364.png │ │ ├── 1544659314099.png │ │ ├── 1545468294295.png │ │ ├── home1.png │ │ ├── home2.png │ │ ├── install1.png │ │ ├── install2.png │ │ ├── install3.png │ │ ├── install4.png │ │ ├── test1.png │ │ ├── test2.png │ │ └── use1.png ├── FAQ │ └── README.md ├── README.md ├── bar │ ├── README.md │ ├── four.md │ └── three.md ├── en-US │ ├── README.md │ └── nested │ │ └── README.md ├── foo │ ├── README.md │ ├── one.md │ └── two.md └── zh │ ├── README.md │ ├── all.md │ ├── auto │ └── README.md │ ├── grammar.md │ ├── install.md │ ├── nested │ └── README.md │ ├── newinterface.md │ └── sqlconfig.md ├── package.json ├── yarn-error.log └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ./docs/.vuepress/dist/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright @2019 vincentCheng(https://github.com/vincentCheng/apijson-doc) 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | apijson的官方文档:https://vincentcheng.github.io/apijson-doc/ 2 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 终止一个错误 4 | set -e 5 | 6 | # 构建 7 | npm run docs:build 8 | 9 | # 进入生成的构建文件夹 10 | cd docs/.vuepress/dist 11 | 12 | # 如果你是要部署到自定义域名 13 | # echo 'www.example.com' > CNAME 14 | 15 | git init 16 | git add -A 17 | git commit -m 'deploy' 18 | 19 | # 如果你想要部署到 https://.github.io 20 | # git push -f git@github.com:/.github.io.git master 21 | 22 | # 如果你想要部署到 https://.github.io/ 23 | git push -f git@github.com:vincentcheng/apijson-doc.git master:gh-pages 24 | 25 | # 删除dist文件夹 26 | git rm -r --cached "docs/.vuepress/dist" 27 | cd - 28 | -------------------------------------------------------------------------------- /docs/.vuepress/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 导航栏 3 | */ 4 | let navbarConfig = { 5 | navbar: true, 6 | nav: [ 7 | { text: "文档", link: "/zh/" }, 8 | { text: "常见问题", link: "/FAQ/" } 9 | // { text: "Home", link: "/" }, 10 | // { text: "Foo", link: "/foo/" } 11 | // { text: "Bar", link: "/bar/" }, 12 | // { 13 | // text: "Languages", 14 | // items: [{ text: "中文", link: "/" }, { text: "English", link: "/en-US/" }] 15 | // }, 16 | // { 17 | // text: "嵌套的items", 18 | // items: [ 19 | // { 20 | // text: "Group1", 21 | // items: [ 22 | // { text: "Group1-1", link: "/language/chinese" }, 23 | // { text: "Group1-2", link: "/language/japanese" } 24 | // ] 25 | // }, 26 | // { 27 | // text: "Group2", 28 | // items: [ 29 | // /* */ 30 | // ] 31 | // } 32 | // ] 33 | // } 34 | ] 35 | }; 36 | 37 | /** 38 | * 侧边栏 39 | * 如果是在“多语言”中,这些配置基本上没有什么用了。 40 | */ 41 | let sidebarConfig = { 42 | displayAllHeaders: true, 43 | activeHeaderLinks: false, // 默认值:true 44 | sidebarDepth: 2, 45 | sidebar: { 46 | // 回退(fallback)侧边栏配置 47 | "/zh/": [ 48 | "" /* /zh/ */, 49 | "install" /* /zh/install.html */, 50 | "sqlconfig" /* /zh/sqlconfig.html */, 51 | "grammar" /* /zh/grammar.html */, 52 | "newinterface" /* /zh/newinterface.html */, 53 | "all" /* /zh/all.html */ 54 | ], 55 | "/FAQ/": [""] 56 | // "/foo/": [ 57 | // // 注意,这个和上面的navBar对应,这是一个新的页面中的侧边栏 58 | // "" /* /foo/ */, 59 | // "one" /* /foo/one.html */, 60 | // "two" /* /foo/two.html */ 61 | // ] 62 | // "/bar/": [ 63 | // "" /* /bar/ */, 64 | // "three" /* /bar/three.html */, 65 | // "four" /* /bar/four.html */ 66 | // ], 67 | // { 68 | // title: "Group 1", 69 | // collapsable: false, 70 | // children: ["/"] 71 | // }, 72 | // { 73 | // title: "Group 2", 74 | // collapsable: false, 75 | // children: ["/", ["/about", "关于"], ["/contact", "联系我们"]] 76 | // } 77 | } 78 | }; 79 | 80 | /** 81 | * 这个只能显示一个 ??? 82 | */ 83 | let sidebarAutoConfig = { sidebar: "auto" }; 84 | 85 | /** 86 | * 多语言模式 87 | */ 88 | let sidebarLanguagesConfig = { "/": { sidebar: "auto" } }; 89 | 90 | /** 91 | * 站点多语言配置 92 | */ 93 | let siteLanguagesConfig = { 94 | locales: { 95 | "/zh/home/": { 96 | lang: "zh-CN", 97 | title: "APIJSON 官方文档", 98 | description: 99 | "apijson 的官方文档 后端接口和文档自动化,前端(客户端) 定制返回JSON的数据和结构 码云GPV" 100 | } 101 | // 键名是该语言所属的子路径 102 | // 作为特例,默认语言可以使用 '/' 作为其路径。 103 | // "/en-US/": { 104 | // lang: "en-US", // 将会被设置为 的 lang 属性 105 | // title: "VuePress English", 106 | // description: "Vue-powered Static Site Generator" 107 | // } 108 | } 109 | }; 110 | 111 | /** 112 | * 默认多语言模式设置 113 | */ 114 | let defaultLanguagesConfig = { 115 | locales: { 116 | "/": { 117 | // 语言下拉菜单的展示文本 118 | selectText: "选择语言", 119 | // 该语言在下拉菜单中的 label 标签 120 | label: "简体中文", 121 | // github 编辑链接的文字 122 | editLinkText: "在 GitHub 上编辑此页", 123 | serviceWorker: { 124 | updatePopup: { 125 | message: "发现新内容可用.", 126 | buttonText: "刷新" 127 | } 128 | }, 129 | algolia: {}, 130 | nav: [{ text: "嵌套", link: "/zh/nested/" }], 131 | sidebar: "auto", 132 | lastUpdated: "最近更新时间:" // 这是一个时间戳 133 | // ...sidebarConfig 134 | }, 135 | "/en-US/": { 136 | // text for the language dropdown 137 | selectText: "Languages", 138 | // label for this locale in the language dropdown 139 | label: "English", 140 | // text for the edit-on-github link 141 | editLinkText: "Edit this page on GitHub", 142 | // config for Service Worker 143 | serviceWorker: { 144 | updatePopup: { 145 | message: "New content is available.", 146 | buttonText: "Refresh" 147 | } 148 | }, 149 | // algolia docsearch options for current locale 150 | algolia: {}, 151 | nav: [{ text: "Nested", link: "/en-US/nested/" }], 152 | sidebar: "auto", 153 | lastUpdated: "Last Updated: " // 这是一个时间戳 154 | // ...sidebarConfig 155 | } 156 | } 157 | }; 158 | 159 | /** 160 | * algolia 这个要提交网址的 161 | */ 162 | let searchConfig = { 163 | search: false, 164 | searchMaxSuggestions: 10, 165 | algolia: { 166 | apiKey: "", 167 | indexName: "" 168 | } 169 | }; 170 | 171 | /** 172 | * 仓库的配置 173 | * 放在themeConfig中 174 | * 175 | * 部署失败的原因二: 176 | * 这个要写在 “themeConfig” 中, 177 | * 并且要写清楚 repo: "https://github.com/vincentCheng/apijson-doc.git" 这个是仓库的地址 178 | */ 179 | let repositoryConfig = { 180 | repo: "https://github.com/vincentCheng/apijson-doc", 181 | repoLabel: "GitHub", 182 | // 默认为 false,设置为 true 来启用 183 | editLinks: true, 184 | // 自定义编辑链接的文本。默认是 "Edit this page" 185 | editLinkText: "帮助我们改进页面内容!", 186 | docsDir: "docs" 187 | }; 188 | 189 | /** 190 | * serviceWorker 这个是能够提醒用户,网站更新了。 191 | * 192 | * 部署失败的原因一: 193 | * base: "/apijson-doc/",要写在“themeConfig”的外面,并且只能填写仓库的“名字” 194 | */ 195 | module.exports = { 196 | base: "/apijson-doc/", 197 | title: "apijson-doc", 198 | description: "Apijson 的官方文档", 199 | head: [["link", { rel: "icon", href: "/APIJSON_Logo.png" }]], 200 | ...siteLanguagesConfig, 201 | themeConfig: { 202 | serviceWorker: { 203 | updatePopup: true 204 | }, 205 | ...navbarConfig, 206 | // ...defaultLanguagesConfig, 207 | // ...sidebarLanguagesConfig, 208 | // ...sidebarAutoConfig, 209 | ...sidebarConfig, 210 | ...repositoryConfig 211 | } 212 | }; 213 | -------------------------------------------------------------------------------- /docs/.vuepress/public/APIJSON_Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/APIJSON_Logo.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1542338464474.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1542338464474.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1542350219020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1542350219020.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1542357146401.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1542357146401.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1542357265371.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1542357265371.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1543975054594.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1543975054594.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1543975563775.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1543975563775.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1543978123163.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1543978123163.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1543983739325.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1543983739325.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1543983787388.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1543983787388.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1544515879364.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1544515879364.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1544659314099.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1544659314099.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/1545468294295.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/1545468294295.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/home1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/home1.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/home2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/home2.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/install1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/install1.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/install2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/install2.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/install3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/install3.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/install4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/install4.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/test1.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/test2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/test2.png -------------------------------------------------------------------------------- /docs/.vuepress/public/assets/use1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vincentCheng/apijson-doc/cf7947d0f678ec15f330fdcdc74a1634fa32cccb/docs/.vuepress/public/assets/use1.png -------------------------------------------------------------------------------- /docs/FAQ/README.md: -------------------------------------------------------------------------------- 1 | # 常见问题 2 | 3 | ## MYSQL 时区引起的乱码 4 | 5 | 操作系统:win10 6 | 数据库:mysql8 7 | 8 | 程序运行后,有可能会出现以下报错: 9 | 10 | ```doc 11 | The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. 12 | ``` 13 | 14 | 解决步骤为: 15 | 进入 C 盘 -> "查看",勾选“隐藏的项目”,也就是显示隐藏文件夹。-> 打开 C:\ProgramData\MySQL\MySQL Server 8.0\my.ini。->搜索字符“[mysqld]”,并且在这字符串下面添加“default-time-zone='+08:00'”。->保存,重启 mysql8。 16 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | home: true 3 | heroImage: /APIJSON_Logo.png 4 | heroText: APIJSON 5 | tagline: 官方文档 6 | actionText: 快速上手 → 7 | actionLink: /zh/install/ 8 | features: 9 | - title: 在线解析 10 | details: 自动生成接口文档,清晰可读永远最新。自动生成请求代码,支持Android和iOS。自动生成JavaBean文件,一键下载。自动管理与测试接口用例,一键共享。自动校验与格式化JSON,支持高亮和收展。 11 | - title: 对于前端 12 | details: 不用再向后端催接口、求文档。数据和结构完全定制,要啥有啥。看请求知结果,所求即所得。可一次获取任何数据、任何结构。能去除重复数据,节省流量提高速度。 13 | - title: 对于后端 14 | details: 提供通用接口,大部分API不用再写。自动生成文档,不用再编写和维护。自动校验权限、自动管理版本、自动防SQL注入。开放API无需划分版本,始终保持兼容。支持增删改查、模糊搜索、正则匹配、远程函数等。 15 | --- 16 | -------------------------------------------------------------------------------- /docs/bar/README.md: -------------------------------------------------------------------------------- 1 | ## bar 的 README.md 2 | -------------------------------------------------------------------------------- /docs/bar/four.md: -------------------------------------------------------------------------------- 1 | ## bar 的 README.md > four.md 2 | -------------------------------------------------------------------------------- /docs/bar/three.md: -------------------------------------------------------------------------------- 1 | ## bar 的 README.md > three.md 2 | -------------------------------------------------------------------------------- /docs/en-US/README.md: -------------------------------------------------------------------------------- 1 | en-US->README.md 2 | -------------------------------------------------------------------------------- /docs/en-US/nested/README.md: -------------------------------------------------------------------------------- 1 | # Test multiple Languages nested>README.md 2 | -------------------------------------------------------------------------------- /docs/foo/README.md: -------------------------------------------------------------------------------- 1 | ## foot 的 README.md 2 | -------------------------------------------------------------------------------- /docs/foo/one.md: -------------------------------------------------------------------------------- 1 | ## foot 的 README.md > one.md 2 | -------------------------------------------------------------------------------- /docs/foo/two.md: -------------------------------------------------------------------------------- 1 | ## foot 的 README.md > two.md 2 | -------------------------------------------------------------------------------- /docs/zh/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | ## 接口开发 4 | 5 | 首先是看名字 APIJSON,API 是说这个项目是属于接口开发的项目,JSON 是指传输数据格式是 JSON 格式。介于各位看官的水平高低不齐,这里就先为没有项目经验朋友啰嗦两句接口开发的内容。有经验的朋友可以跳到 “功能说明” 继续查看。 6 | 7 | (此处内容以后会有的) 8 | 9 | ## 功能说明 10 | 11 | 一个接口的开发(本文档暂时只提供 Java 版本),比如 Java 用 SpringBoot,Mybatis 来开发一般来说就像下面这个流程 12 | 13 | ![home 1](../.vuepress/public/assets/home1.png) 14 | 15 | 部署上这个项目后,流程变成了这样 16 | 17 | ![home 2](../.vuepress/public/assets/home2.png) 18 | 19 | 换句说,使用这个项目作为后端的支持的话,是不需要对每个表写增删改等接口的,只需在该项目连接的数据里进行表的创建,以及配置接口权限即可。无需进行过多的开发,哪怕是要改结构也仅仅只需要修改表字段而已。想想仅仅是部署一个后端项目,现在需要写的接口就基本写好了,直接调用就行了,是不是挺爽的。 20 | 21 | 说这么多,咱们直接开干吧! 22 | -------------------------------------------------------------------------------- /docs/zh/all.md: -------------------------------------------------------------------------------- 1 | # 完整功能图表 2 | 3 | ## 接口功能 4 | 5 | | 方法及说明 | URL | Request | Response | 6 | | ------------------------------------------------------------ | ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | 7 | | GET:
普通获取数据,
可用浏览器调试 | base_url/get/ | {    TableName:{      …
   }
}
{…}内为限制条件

例如获取一个id为235的Moment:
{
   "Moment":{
     "id":235
   }
} | {
   TableName:{
     ...
   },
   "code":200,
   "msg":"success"
}
例如
{
   "Moment":{
     "id":235,
     "userId":38710,
     "content":"APIJSON,let interfaces and documents go to hell !"
   },
   "code":200,
   "msg":"success"
} | 8 | | HEAD:
普通获取数量,
可用浏览器调试 | base_url/head/ | {
   TableName:{
     …
   }
}
{…}内为限制条件

例如获取一个id为38710的User所发布的Moment总数:
{
   "Moment":{
     "userId":38710
   }
} | {
   TableName:{
     "code":200,
     "msg":"success",
     "count":10
   },
   "code":200,
   "msg":"success"
}
例如
{
   "Moment":{
     "code":200,
     "msg":"success",
     "count":10
   },
   "code":200,
   "msg":"success"
} | 9 | | GETS:
安全/私密获取数据,
用于获取钱包等
对安全性要求高的数据 | base_url/gets/ | 最外层加一个"tag":tag,其它同GET | 同GET | 10 | | HEADS:
安全/私密获取数量,
用于获取银行卡数量等
对安全性要求高的数据总数 | base_url/heads/ | 最外层加一个"tag":tag,其它同HEAD | 同HEAD | 11 | | POST:
新增数据 | base_url/post/ | {
   TableName:{
     …
   },
   "tag":tag
}
{…}中id由后端生成,不能传

例如一个id为38710的User发布一个新Moment:
{
   "Moment":{
     "userId":38710,
     "content":"APIJSON,let interfaces and documents go to hell !"
   },
   "tag":"Moment"
} | {
   TableName:{
     "code":200,
     "msg":"success",
     "id":38710
   },
   "code":200,
   "msg":"success"
}
例如
{
   "Moment":{
     "code":200,
     "msg":"success",
     "id":120
   },
   "code":200,
   "msg":"success"
} | 12 | | PUT:
修改数据,
只修改所传的字段 | base_url/put/ | {
   TableName:{
     "id":id,
     …
   },
   "tag":tag
}
{…}中id必传

例如修改id为235的Moment的content:
{
   "Moment":{
     "id":235,
     "content":"APIJSON,let interfaces and documents go to hell !"
   },
   "tag":"Moment"
} | 同POST | 13 | | DELETE:
删除数据 | base_url/delete/ | {
   TableName:{
     "id":id
   },
   "tag":tag
}
{…}中id必传,一般只传id

例如删除id为120的Moment:
{
   "Moment":{
     "id":120
   },
   "tag":"Moment"
} | 同POST | 14 | 15 | 1.TableName指要查询的数据库表Table的名称字符串。第一个字符为大写字母,剩下的字符要符合英语字母、数字、下划线中的任何一种。对应的值的类型为JSONObject,结构是 {...},里面放的是Table的字段(列名)。下同。
16 | 2."tag":tag 后面的tag是非GET、HEAD请求中匹配请求的JSON结构的key,一般是要查询的table的名称,由后端Request表中指定。下同。
17 | 3.GET、HEAD请求是开放请求,可任意组合任意嵌套。其它请求为受限制的安全/私密请求,对应的 方法、tag、结构 都必须和 后端Request表中所指定的 一一对应,否则请求将不被通过。下同。
18 | 4.GETS与GET、HEADS与HEAD分别为同一类型的操作方法,请求稍有不同但返回结果相同。下同。
19 | 5.在HTTP通信中,GET、HEAD方法一般用HTTP GET请求,其它一般用HTTP POST请求。下同。
20 | 6.所有JSONObject都视为容器(或者文件夹),结构为 {...} ,里面可以放普通对象或子容器。下同。
21 | 7.每个对象都有一个唯一的路径(或者叫地址),假设对象名为refKey,则用 key0/key1/.../refKey 表示。下同。 22 | 23 | :notebook:注意 24 | 25 | 1. Oracle数据库直接使用的是当前时间的LONG值,作为插入时新数据ID的 26 | 27 |
28 | 29 | ## 功能符 30 | 31 | | 功能 | 键值对格式 | 使用示例 | 32 | | -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | 33 | | 查询数组 | "key[]":{},后面是JSONObject,key可省略。当key和里面的Table名相同时,Table会被提取出来,即 {Table:{Content}} 会被转化为 {Content} | [{"User[]":{"User":{}}}](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{}}}),查询一个User数组。这里key和Table名都是User,User会被提取出来,即 {"User":{"id", ...}} 会被转化为 {"id", ...} | 34 | | 匹配选项范围 | "key{}":[],后面是JSONArray,作为key可取的值的选项 | ["id{}":[38710,82001,70793]](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{"id{}":[38710,82001,70793]}}}),查询id符合38710,82001,70793中任意一个的一个User数组 | 35 | | 匹配条件范围 | "key{}":"条件0,条件1...",条件为任意SQL比较表达式字符串,非Number类型必须用''包含条件的值,如'a' | ["id{}":"<=80000,\>90000"](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{"id{}":"<=80000,\>90000"}}}),查询id符合id\<=80000 \| id>90000的一个User数组 | 36 | | 包含选项范围 | "key<\>":Object => "key<\>":[Object],key对应值的类型必须为JSONArray,Object类型不能为JSON | ["contactIdList<\>":38710](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{"contactIdList<\>":38710}}}),查询contactIdList包含38710的一个User数组 | 37 | | 远程调用函数 | "key()":"函数表达式",函数表达式为 function(key0,key1...),会调用后端对应的函数 function(JSONObject request, String key0, String key1...) | ["isPraised()":"isContain(praiseUserIdList,userId)"](http://apijson.cn:8080/get/{"Moment":{"id":301,"isPraised()":"isContain(praiseUserIdList,userId)"}}),会调用 boolean isContain(JSONObject request, String array, String value) 函数,然后变为 "isPraised":true 这种(假设点赞用户id列表包含了userId,即这个User点了赞) | 38 | | 引用赋值 | "key@":"引用路径",引用路径为用/分隔的字符串。以/开头的是缺省引用路径,从声明key所处容器的父容器路径开始;其它是完整引用路径,从最外层开始。
被引用的refKey必须在声明key的上面。如果对refKey的容器指定了返回字段,则被引用的refKey必须写在@column对应的值内,例如 "@column":"refKey,key1,..." | ["Moment":{
   "userId":38710
},
"User":{
   "id@":"/Moment/userId"
}](http://apijson.cn:8080/get/{"Moment":{"userId":38710},"User":{"id@":"%252FMoment%252FuserId"}})
User内的id引用了与User同级的Moment内的userId,
即User.id = Moment.userId,请求完成后
"id@":"/Moment/userId" 会变成 "id":38710 | 39 | | 模糊搜索 | "key$":"SQL搜索表达式" => "key$":["SQL搜索表达式"],任意SQL搜索表达式字符串,如 %key%(包含key), key%(以key开始), %k%e%y%(包含字母k,e,y) 等,%表示任意字符 | ["name$":"%m%"](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{"name$":"%2525m%2525"}}}),查询name包含"m"的一个User数组 | 40 | | 正则匹配 | "key?":"正则表达式" => "key?":["正则表达式"],任意正则表达式字符串,如 ^[0-9]+$ ,可用于高级搜索 | ["name?":"^[0-9]+$"](http://apijson.cn:8080/get/{"User[]":{"count":3,"User":{"name%253F":"^[0-9]%252B$"}}}),查询name中字符全为数字的一个User数组 | 41 | | 新建别名 | "name:alias",name映射为alias,用alias替代name。可用于 column,Table,SQL函数 等。只用于GET类型、HEAD类型的请求 | ["@column":"toId:parentId"](http://apijson.cn:8080/get/{"Comment":{"@column":"id,toId:parentId","id":51}}),将查询的字段toId变为parentId返回 | 42 | | 增加 或 扩展 | "key+":Object,Object的类型由key指定,且类型为Number,String,JSONArray中的一种。如 82001,"apijson",["url0","url1"] 等。只用于PUT请求 | "praiseUserIdList+":[82001],添加一个点赞用户id,即这个用户点了赞 | 43 | | 减少 或 去除 | "key-":Object,与"key+"相反 | "balance-":100.00,余额减少100.00,即花费了100元 | 44 | | 逻辑运算 | &, \|, ! 逻辑运算符

① & 可用于"key&{}":"条件"等

② \| 可用于"key\|{}":"条件", "key\|{}":[]等,一般可省略

③ ! 可单独使用,如"key!":Object,也可像&,\|一样配合其他功能符使用 | ① ["id&{}":">80000,<=90000"](http://apijson.cn:8080/head/{"User":{"id&{}":">80000,<=90000"}}),即id满足id>80000 & id<=90000

② ["id\|{}":">90000,<=80000"](http://apijson.cn:8080/head/{"User":{"id\|{}":">90000,<=80000"}}),同"id{}":">90000,<=80000",即id满足id>90000 \| id<=80000

③ ["id!{}":[82001,38710]](http://apijson.cn:8080/head/{"User":{"id!{}":[82001,38710]}}),即id满足 ! (id=82001 \| id=38710),可过滤黑名单的消息 | 45 | | 数组关键词 | "key":Object,key为 "[]":{} 中{}内的关键词,Object的类型由key指定

① "count":Integer,查询数量,假设允许查询数组的最大数量为max(默认为100),则当count在1~max范围内时,查询count个;否则查询max个

② "page":Integer,查询页码,从0开始,一般和count一起用

③ "query":Integer,查询内容
0-对象,1-总数,2-以上全部
总数关键词为total,和query同级,通过引用赋值得到,如 "total@":"/[]/total"
这里query及total仅为GET类型的请求提供方便,一般可直接用HEAD类型的请求获取总数

④ "join":"&/Table0/key0@,\多表连接方式:
"\<" - LEFT JOIN
">" - RIGHT JOIN
"&" - INNER JOIN
"\|" - FULL JOIN
"!" - OUTTER JOIN
| ① 查询User数组,最多5个:
["count":5](http://apijson.cn:8080/get/{"[]":{"count":5,"User":{}}})

② 查询第3页的User数组,每页5个:
["count":5,
"page":3](http://apijson.cn:8080/get/{"[]":{"count":5,"page":3,"User":{}}})

③ 查询User数组和对应的User总数:
["[]":{
   "query":2,
   "User":{}
},
"total@":"/[]/total"](http://apijson.cn:8080/get/{"[]":{"query":2,"count":5,"User":{}},"total@":"%252F[]%252Ftotal"})
总页数、是否有下一页等信息可通过 total,count,page 得出,
总页数 int totalPage = Math.ceil(total \/ count)
是否有下一页 boolean hasNextPage = total > count\*page
是否为第一页 boolean isFirstPage = page <= 0
是否为最后一页 boolean isLastPage = total <= count\*page
...

④ Moment INNER JOIN User LEFT JOIN Comment:
["[]":{
   "join": "&/User/id@,\    "Moment":{},
   "User":{
     "name?":"t",
     "id@": "/Moment/userId"
   },
   "Comment":{
     "momentId@": "/Moment/id"
   }
}](http://apijson.cn:8080/get/{"[]":{"count":5,"join":"&%252FUser%252Fid@,<%252FComment%252FmomentId@","Moment":{"@column":"id,userId,content"},"User":{"name%253F":"t","id@":"%252FMoment%252FuserId","@column":"id,name,head"},"Comment":{"momentId@":"%252FMoment%252Fid","@column":"id,momentId,content"}}}) | 46 | | 对象关键词,可自定义 | "@key":Object,@key为 Table:{} 中{}内的关键词,Object的类型由@key指定

① "@combine":"&key0,\|key1,!key2,...",条件组合方式,\| 可省略

② "@column":"column;function(arg)...",返回字段

③ "@order":"column0+,column1-...",排序方式

④ "@group":"column0,column1...",分组方式。如果@column里声明了Table的id,则id也必须在@group中声明;其它情况下必须满足至少一个条件:
1.分组的key在@column里声明
2.Table主键在@group中声明

⑤ "@having":"function0(...)?value0;function1(...)?value1;function2(...)?value2...",SQL函数条件,一般和@group一起用,函数一般在@column里声明

⑥ "@otherKey": Object,自定义关键词,名称和以上系统关键词不一样,且原样返回上传的值 | ① 搜索name或tag任何一个字段包含字符a的User列表:
["name?":"a",
"tag?":"a",
"@combine":"name?,tag?"](http://apijson.cn:8080/get/{"User[]":{"count":10,"User":{"@column":"id,name,tag","name%253F":"a","tag%253F":"a","@combine":"name%253F,tag%253F"}}})

② 只查询id,sex,name这几列并且请求结果也按照这个顺序:
["@column":"id,sex,name"](http://apijson.cn:8080/get/{"User":{"@column":"id,sex,name","id":38710}})

③ 查询按 name降序、id默认顺序 排序的User数组:
["@order":"name-,id"](http://apijson.cn:8080/get/{"[]":{"count":10,"User":{"@column":"name,id","@order":"name-,id"}}})

④ 查询按userId分组的Moment数组:
["@group":"userId,id"](http://apijson.cn:8080/get/{"[]":{"count":10,"Moment":%7B"@column":"userId,id","@group":"userId,id"}}})

⑤ 查询 按userId分组、id最大值>=100 的Moment数组:
["@column":"userId;max(id)",
"@group":"userId",
"@having":"max(id)>=100"](http://apijson.cn:8080/get/{"[]":{"count":10,"Moment":{"@column":"userId%253Bmax(id)","@group":"userId","@having":"max(id)>=100"}}})
还可以指定函数返回名:
["@column":"userId;max(id):maxId",
"@group":"userId",
"@having":"maxId>=100"](http://apijson.cn:8080/get/{"[]":{"count":10,"Moment":{"@column":"userId%253Bmax(id):maxId","@group":"userId","@having":"maxId>=100"}}})

⑥ 从pictureList获取第0张图片:
["@position":0, //这里@position为自定义关键词
"firstPicture()":"getFromArray(pictureList,@position)"](http://apijson.cn:8080/get/{"User":{"id":38710,"@position":0,"firstPicture()":"getFromArray(pictureList,@position)"}}) | 47 | 48 |
-------------------------------------------------------------------------------- /docs/zh/auto/README.md: -------------------------------------------------------------------------------- 1 | # 自动化 2 | 3 | ## 自动化生成代码 4 | -------------------------------------------------------------------------------- /docs/zh/grammar.md: -------------------------------------------------------------------------------- 1 | # 语法 & 示例 2 | 3 | ## 登录 4 | 5 | 如果需要尝试使用,请按照以下步骤获取: 6 | 7 | 1. 在浏览器中输入 apijson.org; 8 | 2. 点击右上角的“登录”按钮登录; 9 | 3. 点击“测试账号”按钮左边第二个按钮。(也就是“-”左边的第一个)获取各种测试用例 10 | 4. 欢迎大家踊跃共享自己的测试用例;(也欢迎大家踊跃充值,哈哈哈哈~~~~~) 11 | 12 | ## 查询 13 | 14 | 为了方便测试,我这里使用的 Chrome 浏览器的 Restlet Client 插件,大家可以根据自己的喜好使用不同的工具测试。 15 | 16 | 请注意 APIJSONApplication.java 中使用 Tomcat 默认的 8080 端口,如果不小心开着 PC 端的“微信”,8080 端口会被占用,建议改成 8081, 9090 等其它应用程序未占用的端口。 17 | 18 | 随便找一个上一节中导入的表,比如 Moment 表,我们取其中 ID 为 12 的一条出来看看。下图为数据库中的数据: 19 | ![test2](../.vuepress/public/assets/test2.png) 20 | 21 | 下图所示的连接地址: 22 | 23 | ```html 24 | http://apijson.cn:8080/get 25 | ``` 26 | 27 | 仅仅是用于演示。如果本地数据库已经配置完成,请在箭头所指方向输入本地数据库的链接地址。例如: 28 | 29 | ```html 30 | http://localhost:端口号/get 31 | ``` 32 | 33 | ![test1](../.vuepress/public/assets/test1.png) 34 | 35 | 我们接着输入请求的 JSON: 36 | 37 | ```json 38 | { 39 | "Moment": { 40 | "id": 12 41 | } 42 | } 43 | ``` 44 | 45 | 响应的 JSON: 46 | 47 | ```json 48 | { 49 | "Moment": { 50 | "content": "1111534034", 51 | "date": "2017-02-08 16:06:11.0", 52 | "id": 12, 53 | "pictureList": [ 54 | "http://static.oschina.net/uploads/img/201604/22172508_eGDi.jpg", 55 | "http://static.oschina.net/uploads/img/201604/22172507_rrZ5.jpg" 56 | ], 57 | "praiseUserIdList": [70793, 93793, 82001], 58 | "userId": 70793 59 | }, 60 | "code": 200, 61 | "msg": "success" 62 | } 63 | ``` 64 | 65 | ## 字段过滤 66 | 67 | 这里这么多字段,如果我只想要这个 content 字段的信息怎么办? 68 | 69 | 你可以这样请求: 70 | 71 | ```json 72 | { 73 | "Moment": { 74 | "id": 12, 75 | "@column": "content" 76 | } 77 | } 78 | ``` 79 | 80 | 响应: 81 | 82 | ```json 83 | { 84 | "Moment": { 85 | "content": "1111534034" 86 | }, 87 | "code": 200, 88 | "msg": "success" 89 | } 90 | ``` 91 | 92 | **@column 表示你要筛选出的字段**,如果是多个字段可以这样写"@column":"id,date,content" 93 | 94 | ## 字段别名 95 | 96 | 如果想要使用字段的别名应该这样写:**"@column":"id,date:time,content:text"** 97 | 98 | 响应: 99 | 100 | ```json 101 | { 102 | "Moment": { 103 | "text": "1111534034", 104 | "time": "2017-02-08 16:06:11.0", 105 | "id": 12 106 | } 107 | } 108 | ``` 109 | 110 | 这样在返回的数据中 date 字段就变成了 time,content 字段变成了 text。 111 | 112 | ## 逻辑运算-筛选 113 | 114 | 如果想要筛选出,ID 在`12,15,32`中的这三条数据的`日期`和`内容`怎么办呢? 115 | 116 | 请求: 117 | 118 | ```json 119 | { 120 | "[]": { 121 | "Moment": { 122 | "id{}": [12, 15, 32], 123 | "@column": "id,date,content" 124 | } 125 | } 126 | } 127 | ``` 128 | 129 | 响应: 130 | 131 | ```json 132 | { 133 | "[]": [ 134 | { 135 | "Moment": { 136 | "content": "1111534034", 137 | "date": "2017-02-08 16:06:11.0", 138 | "id": 12 139 | } 140 | }, 141 | { 142 | "Moment": { 143 | "content": "APIJSON is a JSON Transmission Structure Protocol…", 144 | "date": "2017-02-08 16:06:11.0", 145 | "id": 15 146 | } 147 | }, 148 | { 149 | "Moment": { 150 | "date": "2017-02-08 16:06:11.0", 151 | "id": 32 152 | } 153 | } 154 | ], 155 | "code": 200, 156 | "msg": "success" 157 | } 158 | ``` 159 | 160 | 如果所要筛选的数据的是在一定范围内的,比如 ID 是 300 到 400 之间的 161 | 162 | 你可以这样过滤`"id&{}":">=300,<=400"` 163 | 164 | &的作用是表明后面的两个过滤条件的逻辑关系 165 | 166 | ```sql 167 | (ID >= 300 AND ID <= 500) 168 | ``` 169 | 170 | 现在的逻辑符号一共有三种,`&`,`|`,`!` 171 | 172 | 默认的逻辑关系是`|`,也就是说`"id|{}":"<=300,>=400"`和`"id{}":"<=300,>=400"`等价。 173 | 174 | `!`主要用于反选,黑名单之类的 175 | 176 | `"id!{}":[12,15,32]`表示`id`不在 12,15,32 内的其他数据。 177 | 178 | 复杂一些,如果多个条件相互组合,可以写多个关于 id 的过滤条件 179 | 180 | ```json 181 | { 182 | "[]": { 183 | "Moment": { 184 | "id&{}": ">=10,<=40", 185 | "id!{}": [12], 186 | "@column": "id,date,content:text" 187 | } 188 | } 189 | } 190 | ``` 191 | 192 | 比如这里表示 id 在 10 到 40 之间,但是却不包含 12 的数据。 193 | 194 | ## 模糊查询 195 | 196 | ```json 197 | { 198 | "[]": { 199 | "Moment": { 200 | "content$": "%APIJSON%", 201 | "@column": "id,date,content:text" 202 | } 203 | } 204 | } 205 | ``` 206 | 207 | 使用方式有多种: 208 | 209 | `keyword%`,以`keyword`开头的字符串。 210 | 211 | `%keyword`,以`keyword`结束的字符串。 212 | 213 | `%keyword%`,包含`keyword`的字符串,如:`keyword123`、`123keyword`、`123keyword123` 214 | 215 | `%k%e%y%`,包含字母`k`,`e`,`y`的字符串 216 | 217 | 还有几种比较便捷的方式,我们这里如果使用`"content~":"keyword"`来代替`"content$":"%keyword%"`,同样可以表示包含某字符串。 218 | 219 | ## 正则匹配 220 | 221 | ```json 222 | { 223 | "[]": { 224 | "Moment": { 225 | "content?": "^[0-9]+$", 226 | "@column": "id,date,content:text" 227 | } 228 | } 229 | } 230 | ``` 231 | 232 | 正则表达式`^[0-9]+$`,查询`content`为纯数字的数据,[MySQL 的正则语法](http://www.runoob.com/mysql/mysql-regexp.html)如下: 233 | 234 | | 模式 | 描述 | 235 | | ---------- | ------------------------------------------------------------------------------------------------------- | 236 | | ^ | 匹配输入字符串的开始位置。如果设置了 RegExp 对象的 Multiline 属性,^ 也匹配 '\n' 或 '\r' 之后的位置。 | 237 | | \$ | 匹配输入字符串的结束位置。如果设置了 RegExp 对象的 Multiline 属性,\$ 也匹配 '\n' 或 '\r' 之前的位置。 | 238 | | . | 匹配除 "\n" 之外的任何单个字符。要匹配包括 '\n' 在内的任何字符,请使用象 '[.\n]' 的模式。 | 239 | | [...] | 字符集合。匹配所包含的任意一个字符。例如, '[abc]' 可以匹配 "plain" 中的 'a'。 | 240 | | [^...] | 负值字符集合。匹配未包含的任意字符。例如, '[^abc]' 可以匹配 "plain" 中的'p'。 | 241 | | p1\|p2\|p3 | 匹配 p1 或 p2 或 p3。例如,'z\|food' 能匹配 "z" 或 "food"。'(z\|f)ood' 则匹配 "zood" 或 "food"。 | 242 | | \* | 匹配前面的子表达式零次或多次。例如,zo* 能匹配 "z" 以及 "zoo"。* 等价于{0,}。 | 243 | | + | 匹配前面的子表达式一次或多次。例如,'zo+' 能匹配 "zo" 以及 "zoo",但不能匹配 "z"。+ 等价于 {1,}。 | 244 | | {n} | n 是一个非负整数。匹配确定的 n 次。例如,'o{2}' 不能匹配 "Bob" 中的 'o',但是能匹配 "food" 中的两个 o。 | 245 | | {n,m} | m 和 n 均为非负整数,其中 n <= m。最少匹配 n 次且最多匹配 m 次。 | 246 | 247 | ## 列表数据 248 | 249 | 之前我们看到返回的数据是这样的 250 | 251 | ```json 252 | { 253 | "Moment": { 254 | "content": "1111534034", 255 | "date": "2017-02-08 16:06:11.0", 256 | "id": 12, 257 | "pictureList": [ 258 | "http://static.oschina.net/uploads/img/201604/22172508_eGDi.jpg", 259 | "http://static.oschina.net/uploads/img/201604/22172507_rrZ5.jpg" 260 | ], 261 | "praiseUserIdList": [70793, 93793, 82001], 262 | "userId": 70793 263 | }, 264 | "code": 200, 265 | "msg": "success" 266 | } 267 | ``` 268 | 269 | 里面的`pictureList`和`praiseUserIdList`是数组,这种数据在 Mysql 数据库中是 JSON 数据格式的。 270 | 271 | ![1542357146401](../.vuepress/public/assets/1542357146401.png) 272 | 273 | 数据库里存储的值是这样的 274 | 275 | ![1542357265371](../.vuepress/public/assets/1542357265371.png) 276 | 277 | 如果我们想过滤出里面有`82001`的数据,我们应该这样请求 278 | 279 | ```json 280 | { 281 | "[]": { 282 | "Moment": { 283 | "praiseUserIdList<>": 82001, 284 | "@column": "id,date,content,praiseUserIdList" 285 | } 286 | } 287 | } 288 | ``` 289 | 290 | 结果是类似这样的,为了显示方便剔除了一些数据。 291 | 292 | ```json 293 | { 294 | "[]": [ 295 | { 296 | "Moment": { 297 | "date": "2017-02-08 16:06:11.0", 298 | "id": 32, 299 | "praiseUserIdList": [38710, 82002, 82001] 300 | } 301 | }, 302 | { 303 | "Moment": { 304 | "content": "This is a Content...-435", 305 | "date": "2017-02-01 19:14:31.0", 306 | "id": 58, 307 | "praiseUserIdList": [38710, 82003, 82001] 308 | } 309 | }, 310 | { 311 | "Moment": { 312 | "content": "https://gss2.bdstatic.com/-fo3dSag_xIb.jpg", 313 | "date": "2018-10-27 17:58:02.0", 314 | "id": 1540634282433, 315 | "praiseUserIdList": [82001] 316 | } 317 | } 318 | ], 319 | "code": 200, 320 | "msg": "success" 321 | } 322 | ``` 323 | 324 | ## 分页 325 | 326 | 对于数量太多的数据,我们很多时候都需要分页操作,这时候我们可以用类似下面这样的请求 327 | 328 | ```json 329 | { 330 | "[]": { 331 | "Moment": { 332 | "@column": "id,date,content,praiseUserIdList" 333 | }, 334 | "page": 0, 335 | "count": 5 336 | } 337 | } 338 | ``` 339 | 340 | 请注意,这里的`page`和`count`是放在`[]`内的属性,而不是`Moment`对象里。这里`count`表示每页的数量,`page`表示第几页,页数从 0 开始算。 341 | 342 | 也许你想看看这个请求对应的 SQL 语句 343 | 344 | ```sql 345 | SELECT `id`,`date`,`content`,`praiseUserIdList` FROM `thea`.`Moment` LIMIT 5 OFFSET 0 346 | ``` 347 | 348 | 这里`thea`是我自己的`schema`的名字,你的可能会有所不同。 349 | 350 | 如果不想分页的,也提供了一套特殊的查询方式。这种查询方式有三种,请求方式类型这样 351 | 352 | ```json 353 | { 354 | "[]": { 355 | "Moment": { 356 | "@column": "id,date,content,praiseUserIdList" 357 | }, 358 | "query": 2 359 | }, 360 | "total@": "/[]/total" 361 | } 362 | ``` 363 | 364 | 这里因为`query`的值是 2,所有会查询`Moment`表中所有的数据。如果是 1 的话,则会返回当前表的总数 365 | 366 | ```json 367 | { "total": 59, "code": 200, "msg": "success" } 368 | ``` 369 | 370 | 数据库中的数量: 371 | 372 | ![1544515879364](../.vuepress/public/assets/1544515879364.png) 373 | 374 | 当然,如果你添加了过滤条件,返回的数量就会是你所过滤的数量,比如: 375 | 376 | ```json 377 | { 378 | "[]": { 379 | "Moment": { 380 | "@column": "id,date,content,praiseUserIdList", 381 | "praiseUserIdList<>": 38710 382 | }, 383 | "query": 1 384 | }, 385 | "total@": "/[]/total" 386 | } 387 | ``` 388 | 389 | 返回: 390 | 391 | ```json 392 | { "total": 12, "code": 200, "msg": "success" } 393 | ``` 394 | 395 | ## 排序 396 | 397 | 要使用排序的话,这样操作 398 | 399 | ```json 400 | { 401 | "[]": { 402 | "Moment": { 403 | "@column": "id,date,content,praiseUserIdList", 404 | "praiseUserIdList<>": 38710, 405 | "@order": "date-,id,content+" 406 | } 407 | } 408 | } 409 | ``` 410 | 411 | `"@order":"date-,id,content+"`其中,字段的前后顺序表示字段排序的优先级。`id`和`id+`是等价的,默认就是升序排列。`date-`表示将`date`字段降序排列。 412 | 413 | ## 关联查询 414 | 415 | 在讲解关联查询的时候,我们需要先了解下表之间的关系 416 | 417 | 现在有两张表 USER 和 MOMENT,两张表的关系是下面这样 418 | 419 | ![1545468294295](../.vuepress/public/assets/1545468294295.png) 420 | 421 | MOMENT 表示评论,每一条评论会有一个发表评论的用户 USER,所以 MOMENT 表里会有一个 USER 表的外键关联 422 | 423 | 对于这样的数据关系,我们在查询评论时,很多时候我们会连带着用户一起查处来,这样又如何操作呢 424 | 425 | ```json 426 | { 427 | "[]": { 428 | "Moment": { 429 | "@column": "id,date,userId", 430 | "id": 12 431 | }, 432 | "User": { 433 | "id@": "/Moment/userId", 434 | "@column": "id,name" 435 | } 436 | } 437 | } 438 | ``` 439 | 440 | 这个请求稍微复杂点,首先我们用`[]`对象表示我们是想查询出一个列表,这个列表包含两个部分`Moment`和`User`。 441 | 442 | 其中`Moment`是我们想要查询的主要内容,它的写法也和一般查询数据时无异。 443 | 444 | `User`是与`Moment`相关联的数据,所以查询的时候我们需要用`id@`来表示他们之间的关联关系 445 | 446 | `/Moment/userId`中,最开始的`/`相当于是指明了`[]`的位置,`/Moment`表示`[]`对象下的`Moemnt`对象,`/Moment/userId`表示`Moemnt`的`userId`字段是与`User`的`id`关联的。 447 | 448 | 响应的数据: 449 | 450 | ```json 451 | { 452 | "[]": [ 453 | { 454 | "Moment": { 455 | "date": "2017-02-08 16:06:11.0", 456 | "id": 12, 457 | "userId": 70793 458 | }, 459 | "User": { 460 | "id": 70793, 461 | "name": "Strong" 462 | } 463 | } 464 | ], 465 | "code": 200, 466 | "msg": "success" 467 | } 468 | ``` 469 | 470 | ## 分组查询 471 | 472 | 在了解分组查询之前,我们需要先了解下 APIJSON 所支持的函数 473 | 474 | | 函数名 | 说明 | 475 | | ------ | -------------------------- | 476 | | count | 统计分组下,某字段的个数 | 477 | | sum | 统计分组下,某字段的和 | 478 | | max | 统计分组下,某字段的最大值 | 479 | | min | 统计分组下,某字段的最小值 | 480 | | avg | 统计分组下,某字段的平均值 | 481 | 482 | 比如,如果只是单纯的查出最大值,这样请求就可以了 483 | 484 | ```json 485 | { 486 | "[]": { 487 | "Moment": { 488 | "@column": "max(id):maxid" 489 | } 490 | } 491 | } 492 | ``` 493 | 494 | 响应: 495 | 496 | ```json 497 | { 498 | "[]": [ 499 | { 500 | "Moment": { 501 | "maxid": 1541912160047 502 | } 503 | } 504 | ], 505 | "code": 200, 506 | "msg": "success" 507 | } 508 | ``` 509 | 510 | 这里`maxid`是我们取的别名 511 | 512 | 如果是有分组条件的,那我们需要使用`@group` 513 | 514 | 比如,像下面 SALE 表,这张表表示,2018 年 1 月 1 日某公司门下的 3 个店铺(STORE_ID)的营业额(AMT)数据 515 | 516 | | ID | STORE_ID | AMT | 517 | | --- | -------- | --- | 518 | | 1 | 1 | 100 | 519 | | 2 | 1 | 80 | 520 | | 3 | 2 | 30 | 521 | | 4 | 2 | 100 | 522 | | 5 | 3 | 210 | 523 | 524 | 如果,我们想要计算出这天每个店铺一共卖了多少,我们通过 APIJSON 可以这样查询 525 | 526 | ``` 527 | { 528 | "[]": { 529 | "Sale":{ 530 | "@column":"store_id,sum(amt):totAmt", 531 | "@group":"store_id" 532 | } 533 | } 534 | } 535 | ``` 536 | 537 | ### 登录 538 | 539 | 如果没有登录,由于权限的限制,是需要登录的。 540 | 541 | 登录地址`http://127.0.0.1:8080/login`,发送请求 542 | 543 | ```json 544 | { 545 | "phone": "13000038710", 546 | "password": "apijson" 547 | } 548 | ``` 549 | 550 | 账号和密码,可以到`apijson_user`里面查询 551 | 552 | ### 测试新增 553 | 554 | 接口地址:`http://localhost:8080/post` 555 | 556 | 我们想新增一条备注时,发送这样的请求 557 | 558 | 请求 559 | 560 | ```json 561 | { 562 | "Moment": { 563 | "content": "今天天气不错,到处都是提拉米苏雪", 564 | "userId": 38710 565 | }, 566 | "tag": "Moment" 567 | } 568 | ``` 569 | 570 | `tag`是我们在`request`表里面配置的`tag`字段。 571 | 572 | 响应 573 | 574 | ```json 575 | { 576 | "Moment": { 577 | "code": 200, 578 | "count": 1, 579 | "id": 1544520921923, 580 | "msg": "success" 581 | }, 582 | "code": 200, 583 | "msg": "success" 584 | } 585 | ``` 586 | 587 | 返回的`id`是新增的数据的新 id 588 | 589 | ### 测试修改 590 | 591 | 接口地址:`http://localhost:8080/put` 592 | 593 | 修改备注和新增类似 594 | 595 | 请求 596 | 597 | ```json 598 | { 599 | "Moment": { 600 | "id": 1544520921923, 601 | "content": "海洋动物数量减少,如果非吃不可,不点杀也是在保护它们" 602 | }, 603 | "tag": "Moment" 604 | } 605 | ``` 606 | 607 | 响应 608 | 609 | ```json 610 | { 611 | "Moment": { 612 | "code": 200, 613 | "count": 1, 614 | "id": 1544520921923, 615 | "msg": "success" 616 | }, 617 | "code": 200, 618 | "msg": "success" 619 | } 620 | ``` 621 | 622 | 如果要对`json`类型操作的话,这样请求 623 | 624 | ```json 625 | { 626 | "Moment": { 627 | "id": 1544520921923, 628 | "praiseUserIdList+": [123] 629 | }, 630 | "tag": "Moment" 631 | } 632 | ``` 633 | 634 | 这里的`praiseUserIdList`是一个`json`类型的字段,在操作之前它是空的`[]`,提交以后它是`[123]`,如果再添加一个 21,则会变成`[123,21]` 635 | 636 | 要删除其中的值,把`+`变成`-`即可 637 | 638 | ### 测试删除 639 | 640 | 接口地址:`http://localhost:8080/delete` 641 | 642 | 请求 643 | 644 | ```json 645 | { 646 | "Moment": { 647 | "id": 1544520921923 648 | }, 649 | "tag": "Moment" 650 | } 651 | ``` 652 | -------------------------------------------------------------------------------- /docs/zh/install.md: -------------------------------------------------------------------------------- 1 | # 安装 2 | 3 | ## 环境配置 4 | 5 | JDK: 1.8+ 6 | 7 | MAVEN: 3.0+ 8 | 9 | Mysql / Oracle 10 | 11 | Eclipse Java EE IDE for Web Developers.Version: Mars.1 Release (4.5.1) 12 | 13 | ## 下载项目 14 | 15 | ```git 16 | git clone https://github.com/TommyLemon/APIJSON.git 17 | ``` 18 | 19 | 或者,直接下载 ZIP 打包好的项目文件。 20 | 21 | ![install1](../.vuepress/public/assets/install1.png) 22 | 23 | ## 导入项目 24 | 25 | Eclipse 导入: 26 | 27 | 顶部菜单 File > Import > Maven > Existing Maven Projects > Next > Browse 28 | 29 | 选择项目所在目录/APIJSON-Master/APIJSON-Java-Server/APIJSONBoot 30 | 31 | 当报依赖错误的时候,将同目录下的 libs 里面的 jar 包添加到 Build Path 中。 32 | ![install2](../.vuepress/public/assets/install2.png) 33 | 34 | 为了方便修改源代码,你可以像我一样不添加 libs/apijson-orm-3.5.1.jar 文件到 Build Path 中。而是将 libs/apijson-orm-3.5.1.jar 的源码,复制到当前项目里,然后添加到 Build Path 中。 35 | 36 | 源代码在 APIJSON-Master/APIJSON-Java-Server/APIJSONORM。 37 | 38 | ## 错误修改 39 | 40 | 有可能 pom.xml 会报错,例如: 41 | 42 | ```java 43 | 45 | ``` 46 | 47 | 这段代码中的这一句提示错误: 48 | 49 | ```java 50 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 51 | ``` 52 | 53 | 修改步骤: 54 | 55 | - 请修改 Eclipse 中的 Maven 镜像地址,以便更快下载或者更新,具体方法自行百度; 56 | - 打开 Eclipse->Windows->Preferences->Maven->Installations->add 这个按钮用于指定 maven 的安装目录。这里不建议使用 eclipse 自带的,需要再自己设置。最终效果如下图所示: 57 | ![install3](../.vuepress/public/assets/install3.png) 58 | - 打开 Eclipse->Windows->Preferences->Maven->User Settings 这是指定 setting.xml 的位置,同时导向自己的本地 maven 仓库。最终效果如下图所示: 59 | ![install4](../.vuepress/public/assets/install4.png) 60 | 61 | 以上截图仅为示例,实际路径请以自己设定为准。 62 | -------------------------------------------------------------------------------- /docs/zh/nested/README.md: -------------------------------------------------------------------------------- 1 | # 测试多语言模式 zh>nested>README.md 2 | 3 | ## 标题一 4 | 5 | ### 标题一->内容一 6 | 7 | # 测试多语言模式 二 zh>nested>README.md 8 | 9 | ## 标题二 10 | 11 | ### 标题二->内容二 12 | -------------------------------------------------------------------------------- /docs/zh/newinterface.md: -------------------------------------------------------------------------------- 1 | # 新增接口 2 | 3 | ## 后台添加数据表 4 | 5 | 在自己的数据库里新增一个表,比如我这里新增`b_stone` 6 | 7 | ```sql 8 | -- 原石 9 | CREATE TABLE `b_stone` ( 10 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 11 | `cost` int(10) NULL COMMENT '成本', 12 | `price` int(10) NULL COMMENT '卖价', 13 | `length` int(10) NULL, 14 | `width` int(10) NULL, 15 | `height` int(10) NULL, 16 | `weight` float(8,1) NULL, 17 | `creationdate` datetime default CURRENT_TIMESTAMP COMMENT '创建时间', 18 | `modifydate` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', 19 | `modifier` varchar(80) NULL, 20 | PRIMARY KEY (`id`) 21 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; 22 | ``` 23 | 24 | ## 在 Model 中添加对象并配置权限 25 | 26 | 项目的 model 目录下,新增一个类 27 | 28 | ```java 29 | package apijson.demo.server.model; 30 | 31 | import zuo.biao.apijson.MethodAccess; 32 | 33 | @MethodAccess 34 | public class Stone { 35 | } 36 | ``` 37 | 38 | 注解`@MethodAccess`的配置,可以参考其他类 39 | 40 | 由于我们的类名和数据库表名不一致,需要注册一下。如果一样就不需要了。 41 | 42 | 设置数据库的实际表名`DemoSQLConfig`,38 行 43 | 44 | ```java 45 | //表名映射,隐藏真实表名,对安全要求很高的表可以这么做 46 | static { 47 | TABLE_KEY_MAP.put(User.class.getSimpleName(), "apijson_user"); 48 | TABLE_KEY_MAP.put(Privacy.class.getSimpleName(), "apijson_privacy"); 49 | TABLE_KEY_MAP.put(Stone.class.getSimpleName(), "b_stone"); // <--这一句 50 | } 51 | ``` 52 | 53 | 注册权限是必须的,这样程序才能使用你配置的类权限去管理你的接口 54 | 55 | `DemoSQLConfig`,48 行 56 | 57 | ```java 58 | static { //注册权限 59 | ACCESS_MAP.put(User.class.getSimpleName(), getAccessMap(User.class.getAnnotation(MethodAccess.class))); 60 | .... 61 | ACCESS_MAP.put(Stone.class.getSimpleName(), getAccessMap(Stone.class.getAnnotation(MethodAccess.class))); 62 | } 63 | ``` 64 | ## 权限管理 Access 表的配置 65 | 66 | 在access数据表中添加一条数据,比如你的表名是:eye_director,而entity的类名是:EyeDirector 67 | 68 | ```sql 69 | INSERT INTO `apijson`.`access` (`id`, `debug`, `name`, `alias`, `get`, `head`, `gets`, `heads`, `post`, `put`, `delete`, `date`) VALUES ('19', '0', 'eye_director', 'EyeDirector', '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["UNKNOWN", "LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["LOGIN", "CONTACT", "CIRCLE", "OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '["OWNER", "ADMIN"]', '2020-03-02 18:23:37'); 70 | ``` 71 | 72 | ## 接口管理 Request 表的配置 73 | 74 | (此处需要作者补充) 75 | 76 | :first_quarter_moon_with_face:此处的介绍都只是简要介绍,只是为了引导刚刚接触 APIJSON 的道友快速了解 APIJSON,并不代表 APIJSON 只有这些功能,具体功能详情参考下列图表 77 | -------------------------------------------------------------------------------- /docs/zh/sqlconfig.md: -------------------------------------------------------------------------------- 1 | # 数据库 2 | 3 | 以下是基于 Mysql 数据库的开发流程示例 4 | 5 | ## 配置 6 | 7 | | 数据库参数 | 值 | 8 | | ---------- | ------------------- | 9 | | 地址 | 192.168.71.146:3306 | 10 | | 用户 | root | 11 | | 密码 | root | 12 | | 数据库 | thea | 13 | 14 | 那么需要在 DemoSQLConfig,40-61 行,改为自己数据库对应的链接 15 | 16 | ```java 17 | @Override 18 | public String getDBUri() { 19 | //TODO 改成你自己的 20 | return DATABASE_POSTGRESQL.equalsIgnoreCase(getDatabase()) ? "jdbc:postgresql://localhost:5432/postgres" : "jdbc:mysql://192.168.71.146:3306/"; 21 | } 22 | @Override 23 | public String getDBAccount() { 24 | return DATABASE_POSTGRESQL.equalsIgnoreCase(getDatabase()) ? "postgres" : "root"; //TODO 改成你自己的 25 | } 26 | @Override 27 | public String getDBPassword() { 28 | return DATABASE_POSTGRESQL.equalsIgnoreCase(getDatabase()) ? null : "root"; //TODO 改成你自己的 29 | } 30 | @Override 31 | public String getSchema() { 32 | String s = super.getSchema(); 33 | return StringUtil.isEmpty(s, true) ? "thea" : s; //TODO 改成你自己的。例如:将"thea"替换成你自己的“数据库名字” 34 | } 35 | ``` 36 | 37 | ## 导入表 38 | 39 | 在 APIJSON-Master/MySQL 目录下有一批 SQL 脚本,他们看起来是这样的: 40 | 41 | ![use1](../.vuepress/public/assets/use1.png) 42 | 43 | 导入完成之后。我们可以把项目跑起来看下,以刚刚配置的项目,项目是否能够连上数据库。其中也有一些初始化数据,可以方便我们测试。 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "vuepress": "^1.0.1" 4 | }, 5 | "scripts": { 6 | "docs:dev": "vuepress dev docs", 7 | "docs:build": "vuepress build docs" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /yarn-error.log: -------------------------------------------------------------------------------- 1 | Arguments: 2 | C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Yarn\bin\yarn.js docs:dev 3 | 4 | PATH: 5 | C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Administrator\bin;C:\Ruby25-x64\bin;C:\ProgramData\Boxstarter;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\chocolatey\bin;C:\Program Files\MongoDB\Server\3.4\bin;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\PuTTY;C:\Program Files\Redis;C:\Program Files\nodejs;C:\Program Files (x86)\Yarn\bin;D:\cmder;C:\Program Files\PowerShell\6;C:\Users\Administrator\AppData\Roaming\npm;D:\MavenWorkSpace\apache-maven-3.6.1\bin;C:\Program Files\Java\jdk1.8.0_191\bin;C:\Program Files\Java\jdk1.8.0_191\jre\bin;D:\Apache\apache-tomcat-7.0.94\bin;D:\Apache\apache-tomcat-7.0.94\lib;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin 6 | 7 | Yarn version: 8 | 1.15.2 9 | 10 | Node version: 11 | 10.15.3 12 | 13 | Platform: 14 | win32 x64 15 | 16 | Trace: 17 | SyntaxError: D:\VueWorkSpace\vue-press\vue-press-learn-001\package.json: Unexpected string in JSON at position 56 18 | at JSON.parse () 19 | at C:\Program Files (x86)\Yarn\lib\cli.js:1625:59 20 | at Generator.next () 21 | at step (C:\Program Files (x86)\Yarn\lib\cli.js:304:30) 22 | at C:\Program Files (x86)\Yarn\lib\cli.js:315:13 23 | 24 | npm manifest: 25 | { 26 | "devDependencies": { 27 | "vuepress": "^1.0.1" 28 | } 29 | 30 | "scripts": { 31 | "docs:dev":"vuepress dev docs", 32 | "docs:build":"vuepress build docs" 33 | } 34 | } 35 | 36 | yarn manifest: 37 | No manifest 38 | 39 | Lockfile: 40 | No lockfile 41 | --------------------------------------------------------------------------------