├── .env.example ├── .github └── workflows │ └── build.yml ├── .gitignore ├── Dockerfile ├── Dockerfile_hub ├── LICENSE ├── README.md ├── api ├── info.go ├── main.go └── user.go ├── conf └── conf.go ├── doc ├── README.md └── git .md ├── go.mod ├── main.go ├── middleware └── cors.go ├── model ├── code.go ├── com_district.go ├── db2.doc.md ├── doc.md ├── init.go ├── report.go └── user.go ├── serializer ├── info.go ├── main.go ├── report.go ├── user.go └── user_info.go ├── server └── router.go └── service ├── check_is_registered.go ├── check_user.go ├── get_bind_info.go ├── get_corpname_service.go ├── get_last_data.go ├── get_user_info.go ├── save_daily_info_service.go ├── user_bind_service.go ├── user_openid_service.go └── wexin_user_register.go /.env.example: -------------------------------------------------------------------------------- 1 | MYSQL_DSN="db_user:db_passwd@tcp(127.0.0.1:3306)/db_name?charset=utf8&parseTime=True&loc=Local" # Mysql连接配置 2 | GIN_MODE="debug" # 设置gin的运行模式,有 debug 和 release 3 | APP_ID="" #appid 4 | APP_SECRET="" #appsecret 5 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | 11 | build: 12 | name: Build 13 | runs-on: ubuntu-latest 14 | steps: 15 | 16 | - name: Set up Go 1.13 17 | uses: actions/setup-go@v1 18 | with: 19 | go-version: 1.13 20 | id: go 21 | 22 | - name: Check out code into the Go module directory 23 | uses: actions/checkout@v2 24 | 25 | - name: Get dependencies 26 | run: | 27 | go get -v -t -d ./... 28 | if [ -f Gopkg.toml ]; then 29 | curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh 30 | dep ensure 31 | fi 32 | - name: Build go 33 | run: go build -v . 34 | 35 | - name: Login to docker hub 36 | uses: actions-hub/docker/login@master 37 | env: 38 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 39 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 40 | 41 | - name: Build Docker :latest 42 | run: docker build -f Dockerfile_hub -t ${{ secrets.GITHUB_REPOSITORY }}:latest . 43 | 44 | - name: Build & Push to docker hub :latest 45 | uses: actions-hub/docker@master 46 | with: 47 | args: push ${{ secrets.GITHUB_REPOSITORY }}:latest -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #go 2 | go.sum 3 | 4 | # Windows 5 | [Dd]esktop.ini 6 | Thumbs.db 7 | $RECYCLE.BIN/ 8 | 9 | # macOS 10 | .DS_Store 11 | .fseventsd 12 | .Spotlight-V100 13 | .TemporaryItems 14 | .Trashes 15 | 16 | # Node.js 17 | node_modules/ 18 | 19 | #thinkphp 20 | .idea 21 | /.vscode 22 | *.log 23 | .env 24 | /runtime 25 | 26 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang as build 2 | 3 | ADD . /usr/local/go/src/MiniProgram-server-Golang 4 | 5 | WORKDIR /usr/local/go/src/MiniProgram-server-Golang 6 | 7 | RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOPROXY="https://goproxy.io" go build -o ncov_golang 8 | 9 | FROM alpine:3.7 10 | 11 | ENV MYSQL_DSN="" 12 | ENV GIN_MODE="release" 13 | ENV PORT=8080 14 | 15 | RUN echo "http://mirrors.aliyun.com/alpine/v3.7/main/" > /etc/apk/repositories && \ 16 | apk update && \ 17 | apk add ca-certificates && \ 18 | echo "hosts:files dns" > /etc/nsswitch.conf && \ 19 | mkdir -p /www/conf 20 | 21 | WORKDIR /www 22 | 23 | COPY --from=build /usr/local/go/src/MiniProgram-server-Golang/ncov_golang /usr/bin/ncov_golang 24 | ADD ./conf /www/conf 25 | 26 | RUN chmod +x /usr/bin/ncov_golang 27 | 28 | ENTRYPOINT ["ncov_golang"] -------------------------------------------------------------------------------- /Dockerfile_hub: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | 3 | ENV MYSQL_DSN="" 4 | ENV GIN_MODE="release" 5 | ENV PORT=8080 6 | 7 | RUN apk update && \ 8 | apk add ca-certificates && \ 9 | echo "hosts:files dns" > /etc/nsswitch.conf && \ 10 | mkdir -p /www/conf 11 | 12 | WORKDIR /www 13 | 14 | ADD ./Miniprogram-server-Golang /usr/bin/ncov_golang 15 | ADD ./conf /www/conf 16 | 17 | RUN chmod +x /usr/bin/ncov_golang 18 | 19 | ENTRYPOINT ["ncov_golang"] -------------------------------------------------------------------------------- /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 [yyyy] [name of copyright owner] 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 | # ncov-report-wx-server-Golang 2 | 3 | > 这里是NCOV 2020疫情防控-人员健康管理平台开源项目的小程序后端--Golang版本。 详细项目记录及学习文档见[doc文件夹](https://github.com/huagua/MiniProgram-server-Golang/tree/master/doc) 4 | 5 | 主项目入口 >> https://github.com/2020NCOV/ncov-report 6 | 7 | ![build](https://github.com/2020NCOV/MiniProgram-server-Golang/workflows/build/badge.svg) 8 | 9 | ## 项目导航 10 | - [ncov-report-wx-server-Golang](#ncov-report-wx-server-golang) 11 | - [项目导航](#项目导航) 12 | - [目录结构](#目录结构) 13 | - [与小程序交互流程](#与小程序交互流程) 14 | - [项目本地配置](#项目本地配置) 15 | 16 | ## 目录结构 17 | ``` 18 | |-- MiniProgram-server-Golang 19 | |-- .env.example —— 这个是对环境变量如何设置的示例,在自己的项目中新建一个.env文件 20 | |-- .gitignore—— 上传代码时一些不需要上传的文件就加入.gitignore 21 | |-- go.mod —— Golang包管理工具 22 | |-- main.go —— 项目入口 23 | |-- **api**—— 定义接口 24 | | |-- main.go 通用接口 25 | | |-- user.go 用户相关的接口 26 | |-- conf —— 配置文件 27 | | |-- conf.go 28 | |-- middleware—— 中间件 29 | | |-- cors.go 跨域相关设置 30 | |-- **model**——主要数据库表的设计,这里是重点需要修改的地方,需要配合统一的数据库表结构 31 | | |-- code.go 32 | | |-- init.go 33 | | |-- migration.go 34 | | |-- report.go 35 | | |-- user.go 36 | |-- **serializer**——序列化器,返回请求时用来序列化数据 37 | | |-- main.go 38 | | |-- report.go 39 | | |-- user.go 40 | |-- **server**——主要定义了路由 41 | | |-- router.go 42 | |-- **service** —— 针对每个请求的具体服务逻辑 43 | |-- check_is_registered.go 44 | |-- check_user.go 45 | |-- get_corpname_service.go 46 | |-- get_info_service.go 47 | |-- save_daily_info_service.go 48 | |-- user_bind_service.go 49 | |-- user_openid_service.go 50 | |-- wexin_user_register.go 51 | ``` 52 | **核心部分就是以上加星部分的文件** 53 | 54 | ## 与小程序交互流程 55 | 以getcode接口为例 56 | 57 | ![流程图](http://q6uspeueh.bkt.clouddn.com/requestRoute.png) 58 | 59 | ## 项目本地配置 60 | ### 1.导入Goland 61 | 可能会下载一会儿包,稍微等待一下。将项目创建在%GOPATH%/src目录下可以加载之前已经安装在%GOPATH%/pkg中的包。 62 | 63 | ### 2.在项目根目录新建文件.env, 内容如下: 64 | ``` 65 | MYSQL_DSN="db_user:db_passwd@tcp(127.0.0.1:3306)/db_name?charset=utf8&parseTime=True&loc=Local" # Mysql连接配置 66 | GIN_MODE="debug" # 设置gin的运行模式,有 debug 和 release 67 | APP_ID="" #appid 68 | APP_SECRET="" #appsecret 69 | ``` 70 | 注: 71 | - 将db_user和db_passwd修改为自己本地的mysql连接的用户名和密码,并创建相应的数据库,将db_name替换成对应数据库名 72 | - 补充自己注册的小程序的app_id和app_secret 73 | 74 | ### 3. 执行命令go run main.go, 如果RUN窗口出现如下字样,则代表后端程序启动成功 75 | ``` 76 | [GIN-debug] POST /index/login/getcode --> Miniprogram-server-Golang/api.UserLogin (3 handlers) 77 | [GIN-debug] POST /index/login/check_is_registered --> Miniprogram-server-Golang/api.UserIsReg (3 handlers) 78 | [GIN-debug] POST /index/login/check_user --> Miniprogram-server-Golang/api.CheckUser (3 handlers) 79 | [GIN-debug] POST /index/login/register --> Miniprogram-server-Golang/api.WeixinUsrRegister (3 handlers) 80 | [GIN-debug] POST /index/login/getcorpname --> Miniprogram-server-Golang/api.GetCorp (3 handlers) 81 | [GIN-debug] POST /index/login/bind --> Miniprogram-server-Golang/api.UserBind (3 handlers) 82 | [GIN-debug] POST /index/login/unbind --> Miniprogram-server-Golang/api.UserUnBind (3 handlers) 83 | [GIN-debug] POST /index/report/save --> Miniprogram-server-Golang/api.SaveInfo (3 handlers) 84 | [GIN-debug] POST /index/report/getlastdata --> Miniprogram-server-Golang/api.GetInfo (3 handlers) 85 | [GIN-debug] POST /index/info/getmyinfo --> Miniprogram-server-Golang/api.GetUserInfo (3 handlers) 86 | [GIN-debug] Listening and serving HTTP on :8080 87 | ``` 88 | ### 4.修改小程序端的baseURL,在/ncov-report-mini-program/util/config.js文件中 89 | ``` 90 | const baseURL = 'http://127.0.0.1:8080/index'; //这表示小程序访问的是本机的8080端口,正是后端程序监听的端口 91 | ``` 92 | ### 5.测试接口 93 | - 编译运行小程序 94 | - 打开调试器,点击network 95 | - 查看小程序发出的请求getcode,如果返回status code是200OK则表示前后端通信成功 96 | -------------------------------------------------------------------------------- /api/info.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "Miniprogram-server-Golang/service" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | // GetBindInfo 检查用户绑定信息接口 9 | func GetBindInfo(c *gin.Context) { 10 | var service service.GetBindInfoService 11 | if err := c.ShouldBind(&service); err == nil { 12 | res := service.GetBindInfo(c) 13 | if res.Data != nil { 14 | c.JSON(200, res.Data) 15 | } else { 16 | c.JSON(200, res) 17 | } 18 | } else { 19 | c.JSON(200, ErrorResponse(err)) 20 | } 21 | } 22 | 23 | func GetAll(c *gin.Context) { 24 | res := `{"data":{"level_data":[{"name":"省","level":1,"id":1},{"name":"市","level":2,"id":2}],"tree_data":[{"id":1100000,"parent_id":0,"name":"北京市","value":1100000,"seq":0,"level_id":1,"children":[{"id":1101000,"parent_id":1100000,"name":"直辖区","value":1101000,"seq":2,"level_id":2,"children":[]}]},{"id":1200000,"parent_id":0,"name":"天津市","value":1200000,"seq":0,"level_id":1,"children":[{"id":1201000,"parent_id":1200000,"name":"直辖区","value":1201000,"seq":4,"level_id":2,"children":[]}]},{"id":1300000,"parent_id":0,"name":"河北省","value":1300000,"seq":0,"level_id":1,"children":[{"id":1301000,"parent_id":1300000,"name":"石家庄市","value":1301000,"seq":6,"level_id":2,"children":[]},{"id":1302000,"parent_id":1300000,"name":"唐山市","value":1302000,"seq":7,"level_id":2,"children":[]},{"id":1303000,"parent_id":1300000,"name":"秦皇岛市","value":1303000,"seq":8,"level_id":2,"children":[]},{"id":1304000,"parent_id":1300000,"name":"邯郸市","value":1304000,"seq":9,"level_id":2,"children":[]},{"id":1305000,"parent_id":1300000,"name":"邢台市","value":1305000,"seq":10,"level_id":2,"children":[]},{"id":1306000,"parent_id":1300000,"name":"保定市","value":1306000,"seq":11,"level_id":2,"children":[]},{"id":1307000,"parent_id":1300000,"name":"张家口市","value":1307000,"seq":12,"level_id":2,"children":[]},{"id":1308000,"parent_id":1300000,"name":"承德市","value":1308000,"seq":13,"level_id":2,"children":[]},{"id":1309000,"parent_id":1300000,"name":"沧州市","value":1309000,"seq":14,"level_id":2,"children":[]},{"id":1310000,"parent_id":1300000,"name":"廊坊市","value":1310000,"seq":15,"level_id":2,"children":[]},{"id":1311000,"parent_id":1300000,"name":"衡水市","value":1311000,"seq":16,"level_id":2,"children":[]}]},{"id":1400000,"parent_id":0,"name":"山西省","value":1400000,"seq":0,"level_id":1,"children":[{"id":1401000,"parent_id":1400000,"name":"太原市","value":1401000,"seq":18,"level_id":2,"children":[]},{"id":1402000,"parent_id":1400000,"name":"大同市","value":1402000,"seq":19,"level_id":2,"children":[]},{"id":1403000,"parent_id":1400000,"name":"阳泉市","value":1403000,"seq":20,"level_id":2,"children":[]},{"id":1404000,"parent_id":1400000,"name":"长治市","value":1404000,"seq":21,"level_id":2,"children":[]},{"id":1405000,"parent_id":1400000,"name":"晋城市","value":1405000,"seq":22,"level_id":2,"children":[]},{"id":1406000,"parent_id":1400000,"name":"朔州市","value":1406000,"seq":23,"level_id":2,"children":[]},{"id":1407000,"parent_id":1400000,"name":"晋中市","value":1407000,"seq":24,"level_id":2,"children":[]},{"id":1408000,"parent_id":1400000,"name":"运城市","value":1408000,"seq":25,"level_id":2,"children":[]},{"id":1409000,"parent_id":1400000,"name":"忻州市","value":1409000,"seq":26,"level_id":2,"children":[]},{"id":1410000,"parent_id":1400000,"name":"临汾市","value":1410000,"seq":27,"level_id":2,"children":[]},{"id":1411000,"parent_id":1400000,"name":"吕梁市","value":1411000,"seq":28,"level_id":2,"children":[]}]},{"id":1500000,"parent_id":0,"name":"内蒙古自治区","value":1500000,"seq":0,"level_id":1,"children":[{"id":1501000,"parent_id":1500000,"name":"呼和浩特市","value":1501000,"seq":30,"level_id":2,"children":[]},{"id":1502000,"parent_id":1500000,"name":"包头市","value":1502000,"seq":31,"level_id":2,"children":[]},{"id":1503000,"parent_id":1500000,"name":"乌海市","value":1503000,"seq":32,"level_id":2,"children":[]},{"id":1504000,"parent_id":1500000,"name":"赤峰市","value":1504000,"seq":33,"level_id":2,"children":[]},{"id":1505000,"parent_id":1500000,"name":"通辽市","value":1505000,"seq":34,"level_id":2,"children":[]},{"id":1506000,"parent_id":1500000,"name":"鄂尔多斯市","value":1506000,"seq":35,"level_id":2,"children":[]},{"id":1507000,"parent_id":1500000,"name":"呼伦贝尔市","value":1507000,"seq":36,"level_id":2,"children":[]},{"id":1508000,"parent_id":1500000,"name":"巴彦淖尔市","value":1508000,"seq":37,"level_id":2,"children":[]},{"id":1509000,"parent_id":1500000,"name":"乌兰察布市","value":1509000,"seq":38,"level_id":2,"children":[]},{"id":1522000,"parent_id":1500000,"name":"兴安盟","value":1522000,"seq":39,"level_id":2,"children":[]},{"id":1525000,"parent_id":1500000,"name":"锡林郭勒盟","value":1525000,"seq":40,"level_id":2,"children":[]},{"id":1529000,"parent_id":1500000,"name":"阿拉善盟","value":1529000,"seq":41,"level_id":2,"children":[]}]},{"id":2100000,"parent_id":0,"name":"辽宁省","value":2100000,"seq":0,"level_id":1,"children":[{"id":2101000,"parent_id":2100000,"name":"沈阳市","value":2101000,"seq":43,"level_id":2,"children":[]},{"id":2102000,"parent_id":2100000,"name":"大连市","value":2102000,"seq":44,"level_id":2,"children":[]},{"id":2103000,"parent_id":2100000,"name":"鞍山市","value":2103000,"seq":45,"level_id":2,"children":[]},{"id":2104000,"parent_id":2100000,"name":"抚顺市","value":2104000,"seq":46,"level_id":2,"children":[]},{"id":2105000,"parent_id":2100000,"name":"本溪市","value":2105000,"seq":47,"level_id":2,"children":[]},{"id":2106000,"parent_id":2100000,"name":"丹东市","value":2106000,"seq":48,"level_id":2,"children":[]},{"id":2107000,"parent_id":2100000,"name":"锦州市","value":2107000,"seq":49,"level_id":2,"children":[]},{"id":2108000,"parent_id":2100000,"name":"营口市","value":2108000,"seq":50,"level_id":2,"children":[]},{"id":2109000,"parent_id":2100000,"name":"阜新市","value":2109000,"seq":51,"level_id":2,"children":[]},{"id":2110000,"parent_id":2100000,"name":"辽阳市","value":2110000,"seq":52,"level_id":2,"children":[]},{"id":2111000,"parent_id":2100000,"name":"盘锦市","value":2111000,"seq":53,"level_id":2,"children":[]},{"id":2112000,"parent_id":2100000,"name":"铁岭市","value":2112000,"seq":54,"level_id":2,"children":[]},{"id":2113000,"parent_id":2100000,"name":"朝阳市","value":2113000,"seq":55,"level_id":2,"children":[]},{"id":2114000,"parent_id":2100000,"name":"葫芦岛市","value":2114000,"seq":56,"level_id":2,"children":[]}]},{"id":2200000,"parent_id":0,"name":"吉林省","value":2200000,"seq":0,"level_id":1,"children":[{"id":2201000,"parent_id":2200000,"name":"长春市","value":2201000,"seq":58,"level_id":2,"children":[]},{"id":2202000,"parent_id":2200000,"name":"吉林市","value":2202000,"seq":59,"level_id":2,"children":[]},{"id":2203000,"parent_id":2200000,"name":"四平市","value":2203000,"seq":60,"level_id":2,"children":[]},{"id":2204000,"parent_id":2200000,"name":"辽源市","value":2204000,"seq":61,"level_id":2,"children":[]},{"id":2205000,"parent_id":2200000,"name":"通化市","value":2205000,"seq":62,"level_id":2,"children":[]},{"id":2206000,"parent_id":2200000,"name":"白山市","value":2206000,"seq":63,"level_id":2,"children":[]},{"id":2207000,"parent_id":2200000,"name":"松原市","value":2207000,"seq":64,"level_id":2,"children":[]},{"id":2208000,"parent_id":2200000,"name":"白城市","value":2208000,"seq":65,"level_id":2,"children":[]},{"id":2224000,"parent_id":2200000,"name":"延边朝鲜族自治州","value":2224000,"seq":66,"level_id":2,"children":[]}]},{"id":2300000,"parent_id":0,"name":"黑龙江省","value":2300000,"seq":0,"level_id":1,"children":[{"id":2301000,"parent_id":2300000,"name":"哈尔滨市","value":2301000,"seq":68,"level_id":2,"children":[]},{"id":2302000,"parent_id":2300000,"name":"齐齐哈尔市","value":2302000,"seq":69,"level_id":2,"children":[]},{"id":2303000,"parent_id":2300000,"name":"鸡西市","value":2303000,"seq":70,"level_id":2,"children":[]},{"id":2304000,"parent_id":2300000,"name":"鹤岗市","value":2304000,"seq":71,"level_id":2,"children":[]},{"id":2305000,"parent_id":2300000,"name":"双鸭山市","value":2305000,"seq":72,"level_id":2,"children":[]},{"id":2306000,"parent_id":2300000,"name":"大庆市","value":2306000,"seq":73,"level_id":2,"children":[]},{"id":2307000,"parent_id":2300000,"name":"伊春市","value":2307000,"seq":74,"level_id":2,"children":[]},{"id":2308000,"parent_id":2300000,"name":"佳木斯市","value":2308000,"seq":75,"level_id":2,"children":[]},{"id":2309000,"parent_id":2300000,"name":"七台河市","value":2309000,"seq":76,"level_id":2,"children":[]},{"id":2310000,"parent_id":2300000,"name":"牡丹江市","value":2310000,"seq":77,"level_id":2,"children":[]},{"id":2311000,"parent_id":2300000,"name":"黑河市","value":2311000,"seq":78,"level_id":2,"children":[]},{"id":2312000,"parent_id":2300000,"name":"绥化市","value":2312000,"seq":79,"level_id":2,"children":[]},{"id":2327000,"parent_id":2300000,"name":"大兴安岭地区","value":2327000,"seq":80,"level_id":2,"children":[]}]},{"id":3100000,"parent_id":0,"name":"上海市","value":3100000,"seq":0,"level_id":1,"children":[{"id":3101000,"parent_id":3100000,"name":"直辖区","value":3101000,"seq":82,"level_id":2,"children":[]}]},{"id":3200000,"parent_id":0,"name":"江苏省","value":3200000,"seq":0,"level_id":1,"children":[{"id":3201000,"parent_id":3200000,"name":"南京市","value":3201000,"seq":84,"level_id":2,"children":[]},{"id":3202000,"parent_id":3200000,"name":"无锡市","value":3202000,"seq":85,"level_id":2,"children":[]},{"id":3203000,"parent_id":3200000,"name":"徐州市","value":3203000,"seq":86,"level_id":2,"children":[]},{"id":3204000,"parent_id":3200000,"name":"常州市","value":3204000,"seq":87,"level_id":2,"children":[]},{"id":3205000,"parent_id":3200000,"name":"苏州市","value":3205000,"seq":88,"level_id":2,"children":[]},{"id":3206000,"parent_id":3200000,"name":"南通市","value":3206000,"seq":89,"level_id":2,"children":[]},{"id":3207000,"parent_id":3200000,"name":"连云港市","value":3207000,"seq":90,"level_id":2,"children":[]},{"id":3208000,"parent_id":3200000,"name":"淮安市","value":3208000,"seq":91,"level_id":2,"children":[]},{"id":3209000,"parent_id":3200000,"name":"盐城市","value":3209000,"seq":92,"level_id":2,"children":[]},{"id":3210000,"parent_id":3200000,"name":"扬州市","value":3210000,"seq":93,"level_id":2,"children":[]},{"id":3211000,"parent_id":3200000,"name":"镇江市","value":3211000,"seq":94,"level_id":2,"children":[]},{"id":3212000,"parent_id":3200000,"name":"泰州市","value":3212000,"seq":95,"level_id":2,"children":[]},{"id":3213000,"parent_id":3200000,"name":"宿迁市","value":3213000,"seq":96,"level_id":2,"children":[]}]},{"id":3300000,"parent_id":0,"name":"浙江省","value":3300000,"seq":0,"level_id":1,"children":[{"id":3301000,"parent_id":3300000,"name":"杭州市","value":3301000,"seq":98,"level_id":2,"children":[]},{"id":3302000,"parent_id":3300000,"name":"宁波市","value":3302000,"seq":99,"level_id":2,"children":[]},{"id":3303000,"parent_id":3300000,"name":"温州市","value":3303000,"seq":100,"level_id":2,"children":[]},{"id":3304000,"parent_id":3300000,"name":"嘉兴市","value":3304000,"seq":101,"level_id":2,"children":[]},{"id":3305000,"parent_id":3300000,"name":"湖州市","value":3305000,"seq":102,"level_id":2,"children":[]},{"id":3306000,"parent_id":3300000,"name":"绍兴市","value":3306000,"seq":103,"level_id":2,"children":[]},{"id":3307000,"parent_id":3300000,"name":"金华市","value":3307000,"seq":104,"level_id":2,"children":[]},{"id":3308000,"parent_id":3300000,"name":"衢州市","value":3308000,"seq":105,"level_id":2,"children":[]},{"id":3309000,"parent_id":3300000,"name":"舟山市","value":3309000,"seq":106,"level_id":2,"children":[]},{"id":3310000,"parent_id":3300000,"name":"台州市","value":3310000,"seq":107,"level_id":2,"children":[]},{"id":3311000,"parent_id":3300000,"name":"丽水市","value":3311000,"seq":108,"level_id":2,"children":[]}]},{"id":3400000,"parent_id":0,"name":"安徽省","value":3400000,"seq":0,"level_id":1,"children":[{"id":3401000,"parent_id":3400000,"name":"合肥市","value":3401000,"seq":110,"level_id":2,"children":[]},{"id":3402000,"parent_id":3400000,"name":"芜湖市","value":3402000,"seq":111,"level_id":2,"children":[]},{"id":3403000,"parent_id":3400000,"name":"蚌埠市","value":3403000,"seq":112,"level_id":2,"children":[]},{"id":3404000,"parent_id":3400000,"name":"淮南市","value":3404000,"seq":113,"level_id":2,"children":[]},{"id":3405000,"parent_id":3400000,"name":"马鞍山市","value":3405000,"seq":114,"level_id":2,"children":[]},{"id":3406000,"parent_id":3400000,"name":"淮北市","value":3406000,"seq":115,"level_id":2,"children":[]},{"id":3407000,"parent_id":3400000,"name":"铜陵市","value":3407000,"seq":116,"level_id":2,"children":[]},{"id":3408000,"parent_id":3400000,"name":"安庆市","value":3408000,"seq":117,"level_id":2,"children":[]},{"id":3410000,"parent_id":3400000,"name":"黄山市","value":3410000,"seq":118,"level_id":2,"children":[]},{"id":3411000,"parent_id":3400000,"name":"滁州市","value":3411000,"seq":119,"level_id":2,"children":[]},{"id":3412000,"parent_id":3400000,"name":"阜阳市","value":3412000,"seq":120,"level_id":2,"children":[]},{"id":3413000,"parent_id":3400000,"name":"宿州市","value":3413000,"seq":121,"level_id":2,"children":[]},{"id":3415000,"parent_id":3400000,"name":"六安市","value":3415000,"seq":122,"level_id":2,"children":[]},{"id":3416000,"parent_id":3400000,"name":"亳州市","value":3416000,"seq":123,"level_id":2,"children":[]},{"id":3417000,"parent_id":3400000,"name":"池州市","value":3417000,"seq":124,"level_id":2,"children":[]},{"id":3418000,"parent_id":3400000,"name":"宣城市","value":3418000,"seq":125,"level_id":2,"children":[]}]},{"id":3500000,"parent_id":0,"name":"福建省","value":3500000,"seq":0,"level_id":1,"children":[{"id":3501000,"parent_id":3500000,"name":"福州市","value":3501000,"seq":127,"level_id":2,"children":[]},{"id":3502000,"parent_id":3500000,"name":"厦门市","value":3502000,"seq":128,"level_id":2,"children":[]},{"id":3503000,"parent_id":3500000,"name":"莆田市","value":3503000,"seq":129,"level_id":2,"children":[]},{"id":3504000,"parent_id":3500000,"name":"三明市","value":3504000,"seq":130,"level_id":2,"children":[]},{"id":3505000,"parent_id":3500000,"name":"泉州市","value":3505000,"seq":131,"level_id":2,"children":[]},{"id":3506000,"parent_id":3500000,"name":"漳州市","value":3506000,"seq":132,"level_id":2,"children":[]},{"id":3507000,"parent_id":3500000,"name":"南平市","value":3507000,"seq":133,"level_id":2,"children":[]},{"id":3508000,"parent_id":3500000,"name":"龙岩市","value":3508000,"seq":134,"level_id":2,"children":[]},{"id":3509000,"parent_id":3500000,"name":"宁德市","value":3509000,"seq":135,"level_id":2,"children":[]}]},{"id":3600000,"parent_id":0,"name":"江西省","value":3600000,"seq":0,"level_id":1,"children":[{"id":3601000,"parent_id":3600000,"name":"南昌市","value":3601000,"seq":137,"level_id":2,"children":[]},{"id":3602000,"parent_id":3600000,"name":"景德镇市","value":3602000,"seq":138,"level_id":2,"children":[]},{"id":3603000,"parent_id":3600000,"name":"萍乡市","value":3603000,"seq":139,"level_id":2,"children":[]},{"id":3604000,"parent_id":3600000,"name":"九江市","value":3604000,"seq":140,"level_id":2,"children":[]},{"id":3605000,"parent_id":3600000,"name":"新余市","value":3605000,"seq":141,"level_id":2,"children":[]},{"id":3606000,"parent_id":3600000,"name":"鹰潭市","value":3606000,"seq":142,"level_id":2,"children":[]},{"id":3607000,"parent_id":3600000,"name":"赣州市","value":3607000,"seq":143,"level_id":2,"children":[]},{"id":3608000,"parent_id":3600000,"name":"吉安市","value":3608000,"seq":144,"level_id":2,"children":[]},{"id":3609000,"parent_id":3600000,"name":"宜春市","value":3609000,"seq":145,"level_id":2,"children":[]},{"id":3610000,"parent_id":3600000,"name":"抚州市","value":3610000,"seq":146,"level_id":2,"children":[]},{"id":3611000,"parent_id":3600000,"name":"上饶市","value":3611000,"seq":147,"level_id":2,"children":[]}]},{"id":3700000,"parent_id":0,"name":"山东省","value":3700000,"seq":0,"level_id":1,"children":[{"id":3701000,"parent_id":3700000,"name":"济南市","value":3701000,"seq":149,"level_id":2,"children":[]},{"id":3702000,"parent_id":3700000,"name":"青岛市","value":3702000,"seq":150,"level_id":2,"children":[]},{"id":3703000,"parent_id":3700000,"name":"淄博市","value":3703000,"seq":151,"level_id":2,"children":[]},{"id":3704000,"parent_id":3700000,"name":"枣庄市","value":3704000,"seq":152,"level_id":2,"children":[]},{"id":3705000,"parent_id":3700000,"name":"东营市","value":3705000,"seq":153,"level_id":2,"children":[]},{"id":3706000,"parent_id":3700000,"name":"烟台市","value":3706000,"seq":154,"level_id":2,"children":[]},{"id":3707000,"parent_id":3700000,"name":"潍坊市","value":3707000,"seq":155,"level_id":2,"children":[]},{"id":3708000,"parent_id":3700000,"name":"济宁市","value":3708000,"seq":156,"level_id":2,"children":[]},{"id":3709000,"parent_id":3700000,"name":"泰安市","value":3709000,"seq":157,"level_id":2,"children":[]},{"id":3710000,"parent_id":3700000,"name":"威海市","value":3710000,"seq":158,"level_id":2,"children":[]},{"id":3711000,"parent_id":3700000,"name":"日照市","value":3711000,"seq":159,"level_id":2,"children":[]},{"id":3712000,"parent_id":3700000,"name":"莱芜市","value":3712000,"seq":160,"level_id":2,"children":[]},{"id":3713000,"parent_id":3700000,"name":"临沂市","value":3713000,"seq":161,"level_id":2,"children":[]},{"id":3714000,"parent_id":3700000,"name":"德州市","value":3714000,"seq":162,"level_id":2,"children":[]},{"id":3715000,"parent_id":3700000,"name":"聊城市","value":3715000,"seq":163,"level_id":2,"children":[]},{"id":3716000,"parent_id":3700000,"name":"滨州市","value":3716000,"seq":164,"level_id":2,"children":[]},{"id":3717000,"parent_id":3700000,"name":"菏泽市","value":3717000,"seq":165,"level_id":2,"children":[]}]},{"id":4100000,"parent_id":0,"name":"河南省","value":4100000,"seq":0,"level_id":1,"children":[{"id":4101000,"parent_id":4100000,"name":"郑州市","value":4101000,"seq":167,"level_id":2,"children":[]},{"id":4102000,"parent_id":4100000,"name":"开封市","value":4102000,"seq":168,"level_id":2,"children":[]},{"id":4103000,"parent_id":4100000,"name":"洛阳市","value":4103000,"seq":169,"level_id":2,"children":[]},{"id":4104000,"parent_id":4100000,"name":"平顶山市","value":4104000,"seq":170,"level_id":2,"children":[]},{"id":4105000,"parent_id":4100000,"name":"安阳市","value":4105000,"seq":171,"level_id":2,"children":[]},{"id":4106000,"parent_id":4100000,"name":"鹤壁市","value":4106000,"seq":172,"level_id":2,"children":[]},{"id":4107000,"parent_id":4100000,"name":"新乡市","value":4107000,"seq":173,"level_id":2,"children":[]},{"id":4108000,"parent_id":4100000,"name":"焦作市","value":4108000,"seq":174,"level_id":2,"children":[]},{"id":4109000,"parent_id":4100000,"name":"濮阳市","value":4109000,"seq":175,"level_id":2,"children":[]},{"id":4110000,"parent_id":4100000,"name":"许昌市","value":4110000,"seq":176,"level_id":2,"children":[]},{"id":4111000,"parent_id":4100000,"name":"漯河市","value":4111000,"seq":177,"level_id":2,"children":[]},{"id":4112000,"parent_id":4100000,"name":"三门峡市","value":4112000,"seq":178,"level_id":2,"children":[]},{"id":4113000,"parent_id":4100000,"name":"南阳市","value":4113000,"seq":179,"level_id":2,"children":[]},{"id":4114000,"parent_id":4100000,"name":"商丘市","value":4114000,"seq":180,"level_id":2,"children":[]},{"id":4115000,"parent_id":4100000,"name":"信阳市","value":4115000,"seq":181,"level_id":2,"children":[]},{"id":4116000,"parent_id":4100000,"name":"周口市","value":4116000,"seq":182,"level_id":2,"children":[]},{"id":4117000,"parent_id":4100000,"name":"驻马店市","value":4117000,"seq":183,"level_id":2,"children":[]},{"id":4190000,"parent_id":4100000,"name":"直辖县","value":4190000,"seq":184,"level_id":2,"children":[]}]},{"id":4200000,"parent_id":0,"name":"湖北省","value":4200000,"seq":0,"level_id":1,"children":[{"id":4201000,"parent_id":4200000,"name":"武汉市","value":4201000,"seq":186,"level_id":2,"children":[]},{"id":4202000,"parent_id":4200000,"name":"黄石市","value":4202000,"seq":187,"level_id":2,"children":[]},{"id":4203000,"parent_id":4200000,"name":"十堰市","value":4203000,"seq":188,"level_id":2,"children":[]},{"id":4205000,"parent_id":4200000,"name":"宜昌市","value":4205000,"seq":189,"level_id":2,"children":[]},{"id":4206000,"parent_id":4200000,"name":"襄阳市","value":4206000,"seq":190,"level_id":2,"children":[]},{"id":4207000,"parent_id":4200000,"name":"鄂州市","value":4207000,"seq":191,"level_id":2,"children":[]},{"id":4208000,"parent_id":4200000,"name":"荆门市","value":4208000,"seq":192,"level_id":2,"children":[]},{"id":4209000,"parent_id":4200000,"name":"孝感市","value":4209000,"seq":193,"level_id":2,"children":[]},{"id":4210000,"parent_id":4200000,"name":"荆州市","value":4210000,"seq":194,"level_id":2,"children":[]},{"id":4211000,"parent_id":4200000,"name":"黄冈市","value":4211000,"seq":195,"level_id":2,"children":[]},{"id":4212000,"parent_id":4200000,"name":"咸宁市","value":4212000,"seq":196,"level_id":2,"children":[]},{"id":4213000,"parent_id":4200000,"name":"随州市","value":4213000,"seq":197,"level_id":2,"children":[]},{"id":4228000,"parent_id":4200000,"name":"恩施土家族苗族自治州","value":4228000,"seq":198,"level_id":2,"children":[]},{"id":4290000,"parent_id":4200000,"name":"直辖县","value":4290000,"seq":199,"level_id":2,"children":[]}]},{"id":4300000,"parent_id":0,"name":"湖南省","value":4300000,"seq":0,"level_id":1,"children":[{"id":4301000,"parent_id":4300000,"name":"长沙市","value":4301000,"seq":201,"level_id":2,"children":[]},{"id":4302000,"parent_id":4300000,"name":"株洲市","value":4302000,"seq":202,"level_id":2,"children":[]},{"id":4303000,"parent_id":4300000,"name":"湘潭市","value":4303000,"seq":203,"level_id":2,"children":[]},{"id":4304000,"parent_id":4300000,"name":"衡阳市","value":4304000,"seq":204,"level_id":2,"children":[]},{"id":4305000,"parent_id":4300000,"name":"邵阳市","value":4305000,"seq":205,"level_id":2,"children":[]},{"id":4306000,"parent_id":4300000,"name":"岳阳市","value":4306000,"seq":206,"level_id":2,"children":[]},{"id":4307000,"parent_id":4300000,"name":"常德市","value":4307000,"seq":207,"level_id":2,"children":[]},{"id":4308000,"parent_id":4300000,"name":"张家界市","value":4308000,"seq":208,"level_id":2,"children":[]},{"id":4309000,"parent_id":4300000,"name":"益阳市","value":4309000,"seq":209,"level_id":2,"children":[]},{"id":4310000,"parent_id":4300000,"name":"郴州市","value":4310000,"seq":210,"level_id":2,"children":[]},{"id":4311000,"parent_id":4300000,"name":"永州市","value":4311000,"seq":211,"level_id":2,"children":[]},{"id":4312000,"parent_id":4300000,"name":"怀化市","value":4312000,"seq":212,"level_id":2,"children":[]},{"id":4313000,"parent_id":4300000,"name":"娄底市","value":4313000,"seq":213,"level_id":2,"children":[]},{"id":4331000,"parent_id":4300000,"name":"湘西土家族苗族自治州","value":4331000,"seq":214,"level_id":2,"children":[]}]},{"id":4400000,"parent_id":0,"name":"广东省","value":4400000,"seq":0,"level_id":1,"children":[{"id":4401000,"parent_id":4400000,"name":"广州市","value":4401000,"seq":216,"level_id":2,"children":[]},{"id":4402000,"parent_id":4400000,"name":"韶关市","value":4402000,"seq":217,"level_id":2,"children":[]},{"id":4403000,"parent_id":4400000,"name":"深圳市","value":4403000,"seq":218,"level_id":2,"children":[]},{"id":4404000,"parent_id":4400000,"name":"珠海市","value":4404000,"seq":219,"level_id":2,"children":[]},{"id":4405000,"parent_id":4400000,"name":"汕头市","value":4405000,"seq":220,"level_id":2,"children":[]},{"id":4406000,"parent_id":4400000,"name":"佛山市","value":4406000,"seq":221,"level_id":2,"children":[]},{"id":4407000,"parent_id":4400000,"name":"江门市","value":4407000,"seq":222,"level_id":2,"children":[]},{"id":4408000,"parent_id":4400000,"name":"湛江市","value":4408000,"seq":223,"level_id":2,"children":[]},{"id":4409000,"parent_id":4400000,"name":"茂名市","value":4409000,"seq":224,"level_id":2,"children":[]},{"id":4412000,"parent_id":4400000,"name":"肇庆市","value":4412000,"seq":225,"level_id":2,"children":[]},{"id":4413000,"parent_id":4400000,"name":"惠州市","value":4413000,"seq":226,"level_id":2,"children":[]},{"id":4414000,"parent_id":4400000,"name":"梅州市","value":4414000,"seq":227,"level_id":2,"children":[]},{"id":4415000,"parent_id":4400000,"name":"汕尾市","value":4415000,"seq":228,"level_id":2,"children":[]},{"id":4416000,"parent_id":4400000,"name":"河源市","value":4416000,"seq":229,"level_id":2,"children":[]},{"id":4417000,"parent_id":4400000,"name":"阳江市","value":4417000,"seq":230,"level_id":2,"children":[]},{"id":4418000,"parent_id":4400000,"name":"清远市","value":4418000,"seq":231,"level_id":2,"children":[]},{"id":4419000,"parent_id":4400000,"name":"东莞市","value":4419000,"seq":232,"level_id":2,"children":[]},{"id":4420000,"parent_id":4400000,"name":"中山市","value":4420000,"seq":233,"level_id":2,"children":[]},{"id":4451000,"parent_id":4400000,"name":"潮州市","value":4451000,"seq":234,"level_id":2,"children":[]},{"id":4452000,"parent_id":4400000,"name":"揭阳市","value":4452000,"seq":235,"level_id":2,"children":[]},{"id":4453000,"parent_id":4400000,"name":"云浮市","value":4453000,"seq":236,"level_id":2,"children":[]}]},{"id":4500000,"parent_id":0,"name":"广西壮族自治区","value":4500000,"seq":0,"level_id":1,"children":[{"id":4501000,"parent_id":4500000,"name":"南宁市","value":4501000,"seq":238,"level_id":2,"children":[]},{"id":4502000,"parent_id":4500000,"name":"柳州市","value":4502000,"seq":239,"level_id":2,"children":[]},{"id":4503000,"parent_id":4500000,"name":"桂林市","value":4503000,"seq":240,"level_id":2,"children":[]},{"id":4504000,"parent_id":4500000,"name":"梧州市","value":4504000,"seq":241,"level_id":2,"children":[]},{"id":4505000,"parent_id":4500000,"name":"北海市","value":4505000,"seq":242,"level_id":2,"children":[]},{"id":4506000,"parent_id":4500000,"name":"防城港市","value":4506000,"seq":243,"level_id":2,"children":[]},{"id":4507000,"parent_id":4500000,"name":"钦州市","value":4507000,"seq":244,"level_id":2,"children":[]},{"id":4508000,"parent_id":4500000,"name":"贵港市","value":4508000,"seq":245,"level_id":2,"children":[]},{"id":4509000,"parent_id":4500000,"name":"玉林市","value":4509000,"seq":246,"level_id":2,"children":[]},{"id":4510000,"parent_id":4500000,"name":"百色市","value":4510000,"seq":247,"level_id":2,"children":[]},{"id":4511000,"parent_id":4500000,"name":"贺州市","value":4511000,"seq":248,"level_id":2,"children":[]},{"id":4512000,"parent_id":4500000,"name":"河池市","value":4512000,"seq":249,"level_id":2,"children":[]},{"id":4513000,"parent_id":4500000,"name":"来宾市","value":4513000,"seq":250,"level_id":2,"children":[]},{"id":4514000,"parent_id":4500000,"name":"崇左市","value":4514000,"seq":251,"level_id":2,"children":[]}]},{"id":4600000,"parent_id":0,"name":"海南省","value":4600000,"seq":0,"level_id":1,"children":[{"id":4601000,"parent_id":4600000,"name":"海口市","value":4601000,"seq":253,"level_id":2,"children":[]},{"id":4602000,"parent_id":4600000,"name":"三亚市","value":4602000,"seq":254,"level_id":2,"children":[]},{"id":4603000,"parent_id":4600000,"name":"三沙市","value":4603000,"seq":255,"level_id":2,"children":[]},{"id":4604000,"parent_id":4600000,"name":"儋州市","value":4604000,"seq":256,"level_id":2,"children":[]},{"id":4690000,"parent_id":4600000,"name":"直辖县","value":4690000,"seq":257,"level_id":2,"children":[]}]},{"id":5000000,"parent_id":0,"name":"重庆市","value":5000000,"seq":0,"level_id":1,"children":[{"id":5001000,"parent_id":5000000,"name":"直辖区","value":5001000,"seq":259,"level_id":2,"children":[]},{"id":5002000,"parent_id":5000000,"name":"直辖县","value":5002000,"seq":260,"level_id":2,"children":[]}]},{"id":5100000,"parent_id":0,"name":"四川省","value":5100000,"seq":0,"level_id":1,"children":[{"id":5101000,"parent_id":5100000,"name":"成都市","value":5101000,"seq":262,"level_id":2,"children":[]},{"id":5103000,"parent_id":5100000,"name":"自贡市","value":5103000,"seq":263,"level_id":2,"children":[]},{"id":5104000,"parent_id":5100000,"name":"攀枝花市","value":5104000,"seq":264,"level_id":2,"children":[]},{"id":5105000,"parent_id":5100000,"name":"泸州市","value":5105000,"seq":265,"level_id":2,"children":[]},{"id":5106000,"parent_id":5100000,"name":"德阳市","value":5106000,"seq":266,"level_id":2,"children":[]},{"id":5107000,"parent_id":5100000,"name":"绵阳市","value":5107000,"seq":267,"level_id":2,"children":[]},{"id":5108000,"parent_id":5100000,"name":"广元市","value":5108000,"seq":268,"level_id":2,"children":[]},{"id":5109000,"parent_id":5100000,"name":"遂宁市","value":5109000,"seq":269,"level_id":2,"children":[]},{"id":5110000,"parent_id":5100000,"name":"内江市","value":5110000,"seq":270,"level_id":2,"children":[]},{"id":5111000,"parent_id":5100000,"name":"乐山市","value":5111000,"seq":271,"level_id":2,"children":[]},{"id":5113000,"parent_id":5100000,"name":"南充市","value":5113000,"seq":272,"level_id":2,"children":[]},{"id":5114000,"parent_id":5100000,"name":"眉山市","value":5114000,"seq":273,"level_id":2,"children":[]},{"id":5115000,"parent_id":5100000,"name":"宜宾市","value":5115000,"seq":274,"level_id":2,"children":[]},{"id":5116000,"parent_id":5100000,"name":"广安市","value":5116000,"seq":275,"level_id":2,"children":[]},{"id":5117000,"parent_id":5100000,"name":"达州市","value":5117000,"seq":276,"level_id":2,"children":[]},{"id":5118000,"parent_id":5100000,"name":"雅安市","value":5118000,"seq":277,"level_id":2,"children":[]},{"id":5119000,"parent_id":5100000,"name":"巴中市","value":5119000,"seq":278,"level_id":2,"children":[]},{"id":5120000,"parent_id":5100000,"name":"资阳市","value":5120000,"seq":279,"level_id":2,"children":[]},{"id":5132000,"parent_id":5100000,"name":"阿坝藏族羌族自治州","value":5132000,"seq":280,"level_id":2,"children":[]},{"id":5133000,"parent_id":5100000,"name":"甘孜藏族自治州","value":5133000,"seq":281,"level_id":2,"children":[]},{"id":5134000,"parent_id":5100000,"name":"凉山彝族自治州","value":5134000,"seq":282,"level_id":2,"children":[]}]},{"id":5200000,"parent_id":0,"name":"贵州省","value":5200000,"seq":0,"level_id":1,"children":[{"id":5201000,"parent_id":5200000,"name":"贵阳市","value":5201000,"seq":284,"level_id":2,"children":[]},{"id":5202000,"parent_id":5200000,"name":"六盘水市","value":5202000,"seq":285,"level_id":2,"children":[]},{"id":5203000,"parent_id":5200000,"name":"遵义市","value":5203000,"seq":286,"level_id":2,"children":[]},{"id":5204000,"parent_id":5200000,"name":"安顺市","value":5204000,"seq":287,"level_id":2,"children":[]},{"id":5205000,"parent_id":5200000,"name":"毕节市","value":5205000,"seq":288,"level_id":2,"children":[]},{"id":5206000,"parent_id":5200000,"name":"铜仁市","value":5206000,"seq":289,"level_id":2,"children":[]},{"id":5223000,"parent_id":5200000,"name":"黔西南布依族苗族自治州","value":5223000,"seq":290,"level_id":2,"children":[]},{"id":5226000,"parent_id":5200000,"name":"黔东南苗族侗族自治州","value":5226000,"seq":291,"level_id":2,"children":[]},{"id":5227000,"parent_id":5200000,"name":"黔南布依族苗族自治州","value":5227000,"seq":292,"level_id":2,"children":[]}]},{"id":5300000,"parent_id":0,"name":"云南省","value":5300000,"seq":0,"level_id":1,"children":[{"id":5301000,"parent_id":5300000,"name":"昆明市","value":5301000,"seq":294,"level_id":2,"children":[]},{"id":5303000,"parent_id":5300000,"name":"曲靖市","value":5303000,"seq":295,"level_id":2,"children":[]},{"id":5304000,"parent_id":5300000,"name":"玉溪市","value":5304000,"seq":296,"level_id":2,"children":[]},{"id":5305000,"parent_id":5300000,"name":"保山市","value":5305000,"seq":297,"level_id":2,"children":[]},{"id":5306000,"parent_id":5300000,"name":"昭通市","value":5306000,"seq":298,"level_id":2,"children":[]},{"id":5307000,"parent_id":5300000,"name":"丽江市","value":5307000,"seq":299,"level_id":2,"children":[]},{"id":5308000,"parent_id":5300000,"name":"普洱市","value":5308000,"seq":300,"level_id":2,"children":[]},{"id":5309000,"parent_id":5300000,"name":"临沧市","value":5309000,"seq":301,"level_id":2,"children":[]},{"id":5323000,"parent_id":5300000,"name":"楚雄彝族自治州","value":5323000,"seq":302,"level_id":2,"children":[]},{"id":5325000,"parent_id":5300000,"name":"红河哈尼族彝族自治州","value":5325000,"seq":303,"level_id":2,"children":[]},{"id":5326000,"parent_id":5300000,"name":"文山壮族苗族自治州","value":5326000,"seq":304,"level_id":2,"children":[]},{"id":5328000,"parent_id":5300000,"name":"西双版纳傣族自治州","value":5328000,"seq":305,"level_id":2,"children":[]},{"id":5329000,"parent_id":5300000,"name":"大理白族自治州","value":5329000,"seq":306,"level_id":2,"children":[]},{"id":5331000,"parent_id":5300000,"name":"德宏傣族景颇族自治州","value":5331000,"seq":307,"level_id":2,"children":[]},{"id":5333000,"parent_id":5300000,"name":"怒江傈僳族自治州","value":5333000,"seq":308,"level_id":2,"children":[]},{"id":5334000,"parent_id":5300000,"name":"迪庆藏族自治州","value":5334000,"seq":309,"level_id":2,"children":[]}]},{"id":5400000,"parent_id":0,"name":"西藏自治区","value":5400000,"seq":0,"level_id":1,"children":[{"id":5401000,"parent_id":5400000,"name":"拉萨市","value":5401000,"seq":311,"level_id":2,"children":[]},{"id":5402000,"parent_id":5400000,"name":"日喀则市","value":5402000,"seq":312,"level_id":2,"children":[]},{"id":5403000,"parent_id":5400000,"name":"昌都市","value":5403000,"seq":313,"level_id":2,"children":[]},{"id":5404000,"parent_id":5400000,"name":"林芝市","value":5404000,"seq":314,"level_id":2,"children":[]},{"id":5405000,"parent_id":5400000,"name":"山南市","value":5405000,"seq":315,"level_id":2,"children":[]},{"id":5406000,"parent_id":5400000,"name":"那曲市","value":5406000,"seq":316,"level_id":2,"children":[]},{"id":5425000,"parent_id":5400000,"name":"阿里地区","value":5425000,"seq":317,"level_id":2,"children":[]}]},{"id":6100000,"parent_id":0,"name":"陕西省","value":6100000,"seq":0,"level_id":1,"children":[{"id":6101000,"parent_id":6100000,"name":"西安市","value":6101000,"seq":319,"level_id":2,"children":[]},{"id":6102000,"parent_id":6100000,"name":"铜川市","value":6102000,"seq":320,"level_id":2,"children":[]},{"id":6103000,"parent_id":6100000,"name":"宝鸡市","value":6103000,"seq":321,"level_id":2,"children":[]},{"id":6104000,"parent_id":6100000,"name":"咸阳市","value":6104000,"seq":322,"level_id":2,"children":[]},{"id":6105000,"parent_id":6100000,"name":"渭南市","value":6105000,"seq":323,"level_id":2,"children":[]},{"id":6106000,"parent_id":6100000,"name":"延安市","value":6106000,"seq":324,"level_id":2,"children":[]},{"id":6107000,"parent_id":6100000,"name":"汉中市","value":6107000,"seq":325,"level_id":2,"children":[]},{"id":6108000,"parent_id":6100000,"name":"榆林市","value":6108000,"seq":326,"level_id":2,"children":[]},{"id":6109000,"parent_id":6100000,"name":"安康市","value":6109000,"seq":327,"level_id":2,"children":[]},{"id":6110000,"parent_id":6100000,"name":"商洛市","value":6110000,"seq":328,"level_id":2,"children":[]}]},{"id":6200000,"parent_id":0,"name":"甘肃省","value":6200000,"seq":0,"level_id":1,"children":[{"id":6201000,"parent_id":6200000,"name":"兰州市","value":6201000,"seq":330,"level_id":2,"children":[]},{"id":6202000,"parent_id":6200000,"name":"嘉峪关市","value":6202000,"seq":331,"level_id":2,"children":[]},{"id":6203000,"parent_id":6200000,"name":"金昌市","value":6203000,"seq":332,"level_id":2,"children":[]},{"id":6204000,"parent_id":6200000,"name":"白银市","value":6204000,"seq":333,"level_id":2,"children":[]},{"id":6205000,"parent_id":6200000,"name":"天水市","value":6205000,"seq":334,"level_id":2,"children":[]},{"id":6206000,"parent_id":6200000,"name":"武威市","value":6206000,"seq":335,"level_id":2,"children":[]},{"id":6207000,"parent_id":6200000,"name":"张掖市","value":6207000,"seq":336,"level_id":2,"children":[]},{"id":6208000,"parent_id":6200000,"name":"平凉市","value":6208000,"seq":337,"level_id":2,"children":[]},{"id":6209000,"parent_id":6200000,"name":"酒泉市","value":6209000,"seq":338,"level_id":2,"children":[]},{"id":6210000,"parent_id":6200000,"name":"庆阳市","value":6210000,"seq":339,"level_id":2,"children":[]},{"id":6211000,"parent_id":6200000,"name":"定西市","value":6211000,"seq":340,"level_id":2,"children":[]},{"id":6212000,"parent_id":6200000,"name":"陇南市","value":6212000,"seq":341,"level_id":2,"children":[]},{"id":6229000,"parent_id":6200000,"name":"临夏回族自治州","value":6229000,"seq":342,"level_id":2,"children":[]},{"id":6230000,"parent_id":6200000,"name":"甘南藏族自治州","value":6230000,"seq":343,"level_id":2,"children":[]}]},{"id":6300000,"parent_id":0,"name":"青海省","value":6300000,"seq":0,"level_id":1,"children":[{"id":6301000,"parent_id":6300000,"name":"西宁市","value":6301000,"seq":345,"level_id":2,"children":[]},{"id":6302000,"parent_id":6300000,"name":"海东市","value":6302000,"seq":346,"level_id":2,"children":[]},{"id":6322000,"parent_id":6300000,"name":"海北藏族自治州","value":6322000,"seq":347,"level_id":2,"children":[]},{"id":6323000,"parent_id":6300000,"name":"黄南藏族自治州","value":6323000,"seq":348,"level_id":2,"children":[]},{"id":6325000,"parent_id":6300000,"name":"海南藏族自治州","value":6325000,"seq":349,"level_id":2,"children":[]},{"id":6326000,"parent_id":6300000,"name":"果洛藏族自治州","value":6326000,"seq":350,"level_id":2,"children":[]},{"id":6327000,"parent_id":6300000,"name":"玉树藏族自治州","value":6327000,"seq":351,"level_id":2,"children":[]},{"id":6328000,"parent_id":6300000,"name":"海西蒙古族藏族自治州","value":6328000,"seq":352,"level_id":2,"children":[]}]},{"id":6400000,"parent_id":0,"name":"宁夏回族自治区","value":6400000,"seq":0,"level_id":1,"children":[{"id":6401000,"parent_id":6400000,"name":"银川市","value":6401000,"seq":354,"level_id":2,"children":[]},{"id":6402000,"parent_id":6400000,"name":"石嘴山市","value":6402000,"seq":355,"level_id":2,"children":[]},{"id":6403000,"parent_id":6400000,"name":"吴忠市","value":6403000,"seq":356,"level_id":2,"children":[]},{"id":6404000,"parent_id":6400000,"name":"固原市","value":6404000,"seq":357,"level_id":2,"children":[]},{"id":6405000,"parent_id":6400000,"name":"中卫市","value":6405000,"seq":358,"level_id":2,"children":[]}]},{"id":6500000,"parent_id":0,"name":"新疆维吾尔自治区","value":6500000,"seq":0,"level_id":1,"children":[{"id":6501000,"parent_id":6500000,"name":"乌鲁木齐市","value":6501000,"seq":360,"level_id":2,"children":[]},{"id":6502000,"parent_id":6500000,"name":"克拉玛依市","value":6502000,"seq":361,"level_id":2,"children":[]},{"id":6504000,"parent_id":6500000,"name":"吐鲁番市","value":6504000,"seq":362,"level_id":2,"children":[]},{"id":6505000,"parent_id":6500000,"name":"哈密市","value":6505000,"seq":363,"level_id":2,"children":[]},{"id":6523000,"parent_id":6500000,"name":"昌吉回族自治州","value":6523000,"seq":364,"level_id":2,"children":[]},{"id":6527000,"parent_id":6500000,"name":"博尔塔拉蒙古自治州","value":6527000,"seq":365,"level_id":2,"children":[]},{"id":6528000,"parent_id":6500000,"name":"巴音郭楞蒙古自治州","value":6528000,"seq":366,"level_id":2,"children":[]},{"id":6529000,"parent_id":6500000,"name":"阿克苏地区","value":6529000,"seq":367,"level_id":2,"children":[]},{"id":6530000,"parent_id":6500000,"name":"克孜勒苏柯尔克孜自治州","value":6530000,"seq":368,"level_id":2,"children":[]},{"id":6531000,"parent_id":6500000,"name":"喀什地区","value":6531000,"seq":369,"level_id":2,"children":[]},{"id":6532000,"parent_id":6500000,"name":"和田地区","value":6532000,"seq":370,"level_id":2,"children":[]},{"id":6540000,"parent_id":6500000,"name":"伊犁哈萨克自治州","value":6540000,"seq":371,"level_id":2,"children":[]},{"id":6542000,"parent_id":6500000,"name":"塔城地区","value":6542000,"seq":372,"level_id":2,"children":[]},{"id":6543000,"parent_id":6500000,"name":"阿勒泰地区","value":6543000,"seq":373,"level_id":2,"children":[]},{"id":6590000,"parent_id":6500000,"name":"直辖县","value":6590000,"seq":374,"level_id":2,"children":[]}]},{"id":7013135,"parent_id":0,"name":"香港特别行政区","value":7013135,"seq":0,"level_id":1,"children":[{"id":7011559,"parent_id":7013135,"name":"香港岛","value":7011559,"seq":376,"level_id":2,"children":[]},{"id":7012837,"parent_id":7013135,"name":"九龙","value":7012837,"seq":377,"level_id":2,"children":[]},{"id":7013591,"parent_id":7013135,"name":"新界","value":7013591,"seq":378,"level_id":2,"children":[]}]},{"id":7112407,"parent_id":0,"name":"澳门特别行政区","value":7112407,"seq":0,"level_id":1,"children":[{"id":7110196,"parent_id":7112407,"name":"氹仔岛","value":7110196,"seq":381,"level_id":2,"children":[]},{"id":7111217,"parent_id":7112407,"name":"澳门半岛","value":7111217,"seq":380,"level_id":2,"children":[]},{"id":7113878,"parent_id":7112407,"name":"路环岛","value":7113878,"seq":382,"level_id":2,"children":[]}]},{"id":7212684,"parent_id":0,"name":"台湾省","value":7212684,"seq":0,"level_id":1,"children":[{"id":7210006,"parent_id":7212684,"name":"苗栗县","value":7210006,"seq":394,"level_id":2,"children":[]},{"id":7210341,"parent_id":7212684,"name":"桃园市","value":7210341,"seq":404,"level_id":2,"children":[]},{"id":7210496,"parent_id":7212684,"name":"宜兰县","value":7210496,"seq":405,"level_id":2,"children":[]},{"id":7210628,"parent_id":7212684,"name":"新竹市","value":7210628,"seq":387,"level_id":2,"children":[]},{"id":7210683,"parent_id":7212684,"name":"台东县","value":7210683,"seq":403,"level_id":2,"children":[]},{"id":7210805,"parent_id":7212684,"name":"云林县","value":7210805,"seq":406,"level_id":2,"children":[]},{"id":7210872,"parent_id":7212684,"name":"新竹县","value":7210872,"seq":388,"level_id":2,"children":[]},{"id":7210941,"parent_id":7212684,"name":"嘉义县","value":7210941,"seq":386,"level_id":2,"children":[]},{"id":7211135,"parent_id":7212684,"name":"台北市","value":7211135,"seq":402,"level_id":2,"children":[]},{"id":7211363,"parent_id":7212684,"name":"彰化县","value":7211363,"seq":384,"level_id":2,"children":[]},{"id":7211448,"parent_id":7212684,"name":"澎湖县","value":7211448,"seq":398,"level_id":2,"children":[]},{"id":7211810,"parent_id":7212684,"name":"台南市","value":7211810,"seq":401,"level_id":2,"children":[]},{"id":7212569,"parent_id":7212684,"name":"南海岛","value":7212569,"seq":395,"level_id":2,"children":[]},{"id":7212732,"parent_id":7212684,"name":"高雄市","value":7212732,"seq":390,"level_id":2,"children":[]},{"id":7212735,"parent_id":7212684,"name":"嘉义市","value":7212735,"seq":385,"level_id":2,"children":[]},{"id":7213169,"parent_id":7212684,"name":"金门县","value":7213169,"seq":392,"level_id":2,"children":[]},{"id":7213286,"parent_id":7212684,"name":"南投县","value":7213286,"seq":396,"level_id":2,"children":[]},{"id":7213368,"parent_id":7212684,"name":"屏东县","value":7213368,"seq":399,"level_id":2,"children":[]},{"id":7213392,"parent_id":7212684,"name":"台中市","value":7213392,"seq":400,"level_id":2,"children":[]},{"id":7213431,"parent_id":7212684,"name":"新北市","value":7213431,"seq":397,"level_id":2,"children":[]},{"id":7213494,"parent_id":7212684,"name":"连江县","value":7213494,"seq":393,"level_id":2,"children":[]},{"id":7213659,"parent_id":7212684,"name":"花莲县","value":7213659,"seq":389,"level_id":2,"children":[]},{"id":7214088,"parent_id":7212684,"name":"基隆市","value":7214088,"seq":391,"level_id":2,"children":[]}]}]},"code":0,"message":""}` 25 | c.Data(200, "application/json", []byte(res)) 26 | } 27 | -------------------------------------------------------------------------------- /api/main.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "gopkg.in/go-playground/validator.v8" 7 | "Miniprogram-server-Golang/serializer" 8 | ) 9 | 10 | // ErrorResponse 返回错误消息 11 | func ErrorResponse(err error) serializer.Response { 12 | if ve, ok := err.(validator.ValidationErrors); ok { 13 | for _, e := range ve { 14 | return serializer.ParamErr( 15 | fmt.Sprintf("%s%s", e.Field, e.Tag), 16 | err, 17 | ) 18 | } 19 | } 20 | if _, ok := err.(*json.UnmarshalTypeError); ok { 21 | return serializer.ParamErr("JSON类型不匹配", err) 22 | } 23 | 24 | return serializer.ParamErr("参数错误", err) 25 | } 26 | -------------------------------------------------------------------------------- /api/user.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "Miniprogram-server-Golang/service" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | // UserLogin 用户登录接口,获取openid,token 10 | func UserLogin(c *gin.Context) { 11 | var service service.UserOpenIDService 12 | if err := c.ShouldBind(&service); err == nil { 13 | res := service.GetCode(c) 14 | c.JSON(200, res.Data) 15 | } else { 16 | c.JSON(200, ErrorResponse(err)) 17 | } 18 | } 19 | 20 | // UserIsReg 判断用户是否存在 21 | func UserIsReg(c *gin.Context) { 22 | var service service.CheckIsRegisteredService 23 | if err := c.ShouldBind(&service); err == nil { 24 | res := service.IsRegistered(c) 25 | if res.Data != nil { 26 | c.JSON(200, res.Data) 27 | } else { 28 | c.JSON(200, res) 29 | } 30 | } else { 31 | c.JSON(200, ErrorResponse(err)) 32 | } 33 | } 34 | 35 | // SaveInfo 用户上传信息接口 36 | func SaveInfo(c *gin.Context) { 37 | var service service.SaveDailyInfoService 38 | if err := c.ShouldBind(&service); err == nil { 39 | res := service.SaveDailyInfo(c) 40 | c.JSON(200, res) 41 | } else { 42 | c.JSON(200, ErrorResponse(err)) 43 | } 44 | } 45 | 46 | // GetInfo 用户上传信息接口 47 | func GetInfo(c *gin.Context) { 48 | var service service.GetLastDataService 49 | if err := c.ShouldBind(&service); err == nil { 50 | res := service.GetLastData(c) 51 | if res.Code == 0 { 52 | c.JSON(200, res.Data) 53 | } else { 54 | c.JSON(200, res) 55 | } 56 | } else { 57 | c.JSON(200, ErrorResponse(err)) 58 | } 59 | } 60 | 61 | // GetUserInfo 用户上传信息接口 62 | func GetUserInfo(c *gin.Context) { 63 | var service service.GetInfoService 64 | if err := c.ShouldBind(&service); err == nil { 65 | res := service.GetMyInfo(c) 66 | if res.Code == 0 { 67 | c.JSON(200, res.Data) 68 | } else { 69 | c.JSON(200, res) 70 | } 71 | } else { 72 | c.JSON(200, ErrorResponse(err)) 73 | } 74 | } 75 | 76 | // GetCorp 获取用户企业信息接口 77 | func GetCorp(c *gin.Context) { 78 | var service service.GetCorpService 79 | if err := c.ShouldBind(&service); err == nil { 80 | res := service.GetCorp(c) 81 | if res.Data != nil { 82 | c.JSON(200, res.Data) 83 | } else { 84 | c.JSON(200, res) 85 | } 86 | } else { 87 | c.JSON(200, ErrorResponse(err)) 88 | } 89 | } 90 | 91 | // CheckUser 检查用户是否存在 92 | func CheckUser(c *gin.Context) { 93 | // 将请求的内容通过ShouldBind方法绑定到service中。每一个接口中对应的service 94 | var service service.CheckUserService 95 | if err := c.ShouldBind(&service); err == nil { 96 | res := service.CheckUser(c) 97 | if res.Data != nil { 98 | c.JSON(200, res.Data) 99 | } else { 100 | c.JSON(200, res) 101 | } 102 | } else { 103 | c.JSON(200, ErrorResponse(err)) 104 | } 105 | } 106 | 107 | // WeixinUsrRegister 检查用户是否存在 108 | func WeixinUsrRegister(c *gin.Context) { 109 | var service service.WeixinUserRegister 110 | if err := c.ShouldBind(&service); err == nil { 111 | res := service.UserRegister(c) 112 | if res.Data != nil { 113 | c.JSON(200, res.Data) 114 | } else { 115 | c.JSON(200, res) 116 | } 117 | } else { 118 | c.JSON(200, ErrorResponse(err)) 119 | } 120 | } 121 | 122 | // UserUnBind 检查用户是否存在 123 | func UserUnBind(c *gin.Context) { 124 | var service service.UserBindService 125 | if err := c.ShouldBind(&service); err == nil { 126 | res := service.UnBind(c) 127 | c.JSON(200, res.Data) 128 | } else { 129 | c.JSON(200, ErrorResponse(err)) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /conf/conf.go: -------------------------------------------------------------------------------- 1 | package conf 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "os" 6 | 7 | "github.com/joho/godotenv" 8 | ) 9 | 10 | // Init 初始化配置 11 | func Init() { 12 | //加载.env文件 13 | godotenv.Load() 14 | 15 | //连接数据库 16 | model.Database(os.Getenv("MYSQL_DSN")) 17 | } 18 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # 开发文档 2 | 3 | > 大家开发的过程中学习到的新知识点、经验、以及对自己负责模块的介绍都放在这个文件夹中,以备参考。 如果大家参考文档时发现了bug,请及时提交PR。 4 | 5 | ## 格式 6 | 比如git相关的知识点 7 | 1. 创建一个git.md 8 | 2. 注明当前文档的主题 9 | 3. 创建一个目录导航 10 | 4. 每一个二级目录是一个知识点,如果下面有细节分支请自行发挥 11 | 12 | ## 大家如果有更好的想法,请务必提出来!通过提交PR、issue讨论、微信群都可! 13 | -------------------------------------------------------------------------------- /doc/git .md: -------------------------------------------------------------------------------- 1 | # git 2 | 3 | > 大家可以把自己学习git的经验放到这里,积累下来互相学习 4 | > 按照格式,在下面添加一个二级目录,然后在目录导航中添加导航 5 | 6 | ## 目录导航 7 | - [git](#git) 8 | - [目录导航](#目录导航) 9 | - [fork的项目如何与上游保持同步](#fork的项目如何与上游保持同步) 10 | 11 | ## fork的项目如何与上游保持同步 12 | 13 | **1. 添加上游仓库**(添加过的可以略过,直接第二步) 14 | 15 | ``` 16 | git remote add upstream [upstream_url] 17 | ``` 18 | 19 | **2. Fetch 上游代码** 20 | 21 | ``` 22 | git fetch upstream 23 | ``` 24 | 25 | **3. 切换到本地master分支** (如果只有一个主分支就不用切换) 26 | 27 | ``` 28 | git checkout master 29 | ``` 30 | 31 | **4. 将upstream/master merge到本地master分支** 32 | 33 | ``` 34 | git merge upstream/master 35 | ``` 36 | 37 | **5. push到自己的github仓库** 38 | 39 | ``` 40 | git push origin master 41 | ``` 42 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module Miniprogram-server-Golang 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/gin-contrib/cors v1.3.0 7 | github.com/gin-gonic/gin v1.4.0 8 | github.com/go-sql-driver/mysql v1.4.1 9 | github.com/jinzhu/gorm v1.9.10 10 | github.com/joho/godotenv v1.3.0 11 | github.com/medivhzhan/weapp/v2 v2.0.1 12 | github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 // indirect 13 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect 14 | gopkg.in/go-playground/validator.v8 v8.18.2 15 | ) 16 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "Miniprogram-server-Golang/conf" 5 | "Miniprogram-server-Golang/server" 6 | ) 7 | 8 | func main() { 9 | //从配置文件读取配置 10 | conf.Init() 11 | 12 | //装载路由 13 | router := server.NewRouter() 14 | 15 | //监听8080端口 16 | router.Run(":8080") 17 | } 18 | -------------------------------------------------------------------------------- /middleware/cors.go: -------------------------------------------------------------------------------- 1 | package middleware 2 | 3 | import ( 4 | "github.com/gin-contrib/cors" 5 | "github.com/gin-gonic/gin" 6 | ) 7 | 8 | // Cors 跨域配置 9 | func Cors() gin.HandlerFunc { 10 | config := cors.DefaultConfig() 11 | config.AllowMethods = []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"} 12 | config.AllowHeaders = []string{"Origin", "Content-Length", "Content-Type", "Cookie"} 13 | //config.AllowOrigins = []string{ "http://localhost:8080","http://127.0.0.1:8080"} 14 | config.AllowAllOrigins = true 15 | config.AllowCredentials = true 16 | return cors.New(config) 17 | } 18 | -------------------------------------------------------------------------------- /model/code.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // 记录用户token信息 4 | type Code struct { 5 | UID string 6 | Token string 7 | Code string 8 | } 9 | 10 | // 判断token是否正确 11 | func CheckToken(uid int, token string) bool { 12 | res, _ := DB.Query("select wid from wx_mp_user where wid = ? and token = ?", uid, token) 13 | 14 | if !res.Next() { 15 | return false 16 | } 17 | 18 | return true 19 | } 20 | -------------------------------------------------------------------------------- /model/com_district.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // 记录行政区信息 4 | // **暂用** 5 | type District struct { 6 | Name string 7 | Value int 8 | LevelID int 9 | ParentID int 10 | } 11 | 12 | // **暂用** 13 | -------------------------------------------------------------------------------- /model/db2.doc.md: -------------------------------------------------------------------------------- 1 | # DB2连接使用说明 2 | 3 | ## DB2产生的原因 4 | 5 | 为了适配其他数据库的明明不服和gorm的命名标准 6 | 7 | ## DB2的使用特点 8 | 9 | * DB2是普通sql连接,需要自己写sql 10 | 11 | * DB2得到的结果无法直接放入结构体,需要自己解出数据,然后放入结构体 12 | 13 | ## DB2的使用方法 14 | 15 | ```go 16 | // 查询 17 | query2, err := db.Query("select * from tmpdb.tmptab where id =?",1) 18 | printResult(query2) 19 | 20 | // 解数据过程 21 | func printResult(query *sql.Rows) { 22 | column, _ := query.Columns() //读出查询出的列字段名 23 | values := make([][]byte, len(column)) //values是每个列的值,这里获取到byte里 24 | scans := make([]interface{}, len(column)) //因为每次查询出来的列是不定长的,用len(column)定住当次查询的长度 25 | for i := range values { //让每一行数据都填充到[][]byte里面 26 | scans[i] = &values[i] 27 | } 28 | results := make(map[int]map[string]string) //最后得到的map 29 | i := 0 30 | for query.Next() { //循环,让游标往下移动 31 | if err := query.Scan(scans...); err != nil { //query.Scan查询出来的不定长值放到scans[i] = &values[i],也就是每行都放在values里 32 | fmt.Println(err) 33 | return 34 | } 35 | row := make(map[string]string) //每行数据 36 | for k, v := range values { //每行数据是放在values里面,现在把它挪到row里 37 | key := column[k] 38 | row[key] = string(v) 39 | } 40 | results[i] = row //装入结果集中 41 | i++ 42 | } 43 | for k, v := range results { //查询出来的数组 44 | fmt.Println(k, v) 45 | } 46 | } 47 | ``` 48 | 49 | ## 其他版本数据库的表定义如下 大家可以根据需要使用 50 | 51 | ```sql 52 | -- MySQL dump 10.13 Distrib 5.7.12, for osx10.11 (x86_64) 53 | -- 54 | -- Host: localhost Database: ncov_oss 55 | -- ------------------------------------------------------ 56 | -- Server version 5.7.12 57 | 58 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 59 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 60 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 61 | /*!40101 SET NAMES utf8 */; 62 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 63 | /*!40103 SET TIME_ZONE='+00:00' */; 64 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 65 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 66 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 67 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 68 | 69 | -- 70 | -- Table structure for table `admin_ope_type` 71 | -- 72 | 73 | DROP TABLE IF EXISTS `admin_ope_type`; 74 | /*!40101 SET @saved_cs_client = @@character_set_client */; 75 | /*!40101 SET character_set_client = utf8 */; 76 | CREATE TABLE `admin_ope_type` ( 77 | `id` int(11) NOT NULL AUTO_INCREMENT, 78 | `name` varchar(20) NOT NULL COMMENT '操作名', 79 | `status` int(11) NOT NULL DEFAULT '0', 80 | PRIMARY KEY (`id`) 81 | ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; 82 | /*!40101 SET character_set_client = @saved_cs_client */; 83 | 84 | -- 85 | -- Dumping data for table `admin_ope_type` 86 | -- 87 | 88 | LOCK TABLES `admin_ope_type` WRITE; 89 | /*!40000 ALTER TABLE `admin_ope_type` DISABLE KEYS */; 90 | INSERT INTO `admin_ope_type` VALUES (1,'登录',0),(2,'修改密码',0),(3,'导出上报数据',0),(4,'添加白名单数据',0),(5,'批量导入白名单数据',0),(6,'删除白名单数据',0),(7,'添加部门',0),(8,'修改部门',0),(9,'部门管理员添加',0),(10,'修改管理员信息',0),(11,'添加标签',0),(12,'修改标签',0); 91 | /*!40000 ALTER TABLE `admin_ope_type` ENABLE KEYS */; 92 | UNLOCK TABLES; 93 | 94 | -- 95 | -- Table structure for table `admin_role` 96 | -- 97 | 98 | DROP TABLE IF EXISTS `admin_role`; 99 | /*!40101 SET @saved_cs_client = @@character_set_client */; 100 | /*!40101 SET character_set_client = utf8 */; 101 | CREATE TABLE `admin_role` ( 102 | `id` int(11) NOT NULL AUTO_INCREMENT, 103 | `name` varchar(100) NOT NULL COMMENT '角色名', 104 | `remark` varchar(100) DEFAULT NULL, 105 | PRIMARY KEY (`id`) 106 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 107 | /*!40101 SET character_set_client = @saved_cs_client */; 108 | 109 | -- 110 | -- Dumping data for table `admin_role` 111 | -- 112 | 113 | LOCK TABLES `admin_role` WRITE; 114 | /*!40000 ALTER TABLE `admin_role` DISABLE KEYS */; 115 | INSERT INTO `admin_role` VALUES (1,'超级管理员','可开通多租户权限'),(2,'机构管理员','可以管理机构内的部门'),(3,'部门管理员','部门内管理员,可以管理部门数据'); 116 | /*!40000 ALTER TABLE `admin_role` ENABLE KEYS */; 117 | UNLOCK TABLES; 118 | 119 | -- 120 | -- Table structure for table `admin_user` 121 | -- 122 | 123 | DROP TABLE IF EXISTS `admin_user`; 124 | /*!40101 SET @saved_cs_client = @@character_set_client */; 125 | /*!40101 SET character_set_client = utf8 */; 126 | CREATE TABLE `admin_user` ( 127 | `id` int(11) NOT NULL AUTO_INCREMENT, 128 | `org_id` int(10) NOT NULL COMMENT '机构id', 129 | `dep_id` int(11) NOT NULL COMMENT '所管理部门的id', 130 | `username` varchar(20) NOT NULL COMMENT '用户名', 131 | `name` varchar(20) NOT NULL, 132 | `password` varchar(100) NOT NULL COMMENT '密码', 133 | `role` int(11) NOT NULL DEFAULT '0', 134 | `is_admin` int(11) NOT NULL DEFAULT '0' COMMENT '内置机构管理员', 135 | `is_del` int(11) NOT NULL DEFAULT '0', 136 | `need_m_pass` int(11) NOT NULL DEFAULT '1', 137 | `remarks` varchar(200) NOT NULL, 138 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 139 | PRIMARY KEY (`id`), 140 | UNIQUE KEY `username_unique` (`username`), 141 | KEY `username` (`username`) 142 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 143 | /*!40101 SET character_set_client = @saved_cs_client */; 144 | 145 | -- 146 | -- Dumping data for table `admin_user` 147 | -- 148 | 149 | LOCK TABLES `admin_user` WRITE; 150 | /*!40000 ALTER TABLE `admin_user` DISABLE KEYS */; 151 | INSERT INTO `admin_user` VALUES (1,0,0,'admin','管理员','076c1c8c99492e2aeac2481b1de7c527',1,0,0,1,'平台总管理员','2020-02-29 13:58:39'); 152 | /*!40000 ALTER TABLE `admin_user` ENABLE KEYS */; 153 | UNLOCK TABLES; 154 | 155 | -- 156 | -- Table structure for table `admin_user_log` 157 | -- 158 | 159 | DROP TABLE IF EXISTS `admin_user_log`; 160 | /*!40101 SET @saved_cs_client = @@character_set_client */; 161 | /*!40101 SET character_set_client = utf8 */; 162 | CREATE TABLE `admin_user_log` ( 163 | `id` int(11) NOT NULL AUTO_INCREMENT, 164 | `uid` int(11) NOT NULL COMMENT 'user表ID', 165 | `name` varchar(20) CHARACTER SET utf8 DEFAULT NULL, 166 | `ope_type` int(11) NOT NULL COMMENT '操作类别', 167 | `path` varchar(100) NOT NULL COMMENT 'URL', 168 | `content` varchar(1000) CHARACTER SET utf8 NOT NULL COMMENT '操作内容', 169 | `ip` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT 'IP地址', 170 | `agent` varchar(1000) CHARACTER SET utf8 NOT NULL COMMENT '浏览器数据', 171 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 172 | PRIMARY KEY (`id`) 173 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 174 | /*!40101 SET character_set_client = @saved_cs_client */; 175 | 176 | -- 177 | -- Dumping data for table `admin_user_log` 178 | -- 179 | 180 | LOCK TABLES `admin_user_log` WRITE; 181 | /*!40000 ALTER TABLE `admin_user_log` DISABLE KEYS */; 182 | /*!40000 ALTER TABLE `admin_user_log` ENABLE KEYS */; 183 | UNLOCK TABLES; 184 | 185 | -- 186 | -- Table structure for table `com_district` 187 | -- 188 | 189 | DROP TABLE IF EXISTS `com_district`; 190 | /*!40101 SET @saved_cs_client = @@character_set_client */; 191 | /*!40101 SET character_set_client = utf8 */; 192 | CREATE TABLE `com_district` ( 193 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ' 行政区划标识id', 194 | `name` varchar(255) NOT NULL COMMENT '行政区划名称', 195 | `value` int(11) NOT NULL COMMENT '行政区划字典值(不重复)', 196 | `level_id` int(11) NOT NULL COMMENT '行政区划级别(关联行政区划级别id)', 197 | `parent_id` int(11) NOT NULL COMMENT '父级行政区划id(最顶级为0)', 198 | `seq` int(11) NOT NULL DEFAULT '0' COMMENT '排序号(数值大的在前)', 199 | `short_name` varchar(255) DEFAULT NULL, 200 | PRIMARY KEY (`id`), 201 | KEY `fk-关联行政区划级别_idx` (`level_id`) 202 | ) ENGINE=InnoDB AUTO_INCREMENT=7214089 DEFAULT CHARSET=utf8; 203 | /*!40101 SET character_set_client = @saved_cs_client */; 204 | 205 | -- 206 | -- Dumping data for table `com_district` 207 | -- 208 | 209 | LOCK TABLES `com_district` WRITE; 210 | /*!40000 ALTER TABLE `com_district` DISABLE KEYS */; 211 | INSERT INTO `com_district` VALUES (1100000,'北京市',1100000,1,0,1,NULL),(1101000,'直辖区',1101000,2,1100000,2,NULL),(1200000,'天津市',1200000,1,0,3,NULL),(1201000,'直辖区',1201000,2,1200000,4,NULL),(1300000,'河北省',1300000,1,0,5,NULL),(1301000,'石家庄市',1301000,2,1300000,6,NULL),(1302000,'唐山市',1302000,2,1300000,7,NULL),(1303000,'秦皇岛市',1303000,2,1300000,8,NULL),(1304000,'邯郸市',1304000,2,1300000,9,NULL),(1305000,'邢台市',1305000,2,1300000,10,NULL),(1306000,'保定市',1306000,2,1300000,11,NULL),(1307000,'张家口市',1307000,2,1300000,12,NULL),(1308000,'承德市',1308000,2,1300000,13,NULL),(1309000,'沧州市',1309000,2,1300000,14,NULL),(1310000,'廊坊市',1310000,2,1300000,15,NULL),(1311000,'衡水市',1311000,2,1300000,16,NULL),(1400000,'山西省',1400000,1,0,17,NULL),(1401000,'太原市',1401000,2,1400000,18,NULL),(1402000,'大同市',1402000,2,1400000,19,NULL),(1403000,'阳泉市',1403000,2,1400000,20,NULL),(1404000,'长治市',1404000,2,1400000,21,NULL),(1405000,'晋城市',1405000,2,1400000,22,NULL),(1406000,'朔州市',1406000,2,1400000,23,NULL),(1407000,'晋中市',1407000,2,1400000,24,NULL),(1408000,'运城市',1408000,2,1400000,25,NULL),(1409000,'忻州市',1409000,2,1400000,26,NULL),(1410000,'临汾市',1410000,2,1400000,27,NULL),(1411000,'吕梁市',1411000,2,1400000,28,NULL),(1500000,'内蒙古自治区',1500000,1,0,29,NULL),(1501000,'呼和浩特市',1501000,2,1500000,30,NULL),(1502000,'包头市',1502000,2,1500000,31,NULL),(1503000,'乌海市',1503000,2,1500000,32,NULL),(1504000,'赤峰市',1504000,2,1500000,33,NULL),(1505000,'通辽市',1505000,2,1500000,34,NULL),(1506000,'鄂尔多斯市',1506000,2,1500000,35,NULL),(1507000,'呼伦贝尔市',1507000,2,1500000,36,NULL),(1508000,'巴彦淖尔市',1508000,2,1500000,37,NULL),(1509000,'乌兰察布市',1509000,2,1500000,38,NULL),(1522000,'兴安盟',1522000,2,1500000,39,NULL),(1525000,'锡林郭勒盟',1525000,2,1500000,40,NULL),(1529000,'阿拉善盟',1529000,2,1500000,41,NULL),(2100000,'辽宁省',2100000,1,0,42,NULL),(2101000,'沈阳市',2101000,2,2100000,43,NULL),(2102000,'大连市',2102000,2,2100000,44,NULL),(2103000,'鞍山市',2103000,2,2100000,45,NULL),(2104000,'抚顺市',2104000,2,2100000,46,NULL),(2105000,'本溪市',2105000,2,2100000,47,NULL),(2106000,'丹东市',2106000,2,2100000,48,NULL),(2107000,'锦州市',2107000,2,2100000,49,NULL),(2108000,'营口市',2108000,2,2100000,50,NULL),(2109000,'阜新市',2109000,2,2100000,51,NULL),(2110000,'辽阳市',2110000,2,2100000,52,NULL),(2111000,'盘锦市',2111000,2,2100000,53,NULL),(2112000,'铁岭市',2112000,2,2100000,54,NULL),(2113000,'朝阳市',2113000,2,2100000,55,NULL),(2114000,'葫芦岛市',2114000,2,2100000,56,NULL),(2200000,'吉林省',2200000,1,0,57,NULL),(2201000,'长春市',2201000,2,2200000,58,NULL),(2202000,'吉林市',2202000,2,2200000,59,NULL),(2203000,'四平市',2203000,2,2200000,60,NULL),(2204000,'辽源市',2204000,2,2200000,61,NULL),(2205000,'通化市',2205000,2,2200000,62,NULL),(2206000,'白山市',2206000,2,2200000,63,NULL),(2207000,'松原市',2207000,2,2200000,64,NULL),(2208000,'白城市',2208000,2,2200000,65,NULL),(2224000,'延边朝鲜族自治州',2224000,2,2200000,66,NULL),(2300000,'黑龙江省',2300000,1,0,67,NULL),(2301000,'哈尔滨市',2301000,2,2300000,68,NULL),(2302000,'齐齐哈尔市',2302000,2,2300000,69,NULL),(2303000,'鸡西市',2303000,2,2300000,70,NULL),(2304000,'鹤岗市',2304000,2,2300000,71,NULL),(2305000,'双鸭山市',2305000,2,2300000,72,NULL),(2306000,'大庆市',2306000,2,2300000,73,NULL),(2307000,'伊春市',2307000,2,2300000,74,NULL),(2308000,'佳木斯市',2308000,2,2300000,75,NULL),(2309000,'七台河市',2309000,2,2300000,76,NULL),(2310000,'牡丹江市',2310000,2,2300000,77,NULL),(2311000,'黑河市',2311000,2,2300000,78,NULL),(2312000,'绥化市',2312000,2,2300000,79,NULL),(2327000,'大兴安岭地区',2327000,2,2300000,80,NULL),(3100000,'上海市',3100000,1,0,81,NULL),(3101000,'直辖区',3101000,2,3100000,82,NULL),(3200000,'江苏省',3200000,1,0,83,NULL),(3201000,'南京市',3201000,2,3200000,84,NULL),(3202000,'无锡市',3202000,2,3200000,85,NULL),(3203000,'徐州市',3203000,2,3200000,86,NULL),(3204000,'常州市',3204000,2,3200000,87,NULL),(3205000,'苏州市',3205000,2,3200000,88,NULL),(3206000,'南通市',3206000,2,3200000,89,NULL),(3207000,'连云港市',3207000,2,3200000,90,NULL),(3208000,'淮安市',3208000,2,3200000,91,NULL),(3209000,'盐城市',3209000,2,3200000,92,NULL),(3210000,'扬州市',3210000,2,3200000,93,NULL),(3211000,'镇江市',3211000,2,3200000,94,NULL),(3212000,'泰州市',3212000,2,3200000,95,NULL),(3213000,'宿迁市',3213000,2,3200000,96,NULL),(3300000,'浙江省',3300000,1,0,97,NULL),(3301000,'杭州市',3301000,2,3300000,98,NULL),(3302000,'宁波市',3302000,2,3300000,99,NULL),(3303000,'温州市',3303000,2,3300000,100,NULL),(3304000,'嘉兴市',3304000,2,3300000,101,NULL),(3305000,'湖州市',3305000,2,3300000,102,NULL),(3306000,'绍兴市',3306000,2,3300000,103,NULL),(3307000,'金华市',3307000,2,3300000,104,NULL),(3308000,'衢州市',3308000,2,3300000,105,NULL),(3309000,'舟山市',3309000,2,3300000,106,NULL),(3310000,'台州市',3310000,2,3300000,107,NULL),(3311000,'丽水市',3311000,2,3300000,108,NULL),(3400000,'安徽省',3400000,1,0,109,NULL),(3401000,'合肥市',3401000,2,3400000,110,NULL),(3402000,'芜湖市',3402000,2,3400000,111,NULL),(3403000,'蚌埠市',3403000,2,3400000,112,NULL),(3404000,'淮南市',3404000,2,3400000,113,NULL),(3405000,'马鞍山市',3405000,2,3400000,114,NULL),(3406000,'淮北市',3406000,2,3400000,115,NULL),(3407000,'铜陵市',3407000,2,3400000,116,NULL),(3408000,'安庆市',3408000,2,3400000,117,NULL),(3410000,'黄山市',3410000,2,3400000,118,NULL),(3411000,'滁州市',3411000,2,3400000,119,NULL),(3412000,'阜阳市',3412000,2,3400000,120,NULL),(3413000,'宿州市',3413000,2,3400000,121,NULL),(3415000,'六安市',3415000,2,3400000,122,NULL),(3416000,'亳州市',3416000,2,3400000,123,NULL),(3417000,'池州市',3417000,2,3400000,124,NULL),(3418000,'宣城市',3418000,2,3400000,125,NULL),(3500000,'福建省',3500000,1,0,126,NULL),(3501000,'福州市',3501000,2,3500000,127,NULL),(3502000,'厦门市',3502000,2,3500000,128,NULL),(3503000,'莆田市',3503000,2,3500000,129,NULL),(3504000,'三明市',3504000,2,3500000,130,NULL),(3505000,'泉州市',3505000,2,3500000,131,NULL),(3506000,'漳州市',3506000,2,3500000,132,NULL),(3507000,'南平市',3507000,2,3500000,133,NULL),(3508000,'龙岩市',3508000,2,3500000,134,NULL),(3509000,'宁德市',3509000,2,3500000,135,NULL),(3600000,'江西省',3600000,1,0,136,NULL),(3601000,'南昌市',3601000,2,3600000,137,NULL),(3602000,'景德镇市',3602000,2,3600000,138,NULL),(3603000,'萍乡市',3603000,2,3600000,139,NULL),(3604000,'九江市',3604000,2,3600000,140,NULL),(3605000,'新余市',3605000,2,3600000,141,NULL),(3606000,'鹰潭市',3606000,2,3600000,142,NULL),(3607000,'赣州市',3607000,2,3600000,143,NULL),(3608000,'吉安市',3608000,2,3600000,144,NULL),(3609000,'宜春市',3609000,2,3600000,145,NULL),(3610000,'抚州市',3610000,2,3600000,146,NULL),(3611000,'上饶市',3611000,2,3600000,147,NULL),(3700000,'山东省',3700000,1,0,148,NULL),(3701000,'济南市',3701000,2,3700000,149,NULL),(3702000,'青岛市',3702000,2,3700000,150,NULL),(3703000,'淄博市',3703000,2,3700000,151,NULL),(3704000,'枣庄市',3704000,2,3700000,152,NULL),(3705000,'东营市',3705000,2,3700000,153,NULL),(3706000,'烟台市',3706000,2,3700000,154,NULL),(3707000,'潍坊市',3707000,2,3700000,155,NULL),(3708000,'济宁市',3708000,2,3700000,156,NULL),(3709000,'泰安市',3709000,2,3700000,157,NULL),(3710000,'威海市',3710000,2,3700000,158,NULL),(3711000,'日照市',3711000,2,3700000,159,NULL),(3712000,'莱芜市',3712000,2,3700000,160,NULL),(3713000,'临沂市',3713000,2,3700000,161,NULL),(3714000,'德州市',3714000,2,3700000,162,NULL),(3715000,'聊城市',3715000,2,3700000,163,NULL),(3716000,'滨州市',3716000,2,3700000,164,NULL),(3717000,'菏泽市',3717000,2,3700000,165,NULL),(4100000,'河南省',4100000,1,0,166,NULL),(4101000,'郑州市',4101000,2,4100000,167,NULL),(4102000,'开封市',4102000,2,4100000,168,NULL),(4103000,'洛阳市',4103000,2,4100000,169,NULL),(4104000,'平顶山市',4104000,2,4100000,170,NULL),(4105000,'安阳市',4105000,2,4100000,171,NULL),(4106000,'鹤壁市',4106000,2,4100000,172,NULL),(4107000,'新乡市',4107000,2,4100000,173,NULL),(4108000,'焦作市',4108000,2,4100000,174,NULL),(4109000,'濮阳市',4109000,2,4100000,175,NULL),(4110000,'许昌市',4110000,2,4100000,176,NULL),(4111000,'漯河市',4111000,2,4100000,177,NULL),(4112000,'三门峡市',4112000,2,4100000,178,NULL),(4113000,'南阳市',4113000,2,4100000,179,NULL),(4114000,'商丘市',4114000,2,4100000,180,NULL),(4115000,'信阳市',4115000,2,4100000,181,NULL),(4116000,'周口市',4116000,2,4100000,182,NULL),(4117000,'驻马店市',4117000,2,4100000,183,NULL),(4190000,'直辖县',4190000,2,4100000,184,NULL),(4200000,'湖北省',4200000,1,0,185,NULL),(4201000,'武汉市',4201000,2,4200000,186,NULL),(4202000,'黄石市',4202000,2,4200000,187,NULL),(4203000,'十堰市',4203000,2,4200000,188,NULL),(4205000,'宜昌市',4205000,2,4200000,189,NULL),(4206000,'襄阳市',4206000,2,4200000,190,NULL),(4207000,'鄂州市',4207000,2,4200000,191,NULL),(4208000,'荆门市',4208000,2,4200000,192,NULL),(4209000,'孝感市',4209000,2,4200000,193,NULL),(4210000,'荆州市',4210000,2,4200000,194,NULL),(4211000,'黄冈市',4211000,2,4200000,195,NULL),(4212000,'咸宁市',4212000,2,4200000,196,NULL),(4213000,'随州市',4213000,2,4200000,197,NULL),(4228000,'恩施土家族苗族自治州',4228000,2,4200000,198,NULL),(4290000,'直辖县',4290000,2,4200000,199,NULL),(4300000,'湖南省',4300000,1,0,200,NULL),(4301000,'长沙市',4301000,2,4300000,201,NULL),(4302000,'株洲市',4302000,2,4300000,202,NULL),(4303000,'湘潭市',4303000,2,4300000,203,NULL),(4304000,'衡阳市',4304000,2,4300000,204,NULL),(4305000,'邵阳市',4305000,2,4300000,205,NULL),(4306000,'岳阳市',4306000,2,4300000,206,NULL),(4307000,'常德市',4307000,2,4300000,207,NULL),(4308000,'张家界市',4308000,2,4300000,208,NULL),(4309000,'益阳市',4309000,2,4300000,209,NULL),(4310000,'郴州市',4310000,2,4300000,210,NULL),(4311000,'永州市',4311000,2,4300000,211,NULL),(4312000,'怀化市',4312000,2,4300000,212,NULL),(4313000,'娄底市',4313000,2,4300000,213,NULL),(4331000,'湘西土家族苗族自治州',4331000,2,4300000,214,NULL),(4400000,'广东省',4400000,1,0,215,NULL),(4401000,'广州市',4401000,2,4400000,216,NULL),(4402000,'韶关市',4402000,2,4400000,217,NULL),(4403000,'深圳市',4403000,2,4400000,218,NULL),(4404000,'珠海市',4404000,2,4400000,219,NULL),(4405000,'汕头市',4405000,2,4400000,220,NULL),(4406000,'佛山市',4406000,2,4400000,221,NULL),(4407000,'江门市',4407000,2,4400000,222,NULL),(4408000,'湛江市',4408000,2,4400000,223,NULL),(4409000,'茂名市',4409000,2,4400000,224,NULL),(4412000,'肇庆市',4412000,2,4400000,225,NULL),(4413000,'惠州市',4413000,2,4400000,226,NULL),(4414000,'梅州市',4414000,2,4400000,227,NULL),(4415000,'汕尾市',4415000,2,4400000,228,NULL),(4416000,'河源市',4416000,2,4400000,229,NULL),(4417000,'阳江市',4417000,2,4400000,230,NULL),(4418000,'清远市',4418000,2,4400000,231,NULL),(4419000,'东莞市',4419000,2,4400000,232,NULL),(4420000,'中山市',4420000,2,4400000,233,NULL),(4451000,'潮州市',4451000,2,4400000,234,NULL),(4452000,'揭阳市',4452000,2,4400000,235,NULL),(4453000,'云浮市',4453000,2,4400000,236,NULL),(4500000,'广西壮族自治区',4500000,1,0,237,NULL),(4501000,'南宁市',4501000,2,4500000,238,NULL),(4502000,'柳州市',4502000,2,4500000,239,NULL),(4503000,'桂林市',4503000,2,4500000,240,NULL),(4504000,'梧州市',4504000,2,4500000,241,NULL),(4505000,'北海市',4505000,2,4500000,242,NULL),(4506000,'防城港市',4506000,2,4500000,243,NULL),(4507000,'钦州市',4507000,2,4500000,244,NULL),(4508000,'贵港市',4508000,2,4500000,245,NULL),(4509000,'玉林市',4509000,2,4500000,246,NULL),(4510000,'百色市',4510000,2,4500000,247,NULL),(4511000,'贺州市',4511000,2,4500000,248,NULL),(4512000,'河池市',4512000,2,4500000,249,NULL),(4513000,'来宾市',4513000,2,4500000,250,NULL),(4514000,'崇左市',4514000,2,4500000,251,NULL),(4600000,'海南省',4600000,1,0,252,NULL),(4601000,'海口市',4601000,2,4600000,253,NULL),(4602000,'三亚市',4602000,2,4600000,254,NULL),(4603000,'三沙市',4603000,2,4600000,255,NULL),(4604000,'儋州市',4604000,2,4600000,256,NULL),(4690000,'直辖县',4690000,2,4600000,257,NULL),(5000000,'重庆市',5000000,1,0,258,NULL),(5001000,'直辖区',5001000,2,5000000,259,NULL),(5002000,'直辖县',5002000,2,5000000,260,NULL),(5100000,'四川省',5100000,1,0,261,NULL),(5101000,'成都市',5101000,2,5100000,262,NULL),(5103000,'自贡市',5103000,2,5100000,263,NULL),(5104000,'攀枝花市',5104000,2,5100000,264,NULL),(5105000,'泸州市',5105000,2,5100000,265,NULL),(5106000,'德阳市',5106000,2,5100000,266,NULL),(5107000,'绵阳市',5107000,2,5100000,267,NULL),(5108000,'广元市',5108000,2,5100000,268,NULL),(5109000,'遂宁市',5109000,2,5100000,269,NULL),(5110000,'内江市',5110000,2,5100000,270,NULL),(5111000,'乐山市',5111000,2,5100000,271,NULL),(5113000,'南充市',5113000,2,5100000,272,NULL),(5114000,'眉山市',5114000,2,5100000,273,NULL),(5115000,'宜宾市',5115000,2,5100000,274,NULL),(5116000,'广安市',5116000,2,5100000,275,NULL),(5117000,'达州市',5117000,2,5100000,276,NULL),(5118000,'雅安市',5118000,2,5100000,277,NULL),(5119000,'巴中市',5119000,2,5100000,278,NULL),(5120000,'资阳市',5120000,2,5100000,279,NULL),(5132000,'阿坝藏族羌族自治州',5132000,2,5100000,280,NULL),(5133000,'甘孜藏族自治州',5133000,2,5100000,281,NULL),(5134000,'凉山彝族自治州',5134000,2,5100000,282,NULL),(5200000,'贵州省',5200000,1,0,283,NULL),(5201000,'贵阳市',5201000,2,5200000,284,NULL),(5202000,'六盘水市',5202000,2,5200000,285,NULL),(5203000,'遵义市',5203000,2,5200000,286,NULL),(5204000,'安顺市',5204000,2,5200000,287,NULL),(5205000,'毕节市',5205000,2,5200000,288,NULL),(5206000,'铜仁市',5206000,2,5200000,289,NULL),(5223000,'黔西南布依族苗族自治州',5223000,2,5200000,290,NULL),(5226000,'黔东南苗族侗族自治州',5226000,2,5200000,291,NULL),(5227000,'黔南布依族苗族自治州',5227000,2,5200000,292,NULL),(5300000,'云南省',5300000,1,0,293,NULL),(5301000,'昆明市',5301000,2,5300000,294,NULL),(5303000,'曲靖市',5303000,2,5300000,295,NULL),(5304000,'玉溪市',5304000,2,5300000,296,NULL),(5305000,'保山市',5305000,2,5300000,297,NULL),(5306000,'昭通市',5306000,2,5300000,298,NULL),(5307000,'丽江市',5307000,2,5300000,299,NULL),(5308000,'普洱市',5308000,2,5300000,300,NULL),(5309000,'临沧市',5309000,2,5300000,301,NULL),(5323000,'楚雄彝族自治州',5323000,2,5300000,302,NULL),(5325000,'红河哈尼族彝族自治州',5325000,2,5300000,303,NULL),(5326000,'文山壮族苗族自治州',5326000,2,5300000,304,NULL),(5328000,'西双版纳傣族自治州',5328000,2,5300000,305,NULL),(5329000,'大理白族自治州',5329000,2,5300000,306,NULL),(5331000,'德宏傣族景颇族自治州',5331000,2,5300000,307,NULL),(5333000,'怒江傈僳族自治州',5333000,2,5300000,308,NULL),(5334000,'迪庆藏族自治州',5334000,2,5300000,309,NULL),(5400000,'西藏自治区',5400000,1,0,310,NULL),(5401000,'拉萨市',5401000,2,5400000,311,NULL),(5402000,'日喀则市',5402000,2,5400000,312,NULL),(5403000,'昌都市',5403000,2,5400000,313,NULL),(5404000,'林芝市',5404000,2,5400000,314,NULL),(5405000,'山南市',5405000,2,5400000,315,NULL),(5406000,'那曲市',5406000,2,5400000,316,NULL),(5425000,'阿里地区',5425000,2,5400000,317,NULL),(6100000,'陕西省',6100000,1,0,318,NULL),(6101000,'西安市',6101000,2,6100000,319,NULL),(6102000,'铜川市',6102000,2,6100000,320,NULL),(6103000,'宝鸡市',6103000,2,6100000,321,NULL),(6104000,'咸阳市',6104000,2,6100000,322,NULL),(6105000,'渭南市',6105000,2,6100000,323,NULL),(6106000,'延安市',6106000,2,6100000,324,NULL),(6107000,'汉中市',6107000,2,6100000,325,NULL),(6108000,'榆林市',6108000,2,6100000,326,NULL),(6109000,'安康市',6109000,2,6100000,327,NULL),(6110000,'商洛市',6110000,2,6100000,328,NULL),(6200000,'甘肃省',6200000,1,0,329,NULL),(6201000,'兰州市',6201000,2,6200000,330,NULL),(6202000,'嘉峪关市',6202000,2,6200000,331,NULL),(6203000,'金昌市',6203000,2,6200000,332,NULL),(6204000,'白银市',6204000,2,6200000,333,NULL),(6205000,'天水市',6205000,2,6200000,334,NULL),(6206000,'武威市',6206000,2,6200000,335,NULL),(6207000,'张掖市',6207000,2,6200000,336,NULL),(6208000,'平凉市',6208000,2,6200000,337,NULL),(6209000,'酒泉市',6209000,2,6200000,338,NULL),(6210000,'庆阳市',6210000,2,6200000,339,NULL),(6211000,'定西市',6211000,2,6200000,340,NULL),(6212000,'陇南市',6212000,2,6200000,341,NULL),(6229000,'临夏回族自治州',6229000,2,6200000,342,NULL),(6230000,'甘南藏族自治州',6230000,2,6200000,343,NULL),(6300000,'青海省',6300000,1,0,344,NULL),(6301000,'西宁市',6301000,2,6300000,345,NULL),(6302000,'海东市',6302000,2,6300000,346,NULL),(6322000,'海北藏族自治州',6322000,2,6300000,347,NULL),(6323000,'黄南藏族自治州',6323000,2,6300000,348,NULL),(6325000,'海南藏族自治州',6325000,2,6300000,349,NULL),(6326000,'果洛藏族自治州',6326000,2,6300000,350,NULL),(6327000,'玉树藏族自治州',6327000,2,6300000,351,NULL),(6328000,'海西蒙古族藏族自治州',6328000,2,6300000,352,NULL),(6400000,'宁夏回族自治区',6400000,1,0,353,NULL),(6401000,'银川市',6401000,2,6400000,354,NULL),(6402000,'石嘴山市',6402000,2,6400000,355,NULL),(6403000,'吴忠市',6403000,2,6400000,356,NULL),(6404000,'固原市',6404000,2,6400000,357,NULL),(6405000,'中卫市',6405000,2,6400000,358,NULL),(6500000,'新疆维吾尔自治区',6500000,1,0,359,NULL),(6501000,'乌鲁木齐市',6501000,2,6500000,360,NULL),(6502000,'克拉玛依市',6502000,2,6500000,361,NULL),(6504000,'吐鲁番市',6504000,2,6500000,362,NULL),(6505000,'哈密市',6505000,2,6500000,363,NULL),(6523000,'昌吉回族自治州',6523000,2,6500000,364,NULL),(6527000,'博尔塔拉蒙古自治州',6527000,2,6500000,365,NULL),(6528000,'巴音郭楞蒙古自治州',6528000,2,6500000,366,NULL),(6529000,'阿克苏地区',6529000,2,6500000,367,NULL),(6530000,'克孜勒苏柯尔克孜自治州',6530000,2,6500000,368,NULL),(6531000,'喀什地区',6531000,2,6500000,369,NULL),(6532000,'和田地区',6532000,2,6500000,370,NULL),(6540000,'伊犁哈萨克自治州',6540000,2,6500000,371,NULL),(6542000,'塔城地区',6542000,2,6500000,372,NULL),(6543000,'阿勒泰地区',6543000,2,6500000,373,NULL),(6590000,'直辖县',6590000,2,6500000,374,NULL),(7011559,'香港岛',7011559,2,7013135,376,NULL),(7012837,'九龙',7012837,2,7013135,377,NULL),(7013135,'香港特别行政区',7013135,1,0,375,NULL),(7013591,'新界',7013591,2,7013135,378,NULL),(7110196,'氹仔岛',7110196,2,7112407,381,NULL),(7111217,'澳门半岛',7111217,2,7112407,380,NULL),(7112407,'澳门特别行政区',7112407,1,0,379,NULL),(7113878,'路环岛',7113878,2,7112407,382,NULL),(7210006,'苗栗县',7210006,2,7212684,394,NULL),(7210341,'桃园市',7210341,2,7212684,404,NULL),(7210496,'宜兰县',7210496,2,7212684,405,NULL),(7210628,'新竹市',7210628,2,7212684,387,NULL),(7210683,'台东县',7210683,2,7212684,403,NULL),(7210805,'云林县',7210805,2,7212684,406,NULL),(7210872,'新竹县',7210872,2,7212684,388,NULL),(7210941,'嘉义县',7210941,2,7212684,386,NULL),(7211135,'台北市',7211135,2,7212684,402,NULL),(7211363,'彰化县',7211363,2,7212684,384,NULL),(7211448,'澎湖县',7211448,2,7212684,398,NULL),(7211810,'台南市',7211810,2,7212684,401,NULL),(7212569,'南海岛',7212569,2,7212684,395,NULL),(7212684,'台湾省',7212684,1,0,383,NULL),(7212732,'高雄市',7212732,2,7212684,390,NULL),(7212735,'嘉义市',7212735,2,7212684,385,NULL),(7213169,'金门县',7213169,2,7212684,392,NULL),(7213286,'南投县',7213286,2,7212684,396,NULL),(7213368,'屏东县',7213368,2,7212684,399,NULL),(7213392,'台中市',7213392,2,7212684,400,NULL),(7213431,'新北市',7213431,2,7212684,397,NULL),(7213494,'连江县',7213494,2,7212684,393,NULL),(7213659,'花莲县',7213659,2,7212684,389,NULL),(7214088,'基隆市',7214088,2,7212684,391,NULL); 212 | /*!40000 ALTER TABLE `com_district` ENABLE KEYS */; 213 | UNLOCK TABLES; 214 | 215 | -- 216 | -- Table structure for table `com_district_level` 217 | -- 218 | 219 | DROP TABLE IF EXISTS `com_district_level`; 220 | /*!40101 SET @saved_cs_client = @@character_set_client */; 221 | /*!40101 SET character_set_client = utf8 */; 222 | CREATE TABLE `com_district_level` ( 223 | `id` int(11) NOT NULL AUTO_INCREMENT, 224 | `name` varchar(255) NOT NULL COMMENT '级别名称', 225 | `level` int(11) NOT NULL COMMENT '级别序号(数值大的在前,不应重复)', 226 | PRIMARY KEY (`id`) 227 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 228 | /*!40101 SET character_set_client = @saved_cs_client */; 229 | 230 | -- 231 | -- Dumping data for table `com_district_level` 232 | -- 233 | 234 | LOCK TABLES `com_district_level` WRITE; 235 | /*!40000 ALTER TABLE `com_district_level` DISABLE KEYS */; 236 | INSERT INTO `com_district_level` VALUES (1,'省',1),(2,'市',2); 237 | /*!40000 ALTER TABLE `com_district_level` ENABLE KEYS */; 238 | UNLOCK TABLES; 239 | 240 | -- 241 | -- Table structure for table `com_provincial` 242 | -- 243 | 244 | DROP TABLE IF EXISTS `com_provincial`; 245 | /*!40101 SET @saved_cs_client = @@character_set_client */; 246 | /*!40101 SET character_set_client = utf8 */; 247 | CREATE TABLE `com_provincial` ( 248 | `pid` int(11) NOT NULL DEFAULT '0', 249 | `Provincial` varchar(50) DEFAULT NULL, 250 | PRIMARY KEY (`pid`) 251 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 252 | /*!40101 SET character_set_client = @saved_cs_client */; 253 | 254 | -- 255 | -- Dumping data for table `com_provincial` 256 | -- 257 | 258 | LOCK TABLES `com_provincial` WRITE; 259 | /*!40000 ALTER TABLE `com_provincial` DISABLE KEYS */; 260 | INSERT INTO `com_provincial` VALUES (1,'北京'),(2,'天津'),(3,'上海'),(4,'重庆'),(5,'河北'),(6,'山西'),(7,'辽宁'),(8,'吉林'),(9,'黑龙江'),(10,'江苏'),(11,'浙江'),(12,'安徽'),(13,'福建'),(14,'江西'),(15,'山东'),(16,'河南'),(17,'湖北(武汉)'),(18,'湖北(其他地区)'),(19,'湖南'),(20,'广东'),(21,'甘肃'),(22,'四川'),(23,'贵州'),(24,'海南'),(25,'云南'),(26,'青海'),(27,'陕西'),(28,'广西'),(29,'西藏'),(30,'宁夏'),(31,'新疆'),(32,'内蒙'),(35,'大陆以外(香港)'),(36,'大陆以外(澳门)'),(37,'大陆以外(台湾)'),(38,'大陆以外(其他国家地区)'); 261 | /*!40000 ALTER TABLE `com_provincial` ENABLE KEYS */; 262 | UNLOCK TABLES; 263 | 264 | -- 265 | -- Table structure for table `org_dep` 266 | -- 267 | 268 | DROP TABLE IF EXISTS `org_dep`; 269 | /*!40101 SET @saved_cs_client = @@character_set_client */; 270 | /*!40101 SET character_set_client = utf8 */; 271 | CREATE TABLE `org_dep` ( 272 | `id` int(11) NOT NULL AUTO_INCREMENT, 273 | `org_id` int(11) NOT NULL, 274 | `dep_name` varchar(100) NOT NULL, 275 | `level` int(11) NOT NULL, 276 | `is_del` int(11) NOT NULL DEFAULT '0', 277 | `status` int(11) NOT NULL DEFAULT '0', 278 | `remark` varchar(100) DEFAULT NULL, 279 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 280 | PRIMARY KEY (`id`) 281 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 282 | /*!40101 SET character_set_client = @saved_cs_client */; 283 | 284 | -- 285 | -- Dumping data for table `org_dep` 286 | -- 287 | 288 | LOCK TABLES `org_dep` WRITE; 289 | /*!40000 ALTER TABLE `org_dep` DISABLE KEYS */; 290 | /*!40000 ALTER TABLE `org_dep` ENABLE KEYS */; 291 | UNLOCK TABLES; 292 | 293 | -- 294 | -- Table structure for table `org_tag` 295 | -- 296 | 297 | DROP TABLE IF EXISTS `org_tag`; 298 | /*!40101 SET @saved_cs_client = @@character_set_client */; 299 | /*!40101 SET character_set_client = utf8 */; 300 | CREATE TABLE `org_tag` ( 301 | `id` int(11) NOT NULL AUTO_INCREMENT, 302 | `org_id` int(11) NOT NULL, 303 | `dep_id` int(11) NOT NULL, 304 | `name` varchar(100) DEFAULT NULL, 305 | `is_del` int(11) NOT NULL DEFAULT '0', 306 | `status` int(11) NOT NULL DEFAULT '0', 307 | `remark` varchar(100) DEFAULT NULL, 308 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 309 | PRIMARY KEY (`id`) 310 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 311 | /*!40101 SET character_set_client = @saved_cs_client */; 312 | 313 | -- 314 | -- Dumping data for table `org_tag` 315 | -- 316 | 317 | LOCK TABLES `org_tag` WRITE; 318 | /*!40000 ALTER TABLE `org_tag` DISABLE KEYS */; 319 | /*!40000 ALTER TABLE `org_tag` ENABLE KEYS */; 320 | UNLOCK TABLES; 321 | 322 | -- 323 | -- Table structure for table `org_tag_admin` 324 | -- 325 | 326 | DROP TABLE IF EXISTS `org_tag_admin`; 327 | /*!40101 SET @saved_cs_client = @@character_set_client */; 328 | /*!40101 SET character_set_client = utf8 */; 329 | CREATE TABLE `org_tag_admin` ( 330 | `id` int(11) NOT NULL AUTO_INCREMENT, 331 | `org_id` int(11) NOT NULL, 332 | `dep_id` int(11) NOT NULL, 333 | `tag_id` int(11) NOT NULL, 334 | `admin_id` int(11) NOT NULL, 335 | `is_del` int(11) NOT NULL DEFAULT '0', 336 | `status` int(11) NOT NULL DEFAULT '0', 337 | `remark` varchar(100) DEFAULT NULL, 338 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 339 | PRIMARY KEY (`id`) 340 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 341 | /*!40101 SET character_set_client = @saved_cs_client */; 342 | 343 | -- 344 | -- Dumping data for table `org_tag_admin` 345 | -- 346 | 347 | LOCK TABLES `org_tag_admin` WRITE; 348 | /*!40000 ALTER TABLE `org_tag_admin` DISABLE KEYS */; 349 | /*!40000 ALTER TABLE `org_tag_admin` ENABLE KEYS */; 350 | UNLOCK TABLES; 351 | 352 | -- 353 | -- Table structure for table `org_tag_user` 354 | -- 355 | 356 | DROP TABLE IF EXISTS `org_tag_user`; 357 | /*!40101 SET @saved_cs_client = @@character_set_client */; 358 | /*!40101 SET character_set_client = utf8 */; 359 | CREATE TABLE `org_tag_user` ( 360 | `id` int(11) NOT NULL AUTO_INCREMENT, 361 | `org_id` int(11) NOT NULL, 362 | `dep_id` int(11) NOT NULL, 363 | `tag_id` int(11) NOT NULL, 364 | `userID` varchar(100) NOT NULL, 365 | `is_del` int(11) NOT NULL DEFAULT '0', 366 | `status` int(11) NOT NULL DEFAULT '0', 367 | `remark` varchar(100) DEFAULT NULL, 368 | `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 369 | PRIMARY KEY (`id`) 370 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 371 | /*!40101 SET character_set_client = @saved_cs_client */; 372 | 373 | -- 374 | -- Dumping data for table `org_tag_user` 375 | -- 376 | 377 | LOCK TABLES `org_tag_user` WRITE; 378 | /*!40000 ALTER TABLE `org_tag_user` DISABLE KEYS */; 379 | /*!40000 ALTER TABLE `org_tag_user` ENABLE KEYS */; 380 | UNLOCK TABLES; 381 | 382 | -- 383 | -- Table structure for table `org_user_info_company` 384 | -- 385 | 386 | DROP TABLE IF EXISTS `org_user_info_company`; 387 | /*!40101 SET @saved_cs_client = @@character_set_client */; 388 | /*!40101 SET character_set_client = utf8 */; 389 | CREATE TABLE `org_user_info_company` ( 390 | `id` int(11) NOT NULL AUTO_INCREMENT, 391 | `cor_id` int(11) NOT NULL COMMENT '机构id', 392 | `cor_name` varchar(100) NOT NULL COMMENT '机构名称', 393 | `userID` varchar(100) NOT NULL COMMENT '用户标识', 394 | `name` varchar(100) NOT NULL COMMENT '姓名', 395 | `school` varchar(100) DEFAULT NULL COMMENT '学院', 396 | `grade` varchar(20) DEFAULT NULL COMMENT '年级', 397 | `source_place` varchar(30) DEFAULT NULL COMMENT '生源地', 398 | `telphone` varchar(20) DEFAULT NULL COMMENT '手机号', 399 | `is_left_bj` varchar(10) DEFAULT NULL COMMENT '是否离京', 400 | `left_date` varchar(10) DEFAULT NULL COMMENT '离开日期', 401 | `left_transport` varchar(20) DEFAULT NULL COMMENT '离开使用交通工具', 402 | `left_transport_info` varchar(100) DEFAULT NULL COMMENT '具体交通信息', 403 | `goto_hubei` varchar(20) DEFAULT NULL COMMENT '去湖北情况', 404 | `goto_hubei_date1` varchar(10) DEFAULT NULL COMMENT '湖北日期起', 405 | `goto_hubei_date2` varchar(10) DEFAULT NULL COMMENT '湖北日期止', 406 | `goto_hubei_info` varchar(1000) DEFAULT NULL COMMENT '去湖北详情', 407 | `is_touch_hubei_person` varchar(10) DEFAULT NULL COMMENT '是否接触过湖北地区活动的人员', 408 | `touch_hubei_date1` varchar(10) DEFAULT NULL COMMENT '接触时间1', 409 | `touch_hubei_date2` varchar(10) DEFAULT NULL COMMENT '接触时间2', 410 | `is_return` varchar(50) DEFAULT NULL COMMENT '是否返京', 411 | `return_date` varchar(10) DEFAULT NULL COMMENT '返京日期', 412 | `return_transport` varchar(50) DEFAULT NULL COMMENT '交通工具', 413 | `return_transport_info` varchar(100) DEFAULT NULL COMMENT '交通工具详细信息', 414 | `is_del` int(11) NOT NULL DEFAULT '0' COMMENT '是否删除', 415 | `ip` varchar(20) DEFAULT NULL COMMENT 'IP', 416 | `agent` varchar(500) DEFAULT NULL, 417 | `time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 418 | `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间', 419 | PRIMARY KEY (`id`) 420 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 421 | /*!40101 SET character_set_client = @saved_cs_client */; 422 | 423 | -- 424 | -- Dumping data for table `org_user_info_company` 425 | -- 426 | 427 | LOCK TABLES `org_user_info_company` WRITE; 428 | /*!40000 ALTER TABLE `org_user_info_company` DISABLE KEYS */; 429 | /*!40000 ALTER TABLE `org_user_info_company` ENABLE KEYS */; 430 | UNLOCK TABLES; 431 | 432 | -- 433 | -- Table structure for table `org_user_info_school` 434 | -- 435 | 436 | DROP TABLE IF EXISTS `org_user_info_school`; 437 | /*!40101 SET @saved_cs_client = @@character_set_client */; 438 | /*!40101 SET character_set_client = utf8 */; 439 | CREATE TABLE `org_user_info_school` ( 440 | `id` int(11) NOT NULL AUTO_INCREMENT, 441 | `cor_id` int(11) NOT NULL COMMENT '机构id', 442 | `cor_name` varchar(100) NOT NULL COMMENT '机构名称', 443 | `userID` varchar(100) NOT NULL COMMENT '用户标识', 444 | `name` varchar(100) NOT NULL COMMENT '姓名', 445 | `school` varchar(100) DEFAULT NULL COMMENT '学院', 446 | `grade` varchar(20) DEFAULT NULL COMMENT '年级', 447 | `source_place` varchar(30) DEFAULT NULL COMMENT '生源地', 448 | `telphone` varchar(20) DEFAULT NULL COMMENT '手机号', 449 | `is_left_bj` varchar(10) DEFAULT NULL COMMENT '是否离京', 450 | `left_date` varchar(10) DEFAULT NULL COMMENT '离开日期', 451 | `left_transport` varchar(20) DEFAULT NULL COMMENT '离开使用交通工具', 452 | `left_transport_info` varchar(100) DEFAULT NULL COMMENT '具体交通信息', 453 | `goto_hubei` varchar(20) DEFAULT NULL COMMENT '去湖北情况', 454 | `goto_hubei_date1` varchar(10) DEFAULT NULL COMMENT '湖北日期起', 455 | `goto_hubei_date2` varchar(10) DEFAULT NULL COMMENT '湖北日期止', 456 | `goto_hubei_info` varchar(1000) DEFAULT NULL COMMENT '去湖北详情', 457 | `is_touch_hubei_person` varchar(10) DEFAULT NULL COMMENT '是否接触过湖北地区活动的人员', 458 | `touch_hubei_date1` varchar(10) DEFAULT NULL COMMENT '接触时间1', 459 | `touch_hubei_date2` varchar(10) DEFAULT NULL COMMENT '接触时间2', 460 | `is_return` varchar(50) DEFAULT NULL COMMENT '是否返京', 461 | `return_date` varchar(10) DEFAULT NULL COMMENT '返京日期', 462 | `return_transport` varchar(50) DEFAULT NULL COMMENT '交通工具', 463 | `return_transport_info` varchar(100) DEFAULT NULL COMMENT '交通工具详细信息', 464 | `is_del` int(11) NOT NULL DEFAULT '0' COMMENT '是否删除', 465 | `ip` varchar(20) DEFAULT NULL COMMENT 'IP', 466 | `agent` varchar(500) DEFAULT NULL, 467 | `time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 468 | `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最后更新时间', 469 | PRIMARY KEY (`id`) 470 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 471 | /*!40101 SET character_set_client = @saved_cs_client */; 472 | 473 | -- 474 | -- Dumping data for table `org_user_info_school` 475 | -- 476 | 477 | LOCK TABLES `org_user_info_school` WRITE; 478 | /*!40000 ALTER TABLE `org_user_info_school` DISABLE KEYS */; 479 | /*!40000 ALTER TABLE `org_user_info_school` ENABLE KEYS */; 480 | UNLOCK TABLES; 481 | 482 | -- 483 | -- Table structure for table `org_whitelist` 484 | -- 485 | 486 | DROP TABLE IF EXISTS `org_whitelist`; 487 | /*!40101 SET @saved_cs_client = @@character_set_client */; 488 | /*!40101 SET character_set_client = utf8 */; 489 | CREATE TABLE `org_whitelist` ( 490 | `id` int(11) NOT NULL AUTO_INCREMENT, 491 | `org_id` int(11) NOT NULL COMMENT '机构id', 492 | `userID` varchar(100) CHARACTER SET utf8 COLLATE utf8_german2_ci NOT NULL COMMENT '用户标识', 493 | `name` varchar(100) NOT NULL COMMENT '姓名', 494 | `gender` varchar(10) DEFAULT NULL COMMENT '性别', 495 | `sub1_department_id` int(10) DEFAULT NULL COMMENT '一级子部门id', 496 | `sub2_department_id` int(10) DEFAULT NULL COMMENT '二级子部门', 497 | `tag1` varchar(100) DEFAULT NULL COMMENT '类型1(学生类型)', 498 | `tag2` varchar(100) DEFAULT NULL, 499 | `tag3` varchar(100) DEFAULT NULL, 500 | `tag4` varchar(100) DEFAULT NULL, 501 | `add_datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间', 502 | `last_update_time` datetime DEFAULT NULL COMMENT '最后更新时间', 503 | `add_remark` varchar(200) NOT NULL COMMENT '添加备注', 504 | `dep_name` varchar(100) DEFAULT NULL COMMENT '用户录入数据,为了便于核对', 505 | `report_id` int(11) DEFAULT '0' COMMENT '报告编号', 506 | `report_date` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '最后报告时间', 507 | `status` int(10) NOT NULL DEFAULT '0' COMMENT '状态', 508 | PRIMARY KEY (`id`) 509 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 510 | /*!40101 SET character_set_client = @saved_cs_client */; 511 | 512 | -- 513 | -- Dumping data for table `org_whitelist` 514 | -- 515 | 516 | LOCK TABLES `org_whitelist` WRITE; 517 | /*!40000 ALTER TABLE `org_whitelist` DISABLE KEYS */; 518 | /*!40000 ALTER TABLE `org_whitelist` ENABLE KEYS */; 519 | UNLOCK TABLES; 520 | 521 | -- 522 | -- Table structure for table `organization` 523 | -- 524 | 525 | DROP TABLE IF EXISTS `organization`; 526 | /*!40101 SET @saved_cs_client = @@character_set_client */; 527 | /*!40101 SET character_set_client = utf8 */; 528 | CREATE TABLE `organization` ( 529 | `id` int(11) NOT NULL AUTO_INCREMENT, 530 | `corpname` varchar(200) NOT NULL COMMENT '单位名称', 531 | `corpname_full` varchar(200) NOT NULL, 532 | `access_type` varchar(10) DEFAULT 'mp' COMMENT 'mp 小程序 qw 企业微信', 533 | `template_code` varchar(50) NOT NULL COMMENT '单位模板', 534 | `corp_code` varchar(100) NOT NULL COMMENT '单位编号', 535 | `type_corpname` varchar(100) NOT NULL COMMENT '公司名称/学校名称', 536 | `type_username` varchar(100) NOT NULL COMMENT '学号/职工号等内容提示语', 537 | `admin_name` varchar(20) DEFAULT NULL, 538 | `tel` varchar(20) DEFAULT NULL, 539 | `is_del` int(11) NOT NULL DEFAULT '0', 540 | `status` int(11) NOT NULL DEFAULT '0', 541 | `remark` varchar(1000) DEFAULT NULL, 542 | `add_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 543 | PRIMARY KEY (`id`), 544 | UNIQUE KEY `编码唯一` (`corp_code`) 545 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 546 | /*!40101 SET character_set_client = @saved_cs_client */; 547 | 548 | -- 549 | -- Dumping data for table `organization` 550 | -- 551 | 552 | LOCK TABLES `organization` WRITE; 553 | /*!40000 ALTER TABLE `organization` DISABLE KEYS */; 554 | INSERT INTO `organization` VALUES (1,'缺省学校名称','缺省学校名称','mp','default','100000001','学校','学号',NULL,NULL,0,0,NULL,'2020-02-22 21:47:18'),(2,'缺省公司名称','缺省公司名称','mp','company','100000002','单位','职工号',NULL,NULL,0,0,NULL,'2020-02-22 21:47:53'); 555 | /*!40000 ALTER TABLE `organization` ENABLE KEYS */; 556 | UNLOCK TABLES; 557 | 558 | -- 559 | -- Table structure for table `report_record_company` 560 | -- 561 | 562 | DROP TABLE IF EXISTS `report_record_company`; 563 | /*!40101 SET @saved_cs_client = @@character_set_client */; 564 | /*!40101 SET character_set_client = utf8 */; 565 | CREATE TABLE `report_record_company` ( 566 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 567 | `wxuid` int(11) DEFAULT NULL COMMENT '微信小程序用户id', 568 | `org_id` int(11) DEFAULT NULL COMMENT '机构id', 569 | `org_name` varchar(100) DEFAULT NULL COMMENT '机构名称', 570 | `userID` varchar(100) DEFAULT NULL COMMENT '用户标识码', 571 | `name` varchar(100) DEFAULT NULL COMMENT '姓名', 572 | `is_return_school` int(11) NOT NULL COMMENT ' 是否返校(选项值)', 573 | `return_dorm_num` varchar(255) DEFAULT NULL COMMENT '所在宿舍号', 574 | `return_time` date DEFAULT NULL COMMENT '返校时间(Unix时间戳-UTC时间)', 575 | `return_district_value` int(11) DEFAULT NULL COMMENT '从哪里返回学校(行政区划字典值)', 576 | `return_district_path` varchar(255) DEFAULT NULL COMMENT '从哪里返回学校(从上级到下级按逗号分隔的字典值)', 577 | `return_traffic_info` varchar(4000) DEFAULT NULL COMMENT '返校过程的交通信息', 578 | `current_district_value` int(11) DEFAULT NULL COMMENT '目前所在地', 579 | `current_district_path` varchar(255) DEFAULT NULL COMMENT '目前所在地(从上级到下级按逗号分隔的字典值)', 580 | `current_health_value` int(11) DEFAULT NULL COMMENT '目前本人身体状况(选项值)', 581 | `current_contagion_risk_value` int(11) DEFAULT NULL COMMENT '被传染风险(选项值)', 582 | `current_temperature` float DEFAULT NULL COMMENT '当前体温(摄氏度)', 583 | `psy_status` int(11) DEFAULT NULL, 584 | `psy_demand` int(11) DEFAULT NULL, 585 | `psy_knowledge` int(11) DEFAULT NULL, 586 | `return_company_date` varchar(100) DEFAULT NULL, 587 | `plan_company_date` varchar(100) DEFAULT NULL, 588 | `template_code` varchar(100) DEFAULT NULL, 589 | `remarks` varchar(4000) DEFAULT NULL COMMENT '其它信息', 590 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 591 | PRIMARY KEY (`id`) 592 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 593 | /*!40101 SET character_set_client = @saved_cs_client */; 594 | 595 | -- 596 | -- Dumping data for table `report_record_company` 597 | -- 598 | 599 | LOCK TABLES `report_record_company` WRITE; 600 | /*!40000 ALTER TABLE `report_record_company` DISABLE KEYS */; 601 | /*!40000 ALTER TABLE `report_record_company` ENABLE KEYS */; 602 | UNLOCK TABLES; 603 | 604 | -- 605 | -- Table structure for table `report_record_default` 606 | -- 607 | 608 | DROP TABLE IF EXISTS `report_record_default`; 609 | /*!40101 SET @saved_cs_client = @@character_set_client */; 610 | /*!40101 SET character_set_client = utf8 */; 611 | CREATE TABLE `report_record_default` ( 612 | `id` bigint(20) NOT NULL AUTO_INCREMENT, 613 | `wxuid` int(11) DEFAULT NULL COMMENT '微信小程序用户id', 614 | `org_id` int(11) DEFAULT NULL COMMENT '机构id', 615 | `org_name` varchar(100) DEFAULT NULL COMMENT '机构名称', 616 | `userID` varchar(100) DEFAULT NULL COMMENT '用户标识码', 617 | `name` varchar(100) DEFAULT NULL COMMENT '姓名', 618 | `is_return_school` int(11) NOT NULL COMMENT ' 是否返校(选项值)', 619 | `return_dorm_num` varchar(255) DEFAULT NULL COMMENT '所在宿舍号', 620 | `return_time` date DEFAULT NULL COMMENT '返校时间(Unix时间戳-UTC时间)', 621 | `return_district_value` int(11) DEFAULT NULL COMMENT '从哪里返回学校(行政区划字典值)', 622 | `return_district_path` varchar(255) DEFAULT NULL COMMENT '从哪里返回学校(从上级到下级按逗号分隔的字典值)', 623 | `return_traffic_info` varchar(4000) DEFAULT NULL COMMENT '返校过程的交通信息', 624 | `current_district_value` int(11) DEFAULT NULL COMMENT '目前所在地', 625 | `current_district_path` varchar(255) DEFAULT NULL COMMENT '目前所在地(从上级到下级按逗号分隔的字典值)', 626 | `current_health_value` int(11) DEFAULT NULL COMMENT '目前本人身体状况(选项值)', 627 | `current_contagion_risk_value` int(11) DEFAULT NULL COMMENT '被传染风险(选项值)', 628 | `current_temperature` float DEFAULT NULL COMMENT '当前体温(摄氏度)', 629 | `psy_status` int(11) DEFAULT NULL, 630 | `psy_demand` int(11) DEFAULT NULL, 631 | `psy_knowledge` int(11) DEFAULT NULL, 632 | `return_company_date` varchar(100) DEFAULT NULL, 633 | `plan_company_date` varchar(100) DEFAULT NULL, 634 | `template_code` varchar(100) DEFAULT NULL, 635 | `remarks` varchar(4000) DEFAULT NULL COMMENT '其它信息', 636 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 637 | PRIMARY KEY (`id`) 638 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 639 | /*!40101 SET character_set_client = @saved_cs_client */; 640 | 641 | -- 642 | -- Dumping data for table `report_record_default` 643 | -- 644 | 645 | LOCK TABLES `report_record_default` WRITE; 646 | /*!40000 ALTER TABLE `report_record_default` DISABLE KEYS */; 647 | /*!40000 ALTER TABLE `report_record_default` ENABLE KEYS */; 648 | UNLOCK TABLES; 649 | 650 | -- 651 | -- Table structure for table `report_template` 652 | -- 653 | 654 | DROP TABLE IF EXISTS `report_template`; 655 | /*!40101 SET @saved_cs_client = @@character_set_client */; 656 | /*!40101 SET character_set_client = utf8 */; 657 | CREATE TABLE `report_template` ( 658 | `id` int(11) NOT NULL AUTO_INCREMENT, 659 | `name` varchar(30) NOT NULL, 660 | `code` varchar(100) NOT NULL, 661 | `remark` varchar(200) DEFAULT NULL, 662 | `is_visable` int(11) NOT NULL DEFAULT '0', 663 | `is_del` int(11) NOT NULL DEFAULT '0', 664 | `add_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 665 | PRIMARY KEY (`id`) 666 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 667 | /*!40101 SET character_set_client = @saved_cs_client */; 668 | 669 | -- 670 | -- Dumping data for table `report_template` 671 | -- 672 | 673 | LOCK TABLES `report_template` WRITE; 674 | /*!40000 ALTER TABLE `report_template` DISABLE KEYS */; 675 | INSERT INTO `report_template` VALUES (1,'高校缺省模板','default','高校缺省',1,0,'2020-03-01 13:29:25'),(2,'公司缺省模板','company','公司缺省',1,0,'2020-03-01 13:30:02'); 676 | /*!40000 ALTER TABLE `report_template` ENABLE KEYS */; 677 | UNLOCK TABLES; 678 | 679 | -- 680 | -- Table structure for table `wx_mp_bind_info` 681 | -- 682 | 683 | DROP TABLE IF EXISTS `wx_mp_bind_info`; 684 | /*!40101 SET @saved_cs_client = @@character_set_client */; 685 | /*!40101 SET character_set_client = utf8 */; 686 | CREATE TABLE `wx_mp_bind_info` ( 687 | `id` int(11) NOT NULL AUTO_INCREMENT, 688 | `org_id` int(11) NOT NULL COMMENT 'department_id', 689 | `wx_uid` int(11) NOT NULL COMMENT 'weixin_id', 690 | `username` varchar(100) NOT NULL COMMENT '用户唯一表示', 691 | `isbind` int(11) NOT NULL DEFAULT '1' COMMENT '是否绑定', 692 | `bind_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 693 | `unbind_date` datetime DEFAULT NULL, 694 | `remark` varchar(100) DEFAULT NULL, 695 | PRIMARY KEY (`id`) 696 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 697 | /*!40101 SET character_set_client = @saved_cs_client */; 698 | 699 | -- 700 | -- Dumping data for table `wx_mp_bind_info` 701 | -- 702 | 703 | LOCK TABLES `wx_mp_bind_info` WRITE; 704 | /*!40000 ALTER TABLE `wx_mp_bind_info` DISABLE KEYS */; 705 | /*!40000 ALTER TABLE `wx_mp_bind_info` ENABLE KEYS */; 706 | UNLOCK TABLES; 707 | 708 | -- 709 | -- Table structure for table `wx_mp_log` 710 | -- 711 | 712 | DROP TABLE IF EXISTS `wx_mp_log`; 713 | /*!40101 SET @saved_cs_client = @@character_set_client */; 714 | /*!40101 SET character_set_client = utf8 */; 715 | CREATE TABLE `wx_mp_log` ( 716 | `id` int(11) NOT NULL AUTO_INCREMENT, 717 | `uid` int(11) DEFAULT NULL, 718 | `url` varchar(100) DEFAULT NULL, 719 | `token` varchar(200) DEFAULT NULL, 720 | `time` datetime NOT NULL, 721 | PRIMARY KEY (`id`) 722 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 723 | /*!40101 SET character_set_client = @saved_cs_client */; 724 | 725 | -- 726 | -- Dumping data for table `wx_mp_log` 727 | -- 728 | 729 | LOCK TABLES `wx_mp_log` WRITE; 730 | /*!40000 ALTER TABLE `wx_mp_log` DISABLE KEYS */; 731 | /*!40000 ALTER TABLE `wx_mp_log` ENABLE KEYS */; 732 | UNLOCK TABLES; 733 | 734 | -- 735 | -- Table structure for table `wx_mp_user` 736 | -- 737 | 738 | DROP TABLE IF EXISTS `wx_mp_user`; 739 | /*!40101 SET @saved_cs_client = @@character_set_client */; 740 | /*!40101 SET character_set_client = utf8 */; 741 | CREATE TABLE `wx_mp_user` ( 742 | `wid` int(11) NOT NULL AUTO_INCREMENT, 743 | `openid` varchar(512) DEFAULT NULL, 744 | `token` varchar(200) NOT NULL, 745 | `time_out` int(11) NOT NULL, 746 | `session_key` varchar(512) DEFAULT NULL, 747 | `nickname` varchar(512) DEFAULT NULL, 748 | `gender` varchar(512) DEFAULT NULL, 749 | `city` varchar(512) DEFAULT NULL, 750 | `avatar_url` varchar(512) DEFAULT NULL, 751 | `login_time` varchar(512) DEFAULT NULL, 752 | `userid` varchar(100) DEFAULT NULL, 753 | `name` varchar(100) DEFAULT NULL, 754 | `phone_num` varchar(30) DEFAULT NULL, 755 | `reg_date` date DEFAULT NULL COMMENT '注册时间', 756 | `status` int(11) DEFAULT '0', 757 | PRIMARY KEY (`wid`) 758 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 759 | /*!40101 SET character_set_client = @saved_cs_client */; 760 | 761 | -- 762 | -- Dumping data for table `wx_mp_user` 763 | -- 764 | 765 | LOCK TABLES `wx_mp_user` WRITE; 766 | /*!40000 ALTER TABLE `wx_mp_user` DISABLE KEYS */; 767 | /*!40000 ALTER TABLE `wx_mp_user` ENABLE KEYS */; 768 | UNLOCK TABLES; 769 | 770 | -- 771 | -- Table structure for table `wx_qy_access_token` 772 | -- 773 | 774 | DROP TABLE IF EXISTS `wx_qy_access_token`; 775 | /*!40101 SET @saved_cs_client = @@character_set_client */; 776 | /*!40101 SET character_set_client = utf8 */; 777 | CREATE TABLE `wx_qy_access_token` ( 778 | `id` int(11) NOT NULL AUTO_INCREMENT, 779 | `agent_id` varchar(20) NOT NULL, 780 | `access_token` varchar(300) NOT NULL, 781 | `expires_in` int(11) NOT NULL, 782 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 783 | PRIMARY KEY (`id`) 784 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 785 | /*!40101 SET character_set_client = @saved_cs_client */; 786 | 787 | -- 788 | -- Dumping data for table `wx_qy_access_token` 789 | -- 790 | 791 | LOCK TABLES `wx_qy_access_token` WRITE; 792 | /*!40000 ALTER TABLE `wx_qy_access_token` DISABLE KEYS */; 793 | /*!40000 ALTER TABLE `wx_qy_access_token` ENABLE KEYS */; 794 | UNLOCK TABLES; 795 | 796 | -- 797 | -- Table structure for table `wx_qy_log` 798 | -- 799 | 800 | DROP TABLE IF EXISTS `wx_qy_log`; 801 | /*!40101 SET @saved_cs_client = @@character_set_client */; 802 | /*!40101 SET character_set_client = utf8 */; 803 | CREATE TABLE `wx_qy_log` ( 804 | `id` int(11) NOT NULL AUTO_INCREMENT, 805 | `url` varchar(300) NOT NULL, 806 | `response` varchar(3300) NOT NULL, 807 | `type` varchar(100) NOT NULL, 808 | `ip` varchar(100) DEFAULT NULL, 809 | `agent` varchar(1000) DEFAULT NULL, 810 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 811 | PRIMARY KEY (`id`) 812 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 813 | /*!40101 SET character_set_client = @saved_cs_client */; 814 | 815 | -- 816 | -- Dumping data for table `wx_qy_log` 817 | -- 818 | 819 | LOCK TABLES `wx_qy_log` WRITE; 820 | /*!40000 ALTER TABLE `wx_qy_log` DISABLE KEYS */; 821 | /*!40000 ALTER TABLE `wx_qy_log` ENABLE KEYS */; 822 | UNLOCK TABLES; 823 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 824 | 825 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 826 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 827 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 828 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 829 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 830 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 831 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 832 | 833 | -- Dump completed on 2020-03-06 9:08:48 834 | ``` -------------------------------------------------------------------------------- /model/doc.md: -------------------------------------------------------------------------------- 1 | # 数据库设计文档 2 | 3 | ## 需求 4 | 5 | ### cookie 储存 6 | 7 | 当微信用户打开小程序时,会发来一个code,此时,后端需要做两件事 8 | 9 | 1. 向微信api发送请求,确定是合法用户,微信会返回用户的openid 此时我们将用户的openid作为用户的唯一标志,也就是数据库表中的主码 10 | 2. 生成session分发给用户,然后该session将会作为该用户发送请求时的标志。 11 | 12 | 这里有两种做法。 13 | 14 | 1. 将session储存 15 | 2. 不存,只校验时间合法性,所以。在middleware的session已经帮我们做了合法校验,无需再次存,这样也减少了不断读取数据库的时间。 16 | 17 | ### 上报人员信息 18 | 19 | 用户需要绑定信息,也就是说,帮定信息就是创建一个数据条目的过程,在这里为了简便,不再拆分表去满足第二范式。 20 | 21 | ``` go 22 | // WeChat means Who has loged in 23 | type WeChat struct{ 24 | gorm.Model 25 | OpenID string `gorm:"unique;"` 26 | } 27 | // Reporter 上报人 28 | type Reporter struct { 29 | gorm.Model 30 | WeChat WeChat `gorm:"association_foreignkey:WeChatRefer;unique;type:varchar(200)"` 31 | WeChatRefer string //对应的微信号 32 | OrgID int // 机构id 33 | Name string`gorm:"varchar(30);"` 34 | Gender int //0代表女性,1代表男性 35 | Tel int64 //手机号 36 | StuNum int64 //学号 37 | LastUpdateTime *time.Time`gorm:"type:datatime;default:null;"` //最后更新时间 38 | } 39 | 40 | ``` 41 | 42 | ### 上报记录 43 | 44 | ``` go 45 | // Record 上报记录 46 | type Record struct{ 47 | gorm.Model 48 | Reporter Reporter `gorm:"foreign_key:ReporterRefer;` 49 | ReporterRefer int 50 | IsReturnSchool int `gorm:"not null;"` //是否返校(选项) 51 | CurrentHealthValue int //当前身体状况 52 | CurrentDistrictPath int //当前所在地 53 | CurrentContagionRiskValue int //传染风险 54 | PsyStatus int //心理状况 55 | PsyDemand int //心理需求 56 | PsyKnowledge int //所需心理知识 57 | CurrentTemperature int //今日体温 58 | } 59 | ``` 60 | -------------------------------------------------------------------------------- /model/init.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "database/sql" 5 | 6 | _ "github.com/go-sql-driver/mysql" // 7 | _ "github.com/jinzhu/gorm/dialects/mysql" // 8 | ) 9 | 10 | // DB 适配其他版本的数据库连接实例 11 | var DB *sql.DB 12 | 13 | // 创建数据库连接实例 14 | func Database(conString string) { 15 | db, err := sql.Open("mysql", conString) 16 | 17 | if err != nil { 18 | panic("fail to connect database") 19 | } 20 | 21 | DB = db 22 | } 23 | -------------------------------------------------------------------------------- /model/report.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | // 上报记录 4 | type Record struct { 5 | Reporter Reporter `gorm:"foreign_key:ReporterRefer;"` 6 | ReporterRefer uint //关联上报人的主键,也就是Reporter.ID 7 | IsReturnSchool int `gorm:"not null;"` //是否返校(选项) 8 | CurrentHealthValue int //当前身体状况 9 | CurrentContagionRiskValue int //传染风险 10 | PsyStatus int //心理状况 11 | PsyDemand int //心理需求 12 | PsyKnowledge int //所需心理知识 13 | CurrentTemperature int //今日体温 14 | ReturnDistrictValue int 15 | CurrentDistrictValue int 16 | PlanCompanyDate string 17 | Remarks string //其他信息 18 | ReturnTime string //返校时间 19 | ReturnDormNum string //所在宿舍号 20 | ReturnTrafficInfo string //返校过程的交通信息 21 | ReturnDistrictPath string //从哪里返回学校(从上级到下级按逗号分隔的字典值) 22 | CurrentDistrictPath string //目前所在地(从上级到下级按逗号分隔的字典值) 23 | } 24 | -------------------------------------------------------------------------------- /model/user.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // WeChat means Who has loged in 8 | type WeChat struct { 9 | OpenID string `gorm:"unique;"` 10 | } 11 | 12 | // 上报人 13 | type Reporter struct { 14 | WeChat WeChat `gorm:"association_foreignkey:WeChatRefer;unique;type:varchar(200)"` 15 | WeChatRefer string //对应的微信号 16 | Corp Corp `gorm:"foreign_key:OrgID;unique;"` //对应旧版表中的Corp 17 | OrgID int // 机构id 18 | Name string `gorm:"varchar(30);"` 19 | Gender int //0代表女性,1代表男性 20 | Tel int64 //手机号 21 | StuNum int64 //学号 22 | LastUpdateTime *time.Time `gorm:"default:null;"` //最后更新时间 23 | } 24 | 25 | /* 26 | -------------------------以下为旧版表------------------------------ 27 | */ 28 | 29 | // 记录不同机构的不同模板号 30 | type Corp struct { 31 | Id int 32 | Corpid string 33 | TemplateCode string 34 | Corpname string 35 | TypeCorpname string 36 | TypeUsername string 37 | } 38 | 39 | // 学生 40 | type Student struct { 41 | Name string 42 | PhoneNum string 43 | UID string 44 | UserID string 45 | Corpid string 46 | IsRegistered int 47 | Password string 48 | } 49 | -------------------------------------------------------------------------------- /serializer/info.go: -------------------------------------------------------------------------------- 1 | package serializer 2 | 3 | // 用户序列化器 4 | type BindInfo struct { 5 | ErrCode int `json:"errcode"` 6 | IsBind int `json:"is_bind"` 7 | CorpCode string `json:"corp_code"` 8 | } 9 | 10 | // 序列化 11 | func BuildBindInfo(errCode int, isBind int, corpCode string) BindInfo { 12 | return BindInfo{ 13 | ErrCode: errCode, 14 | IsBind: isBind, 15 | CorpCode: corpCode, 16 | } 17 | } 18 | 19 | func BuildBindInfoResponse(errCode int, isBind int, corpCode string) Response { 20 | return Response{ 21 | Data: BuildBindInfo(errCode, isBind, corpCode), 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /serializer/main.go: -------------------------------------------------------------------------------- 1 | package serializer 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | // 基础序列化器 6 | type Response struct { 7 | Code int `json:"errcode"` 8 | Data interface{} `json:"data,omitempty"` 9 | Msg string `json:"msg"` 10 | Error string `json:"error,omitempty"` 11 | } 12 | 13 | // 三位数错误编码为复用http原本含义 14 | // 五位数错误编码为应用自定义错误 15 | // 五开头的五位数错误编码为服务器端错误,比如数据库操作失败 16 | // 四开头的五位数错误编码为客户端错误,有时候是客户端代码写错了,有时候是用户操作错误 17 | const ( 18 | // CodeCheckLogin 未登录 19 | CodeCheckLogin = 401 20 | // CodeNoRightErr 未授权访问 21 | CodeNoRightErr = 403 22 | // CodeDBError 数据库操作失败 23 | CodeDBError = 50001 24 | // CodeEncryptError 加密失败 25 | CodeEncryptError = 50002 26 | //CodeParamErr 各种奇奇怪怪的参数错误 27 | CodeParamErr = 40001 28 | ) 29 | 30 | // 通用错误处理 31 | func Err(errCode int, msg string, err error) Response { 32 | res := Response{ 33 | Code: errCode, 34 | Msg: msg, 35 | } 36 | // 生产环境隐藏底层报错 37 | if err != nil && gin.Mode() != gin.ReleaseMode { 38 | res.Error = err.Error() 39 | } 40 | return res 41 | } 42 | 43 | // 各种参数错误 44 | func ParamErr(msg string, err error) Response { 45 | if msg == "" { 46 | msg = "参数错误" 47 | } 48 | return Err(CodeParamErr, msg, err) 49 | } 50 | -------------------------------------------------------------------------------- /serializer/report.go: -------------------------------------------------------------------------------- 1 | package serializer 2 | 3 | import "Miniprogram-server-Golang/model" 4 | 5 | // 用户序列化器 6 | type Record struct { 7 | IsReturnSchool int `json:"is_return_school"` 8 | CurrentHealthValue int `json:"current_health_value"` 9 | CurrentContagionRiskValue int `json:"current_contagion_risk_value"` 10 | ReturnDistrictValue int `json:"return_district_value"` 11 | CurrentDistrictValue int `json:"current_district_value"` 12 | CurrentTemperature int `json:"current_temperature"` 13 | PsyStatus int `json:"psy_status"` 14 | PsyDemand int `json:"psy_demand"` 15 | PsyKnowledge int `json:"psy_knowledge"` 16 | ReturnTime string `json:"return_time"` 17 | ReturnDormNum string `json:"return_dorm_num"` 18 | ReturnTrafficInfo string `json:"return_traffic_info"` 19 | Remarks string `json:"remarks"` 20 | PlanCompanyDate string `json:"plan_company_date"` 21 | ReturnDistrictPath string `json:"return_district_path"` 22 | CurrentDistrictPath string `json:"current_district_path"` 23 | } 24 | 25 | // 生成返回消息体 26 | type ResponseData struct { 27 | Errcode int `json:"errcode"` 28 | IsEmpty int `json:"isEmpty"` 29 | Data interface{} `json:"data"` 30 | } 31 | 32 | // 序列化report 33 | func BuildRecord(record model.Record) Record { 34 | return Record{ 35 | IsReturnSchool: record.IsReturnSchool, 36 | ReturnTime: record.ReturnTime, 37 | ReturnDormNum: record.ReturnDormNum, 38 | ReturnTrafficInfo: record.ReturnTrafficInfo, 39 | CurrentHealthValue: record.CurrentHealthValue, 40 | CurrentContagionRiskValue: record.CurrentContagionRiskValue, 41 | ReturnDistrictValue: record.ReturnDistrictValue, 42 | CurrentDistrictValue: record.CurrentDistrictValue, 43 | CurrentTemperature: record.CurrentTemperature, 44 | PsyStatus: record.PsyStatus, 45 | PsyDemand: record.PsyDemand, 46 | Remarks: record.Remarks, 47 | PsyKnowledge: record.PsyKnowledge, 48 | PlanCompanyDate: record.PlanCompanyDate, 49 | ReturnDistrictPath: record.ReturnDistrictPath, 50 | CurrentDistrictPath: record.CurrentDistrictPath, 51 | } 52 | } 53 | 54 | // 相应上传成功 55 | func BuildSuccessSave() Response { 56 | return Response{ 57 | Msg: "上传成功", 58 | } 59 | } 60 | 61 | // 序列化响应 62 | func BuildLastDataResponse(isEmpty bool, record model.Record) Response { 63 | if isEmpty { 64 | return Response{ 65 | Data: ResponseData{0, 1, nil}, 66 | } 67 | } 68 | return Response{ 69 | Data: ResponseData{0, 0, BuildRecord(record)}, 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /serializer/user.go: -------------------------------------------------------------------------------- 1 | package serializer 2 | 3 | import "Miniprogram-server-Golang/model" 4 | 5 | // 状态 6 | type Status struct { 7 | UID int64 `json:"uid"` 8 | Token string `json:"token"` 9 | IsRegistered int `json:"is_registered"` 10 | ErrCode int `json:"errcode"` 11 | } 12 | 13 | // 表单模板序列化器 14 | type Corp struct { 15 | ErrCode int `json:"errcode"` 16 | Corpid string `json:"corpid"` 17 | Corpname string `json:"corpname"` 18 | TypeCorpname string `json:"type_corpname"` 19 | TypeUsername string `json:"type_username"` 20 | TemplateCode string `json:"template_code"` 21 | Depid int `json:"depid"` 22 | } 23 | 24 | // 用户序列化器 25 | type IsRegistered struct { 26 | //php代码和api中还有errcode参数 27 | ErrCode int `json:"errcode"` 28 | IsRegistered int `json:"is_registered"` 29 | } 30 | 31 | // 检查 32 | type CheckUser struct { 33 | ErrCode int `json:"errcode"` 34 | UserID string `json:"userid"` 35 | CorpID string `json:"corpid"` 36 | IsExist int `json:"is_exist"` 37 | } 38 | 39 | // 序列化 40 | func BuildUserCheck(errCode int, corpID string, userID string, x int) CheckUser { 41 | return CheckUser{ 42 | ErrCode: errCode, 43 | CorpID: corpID, 44 | UserID: userID, 45 | IsExist: x, 46 | } 47 | } 48 | 49 | // 序列化corp 50 | func BuildCorp(errCode int, corp model.Corp) Corp { 51 | return Corp{ 52 | ErrCode: errCode, 53 | Corpid: corp.Corpid, 54 | Corpname: corp.Corpname, 55 | TypeCorpname: corp.TypeCorpname, 56 | TypeUsername: corp.TypeUsername, 57 | TemplateCode: corp.TemplateCode, 58 | Depid: corp.Id, 59 | } 60 | } 61 | 62 | // 序列化status 63 | func BuildStatus(token string, uid int64, isRegistered int, errcode int) Status { 64 | return Status{ 65 | Token: token, 66 | UID: uid, 67 | IsRegistered: isRegistered, 68 | ErrCode: errcode, 69 | } 70 | } 71 | 72 | // 序列化status响应,返回token、uid等信息 73 | func BuildStatusResponse(token string, uid int64, isRegistered int, errcode int) Response { 74 | return Response{ 75 | Data: BuildStatus(token, uid, isRegistered, errcode), 76 | } 77 | } 78 | 79 | // 序列化corp响应 80 | func BuildCorpResponse(errCode int, corp model.Corp) Response { 81 | return Response{ 82 | Data: BuildCorp(errCode, corp), 83 | } 84 | } 85 | 86 | // 序列化IsRegistered响应 87 | func BuildIsRegistered(errcode int, is_registered int) IsRegistered { 88 | return IsRegistered{ 89 | ErrCode: errcode, 90 | IsRegistered: is_registered, 91 | } 92 | } 93 | 94 | // 序列化用户注册响应 95 | func BuildIsRegisteredResponse(errcode int, is_registered int) Response { 96 | return Response{ 97 | Data: BuildIsRegistered(errcode, is_registered), 98 | } 99 | } 100 | 101 | // 序列化验证用户是否响应 102 | func BuildUserCheckResponse(errCode int, corpID string, userID string, x int) Response { 103 | return Response{ 104 | Data: BuildUserCheck(errCode, corpID, userID, x), 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /serializer/user_info.go: -------------------------------------------------------------------------------- 1 | package serializer 2 | 3 | import "Miniprogram-server-Golang/model" 4 | 5 | // 用户数据序列化器 6 | type UserInfo struct { 7 | ErrCode int `json:"errcode"` 8 | Name string `json:"name"` 9 | PhoneNum string `json:"phone_num"` 10 | UserID string `json:"userid"` 11 | TemplateCode string `json:"bind_corp_template_code"` 12 | Corpname string `json:"corpname"` 13 | TypeCorpname string `json:"type_corpname"` 14 | TypeUsername string `json:"type_username"` 15 | } 16 | 17 | // 序列化 18 | func BuildUserInfo(user model.Student, corp model.Corp) UserInfo { 19 | return UserInfo{ 20 | ErrCode: 0, 21 | Name: user.Name, 22 | PhoneNum: user.PhoneNum, 23 | UserID: user.UserID, 24 | TemplateCode: corp.TemplateCode, 25 | Corpname: corp.Corpname, 26 | TypeCorpname: corp.TypeCorpname, 27 | TypeUsername: corp.TypeUsername, 28 | } 29 | } 30 | 31 | // 序列化用户信息响应 32 | func BuildUserInfoResponse(user model.Student, corp model.Corp) Response { 33 | return Response{ 34 | Data: BuildUserInfo(user, corp), 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/router.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "Miniprogram-server-Golang/api" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func NewRouter() *gin.Engine { 10 | //创建带有默认中间件的路由 11 | //日志与恢复中间件 12 | router := gin.Default() 13 | 14 | // 路由 用户登录信息接口 15 | v1 := router.Group("index/login") 16 | { 17 | //获取uid和token 18 | v1.POST("/getcode", api.UserLogin) 19 | 20 | //检查用户是否注册 21 | v1.POST("/check_is_registered", api.UserIsReg) 22 | 23 | //检查用户是否存在 24 | v1.POST("/check_user", api.CheckUser) 25 | 26 | //微信用户注册 27 | v1.POST("/register", api.WeixinUsrRegister) 28 | 29 | //获取公司模板 30 | v1.POST("/getcorpname", api.GetCorp) 31 | 32 | //用户解绑 33 | v1.POST("/unbind", api.UserUnBind) 34 | 35 | } 36 | 37 | // 路由,用户上传信息接口 38 | v2 := router.Group("index/report") 39 | { 40 | //保存每日上传信息 41 | v2.POST("/save", api.SaveInfo) 42 | 43 | //获取上次上传信息 44 | v2.POST("/getlastdata", api.GetInfo) 45 | } 46 | 47 | // 路由, 获取用户基本信息 48 | v3 := router.Group("/index/info") 49 | { 50 | //获取用户信息 51 | v3.POST("/getmyinfo", api.GetUserInfo) 52 | 53 | //检查用户绑定信息 54 | v3.POST("/getbindinfo", api.GetBindInfo) 55 | } 56 | 57 | router.GET("index/district/getall", api.GetAll) 58 | 59 | return router 60 | } 61 | -------------------------------------------------------------------------------- /service/check_is_registered.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理用户注册服务 11 | type CheckIsRegisteredService struct { 12 | Code string `form:"code" json:"code"` 13 | Corpid string `form:"corpid" json:"corpid" binding:"required"` 14 | UID int `form:"uid" json:"uid" binding:"required"` 15 | Token string `form:"token" json:"token" binding:"required"` 16 | } 17 | 18 | // 判断用户是否注册过 19 | func (service *CheckIsRegisteredService) IsRegistered(c *gin.Context) serializer.Response { 20 | 21 | if !model.CheckToken(service.UID, service.Token) { 22 | return serializer.ParamErr("token验证错误", nil) 23 | } 24 | 25 | //到organization表中查找是否有该企业 26 | var orgid string 27 | if err := model.DB.QueryRow("select id from organization where corp_code =?", service.Corpid).Scan(&orgid); err != nil || orgid == "" { 28 | return serializer.Err(10006, "获取企业信息失败", nil) 29 | } 30 | 31 | ////到wx_mp_bind_info表中查找是否有绑定信息 32 | var bindid string 33 | if err := model.DB.QueryRow("select id from wx_mp_bind_info where org_id =? and wx_uid =? and isbind =?", orgid, service.UID, 1).Scan(&bindid); err != nil || bindid == "" { 34 | return serializer.BuildIsRegisteredResponse(0, 0) 35 | } else { 36 | return serializer.BuildIsRegisteredResponse(0, 1) 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /service/check_user.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理用户注册服务 11 | type CheckUserService struct { 12 | UserID string `form:"userid" json:"userid"` 13 | CorpID string `form:"corpid" json:"corpid"` 14 | UID int `form:"uid" json:"uid"` 15 | Token string `form:"token" json:"token"` 16 | } 17 | 18 | // 用于检测用户标识是否已经被绑定 19 | func (service *CheckUserService) CheckUser(c *gin.Context) serializer.Response { 20 | if !model.CheckToken(service.UID, service.Token) { 21 | return serializer.ParamErr("token验证错误", nil) 22 | } 23 | 24 | var depId int 25 | // 根据企业的标识码CorpID找到该企业信息对应的id 26 | if err := model.DB.QueryRow("select id from organization where corp_code = ?", service.CorpID).Scan(&depId); err != nil || depId == 0 { 27 | return serializer.Err(10006, "获取企业信息失败", nil) 28 | } 29 | 30 | var wxUid int 31 | // 根据企业id和用户信息,查找二者的绑定情况 32 | err := model.DB.QueryRow("select wx_uid from wx_mp_bind_info where org_id = ? and username = ? and isbind = ?", depId, service.UserID, 1).Scan(&wxUid) 33 | 34 | if err == nil { 35 | if wxUid == service.UID { 36 | // 待增加bind接口后修改isExist字段值 37 | return serializer.BuildUserCheckResponse(0, service.CorpID, service.UserID, 0) 38 | } else { 39 | return serializer.Err(100020, "该用户已被其他微信绑定,每个用户只能被一个微信绑定", nil) 40 | } 41 | } 42 | return serializer.BuildUserCheckResponse(0, service.CorpID, service.UserID, 0) 43 | } 44 | -------------------------------------------------------------------------------- /service/get_bind_info.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理用户绑定信息服务 11 | type GetBindInfoService struct { 12 | UID int `form:"uid" json:"uid"` 13 | Token string `form:"token" json:"token"` 14 | } 15 | 16 | // 检查用户绑定信息 17 | func (service *GetBindInfoService) GetBindInfo(c *gin.Context) serializer.Response { 18 | if !model.CheckToken(service.UID, service.Token) { 19 | return serializer.ParamErr("token验证错误", nil) 20 | } 21 | 22 | var corpCode string 23 | if err := model.DB.QueryRow("select o.corp_code from wx_mp_bind_info as u left join organization as o on o.id = u.orgid where u.wx_uid = ? and u.isbind = ?", service.UID, 1).Scan(&corpCode); err != nil || corpCode == "" { 24 | return serializer.BuildBindInfoResponse(0, 0, "") 25 | } 26 | return serializer.BuildBindInfoResponse(0, 1, corpCode) 27 | } 28 | -------------------------------------------------------------------------------- /service/get_corpname_service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理用户企业身份服务 11 | type GetCorpService struct { 12 | Uid int `form:"uid" json:"uid"` 13 | Token string `form:"token" json:"token"` 14 | Corpid string `form:"corpid" json:"corpid"` 15 | } 16 | 17 | // 获取用户企业信息 18 | func (service *GetCorpService) GetCorp(c *gin.Context) serializer.Response { 19 | 20 | if !model.CheckToken(service.Uid, service.Token) { 21 | return serializer.ParamErr("token验证错误", nil) 22 | } 23 | 24 | var corp model.Corp 25 | err := model.DB.QueryRow("select id,corp_code,corpname,template_code,type_corpname,type_username from organization where corp_code =?", service.Corpid). 26 | Scan(&corp.Id, &corp.Corpid, &corp.Corpname, &corp.TemplateCode, &corp.TypeCorpname, &corp.TypeUsername) 27 | if err != nil { 28 | return serializer.Err(10006, "获取企业信息失败", nil) 29 | } 30 | 31 | return serializer.BuildCorpResponse(0, corp) 32 | } 33 | -------------------------------------------------------------------------------- /service/get_last_data.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | "log" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | // 管理获取表单数据服务 12 | type GetLastDataService struct { 13 | UID int `form:"uid" json:"uid"` 14 | Token string `form:"token" json:"token"` 15 | } 16 | 17 | // 获取上次提交的数据 18 | func (service *GetLastDataService) GetLastData(c *gin.Context) serializer.Response { 19 | 20 | if !model.CheckToken(service.UID, service.Token) { 21 | return serializer.ParamErr("token验证错误", nil) 22 | } 23 | 24 | //获取用户所属的机构 25 | var templateCode string 26 | err := model.DB.QueryRow(`select o.template_code 27 | from wx_mp_bind_info u 28 | left join organization o 29 | on u.org_id = o.id 30 | where u.wx_uid = ? and u.isbind = 1`, service.UID). 31 | Scan(&templateCode) 32 | if err != nil { 33 | return serializer.Err(10006, "获取用户绑定信息失败", nil) 34 | } 35 | 36 | // 获取表单信息 37 | var lastData model.Record 38 | queryStr := `select is_return_school,IFNULL(remarks,""),IFNULL(return_dorm_num,""),IFNULL(return_time,""),IFNULL(return_traffic_info,""), 39 | IFNULL(current_health_value,0),IFNULL(current_contagion_risk_value,0),IFNULL(return_district_value,0),IFNULL(current_district_value,0), 40 | IFNULL(current_temperature,0),IFNULL(psy_status,0),IFNULL(psy_demand,0),IFNULL(psy_knowledge,0),IFNULL(plan_company_date,"") 41 | from ` + "report_record_" + templateCode + " where wxuid = ? order by time desc limit 1" 42 | err = model.DB.QueryRow(queryStr, service.UID).Scan(&lastData.IsReturnSchool, &lastData.Remarks, &lastData.ReturnDormNum, 43 | &lastData.ReturnTime, &lastData.ReturnTrafficInfo, &lastData.CurrentHealthValue, &lastData.CurrentContagionRiskValue, 44 | &lastData.ReturnDistrictValue, &lastData.CurrentDistrictValue, &lastData.CurrentTemperature, &lastData.PsyStatus, 45 | &lastData.PsyDemand, &lastData.PsyKnowledge, &lastData.PlanCompanyDate) 46 | if err == nil { 47 | lastData.ReturnDistrictPath = service.getDistrictPath(lastData.ReturnDistrictValue) 48 | lastData.CurrentDistrictPath = service.getDistrictPath(lastData.CurrentDistrictValue) 49 | return serializer.BuildLastDataResponse(false, lastData) 50 | } 51 | // 出现错误时返回空值 52 | log.Println(err) 53 | return serializer.BuildLastDataResponse(true, lastData) 54 | } 55 | 56 | // getDistrictPath 获取行政区信息 57 | func (service *GetLastDataService) getDistrictPath(cityCode int) string { 58 | var dis model.District 59 | var pathStr string 60 | err := model.DB.QueryRow("select name,level_id,parent_id from com_district where value = ?", cityCode). 61 | Scan(&dis.Name, &dis.LevelID, &dis.ParentID) 62 | if err == nil { 63 | pathStr = dis.Name 64 | if dis.LevelID != 1 { 65 | err = model.DB.QueryRow("select name from com_district where value = ?", dis.ParentID). 66 | Scan(&dis.Name) 67 | if err == nil { 68 | pathStr = dis.Name + pathStr 69 | } 70 | } 71 | } 72 | return pathStr 73 | } 74 | -------------------------------------------------------------------------------- /service/get_user_info.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理获取用户数据服务 11 | type GetInfoService struct { 12 | UID int `form:"uid" json:"uid" binding:"required"` 13 | Token string `form:"token" json:"token" binding:"required"` 14 | Corpid string `form:"corpid" json:"corpid" binding:"required"` 15 | } 16 | 17 | // 获取用户数据 18 | func (service *GetInfoService) GetMyInfo(c *gin.Context) serializer.Response { 19 | if !model.CheckToken(service.UID, service.Token) { 20 | return serializer.ParamErr("token验证错误", nil) 21 | } 22 | 23 | // 获取传递参数的企业信息 24 | var corp model.Corp 25 | err := model.DB.QueryRow("select corpname,template_code,type_corpname,type_username from organization where corp_code = ?", service.Corpid). 26 | Scan(&corp.Corpname, &corp.TemplateCode, &corp.TypeCorpname, &corp.TypeUsername) 27 | if err != nil { 28 | return serializer.Err(10006, "获取企业信息失败", nil) 29 | } 30 | 31 | // 获取用户信息 32 | var user model.Student 33 | err = model.DB.QueryRow("select userid,name,phone_num from wx_mp_user where wid = ?", service.UID). 34 | Scan(&user.UserID, &user.Name, &user.PhoneNum) 35 | if err != nil { 36 | return serializer.Err(1005, "获取用户信息失败", nil) 37 | } 38 | 39 | return serializer.BuildUserInfoResponse(user, corp) 40 | } 41 | -------------------------------------------------------------------------------- /service/save_daily_info_service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | "database/sql" 7 | "github.com/gin-gonic/gin" 8 | "time" 9 | ) 10 | 11 | //SaveDailyInfoService 管理每日上传信息服务 12 | 13 | type data struct { 14 | IsReturnSchool string `form:"data.is_return_school" json:"is_return_school"` 15 | ReturnTime string `form:"data.return_time" json:"return_time"` 16 | ReturnDormNum string `form:"data.return_dorm_num" json:"return_dorm_num"` 17 | ReturnTrafficInfo string `form:"data.return_traffic_info" json:"return_traffic_info"` 18 | CurrentHealthValue string `form:"data.current_health_value" json:"current_health_value"` 19 | CurrentContagionRiskValue string `form:"data.current_contagion_risk_value" json:"current_contagion_risk_value"` 20 | //ReturnDistrictValue int `form:"data.current_contagion_risk_value" json:"return_district_value"` 21 | CurrentDistrictValue int `form:"data.current_district_value" json:"current_district_value"` 22 | CurrentTemperature string `form:"data.current_temperature" json:"current_temperature"` 23 | PsyStatus string `form:"data.psy_status" json:"psy_status"` 24 | PsyDemand string `form:"data.psy_demand" json:"psy_demand"` 25 | PsyKnowledge string `form:"data.psy_knowledge" json:"psy_knowledge"` 26 | Remarks string `form:"data.remarks" json:"remarks"` 27 | } 28 | 29 | type SaveDailyInfoService struct { 30 | Data data `form:"data" json:"data"` 31 | UID int `form:"uid" json:"uid"` 32 | Token string `form:"token" json:"token"` 33 | TemplateCode string `form:"template_code" json:"template_code"` 34 | } 35 | 36 | //判断字符串是否为空 用于解决输入数据为空 无法存储到数据库的问题 37 | func CheckValid(s string) bool { 38 | if s != "" { 39 | return true 40 | } 41 | return false 42 | } 43 | 44 | // isRegistered 判断用户是否存在 45 | func (service *SaveDailyInfoService) SaveDailyInfo(c *gin.Context) serializer.Response { 46 | if !model.CheckToken(service.UID, service.Token) { 47 | return serializer.ParamErr("token验证错误", nil) 48 | } 49 | //查找用户绑定信息 50 | var orgid, orgname, username, userid string 51 | err := model.DB.QueryRow("select org_id from wx_mp_bind_info where wx_uid =? ", service.UID).Scan(&orgid) 52 | err = model.DB.QueryRow("select corpname from organization where id=?", orgid).Scan(&orgname) 53 | err = model.DB.QueryRow("select name,userid from wx_mp_user where wid =? ", service.UID).Scan(&username, &userid) 54 | //count 用于判断是否重复提交 55 | count := 0 56 | var time = time.Now().Format("2006-01-02") 57 | if service.TemplateCode == "default" { 58 | //学生 59 | //判断是否重复提交 60 | err = model.DB.QueryRow("select count(*) from report_record_default where userID =? and time = ?", userid, time).Scan(&count) 61 | if count > 0 && err == nil { 62 | return serializer.ParamErr("今日您已提交,请勿重复提交", nil) 63 | } 64 | 65 | //保存信息 66 | queryStr := "insert into report_record_default(is_return_school,current_health_value,current_contagion_risk_value," + 67 | "current_district_value,current_temperature,remarks,psy_status,psy_demand,psy_knowledge,return_time," + 68 | "wxuid,time,org_id,org_name,name,userID,template_code,return_dorm_num,return_traffic_info)" + 69 | "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" 70 | if _, err := model.DB.Exec(queryStr, service.Data.IsReturnSchool, service.Data.CurrentHealthValue, service.Data.CurrentContagionRiskValue, 71 | service.Data.CurrentDistrictValue, service.Data.CurrentTemperature, service.Data.Remarks, 72 | service.Data.PsyStatus, service.Data.PsyDemand, service.Data.PsyKnowledge, 73 | sql.NullString{String: service.Data.ReturnTime, Valid: CheckValid(service.Data.ReturnTime)}, 74 | service.UID, time, orgid, orgname, username, userid, service.TemplateCode, service.Data.ReturnDormNum, 75 | service.Data.ReturnTrafficInfo); err != nil { 76 | return serializer.ParamErr("上传失败", nil) 77 | } 78 | //企业员工 79 | } else { 80 | //判断是否重复提交 81 | err = model.DB.QueryRow("select count(*) from report_record_company where userID =? and time = ?", userid, time).Scan(&count) 82 | if count > 0 && err == nil { 83 | return serializer.ParamErr("今日您已提交,请勿重复提交", nil) 84 | } 85 | //保存信息 86 | queryStr := "insert into report_record_company(is_return_school,current_health_value,current_contagion_risk_value," + 87 | "current_district_value,current_temperature,remarks,psy_status,psy_demand,psy_knowledge,return_time," + 88 | "wxuid,time,org_id,org_name,name,userID,template_code,return_dorm_num,return_traffic_info)" + 89 | "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" 90 | if _, err := model.DB.Exec(queryStr, service.Data.IsReturnSchool, service.Data.CurrentHealthValue, service.Data.CurrentContagionRiskValue, 91 | service.Data.CurrentDistrictValue, service.Data.CurrentTemperature, service.Data.Remarks, 92 | service.Data.PsyStatus, service.Data.PsyDemand, service.Data.PsyKnowledge, 93 | sql.NullString{String: service.Data.ReturnTime, Valid: CheckValid(service.Data.ReturnTime)}, 94 | service.UID, time, orgid, orgname, username, userid, service.TemplateCode, service.Data.ReturnDormNum, 95 | service.Data.ReturnTrafficInfo); err != nil { 96 | return serializer.ParamErr("上传失败", nil) 97 | } 98 | } 99 | return serializer.BuildSuccessSave() 100 | } 101 | -------------------------------------------------------------------------------- /service/user_bind_service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | "database/sql" 7 | "github.com/gin-gonic/gin" 8 | "time" 9 | ) 10 | 11 | // 管理用户注册服务 12 | type UserBindService struct { 13 | UserID string `form:"userid" json:"userid"` 14 | Corpid string `form:"corpid" json:"corpid"` 15 | UID int `form:"uid" json:"uid"` 16 | Token string `form:"token" json:"token"` 17 | Password string `form:"password" json:"password"` 18 | } 19 | 20 | // 用户绑定 21 | func (service *UserBindService) UnBind(c *gin.Context) serializer.Response { 22 | if !model.CheckToken(service.UID, service.Token) { 23 | // Token 验证失败 此处 is_registered 无意义 24 | return serializer.BuildIsRegisteredResponse(serializer.CodeParamErr, 0) 25 | } 26 | // 再搜索数据库,修改注册状态 27 | var isRegistered int 28 | err := model.DB.QueryRow("SELECT isbind FROM wx_mp_bind_info WHERE wx_uid = ?", service.UID).Scan(&isRegistered) 29 | if err != nil { 30 | // 无该用户 根据 PHP 代码此处返回 errcode: 0 is_registered: 0 31 | if err == sql.ErrNoRows { 32 | return serializer.BuildIsRegisteredResponse(0, 0) 33 | } else { 34 | // 此处为其它数据库错误 小程序并未做针对处理 此处 is_registered 无意义 35 | return serializer.BuildIsRegisteredResponse(serializer.CodeDBError, 0) 36 | } 37 | } 38 | rows, err := model.DB.Exec("UPDATE wx_mp_bind_info SET isbind = ? , unbind_date = ? WHERE wx_uid = ?;", "0", time.Now(), service.UID) 39 | _ = rows 40 | if err != nil { 41 | // 此处为其它数据库错误 小程序并未做针对处理 此处 is_registered 无意义 42 | return serializer.BuildIsRegisteredResponse(serializer.CodeDBError, 0) 43 | } 44 | return serializer.BuildIsRegisteredResponse(0, 0) 45 | } 46 | -------------------------------------------------------------------------------- /service/user_openid_service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | "github.com/gin-gonic/gin" 7 | "github.com/medivhzhan/weapp/v2" 8 | "os" 9 | "time" 10 | ) 11 | 12 | // UserOpenIDService 获取用户token服务 13 | type UserOpenIDService struct { 14 | Code string `form:"code" json:"code"` 15 | } 16 | 17 | // GetCode 用户登录函数,获取openidhesessionkey,作为之后操作的验证 18 | func (service *UserOpenIDService) GetCode(c *gin.Context) serializer.Response { 19 | res, err := weapp.Login(os.Getenv("APP_ID"), os.Getenv("APP_SECRET"), service.Code) 20 | 21 | if err != nil { 22 | //处理错误 23 | return serializer.ParamErr("获取openid失败", err) 24 | } 25 | 26 | if err := res.GetResponseError(); err != nil { 27 | //处理小程序传送的错误信息 28 | return serializer.ParamErr("小程序报错", err) 29 | } 30 | 31 | //查看数据库中是否已有token信息 32 | var wid int64 33 | var token string 34 | //err = model.DB2.QueryRow("select wid from wx_mp_user where wid = ?", UID).Scan(&wid) 35 | err = model.DB.QueryRow("select wid, token from wx_mp_user where openid = ?", res.OpenID). 36 | Scan(&wid, &token) 37 | 38 | if err != nil { 39 | //如果没有,重新存入并返回 40 | result, err2 := model.DB.Exec("insert into wx_mp_user(openid, token, time_out) values(?,?,?)", res.OpenID, res.SessionKey, time.Now()) 41 | var err3 error 42 | wid, err3 = result.LastInsertId() 43 | if err2 != nil || err3 != nil{ 44 | return serializer.Err(1008, "获取请求失败,请退出重试", nil) 45 | } 46 | } 47 | return serializer.BuildStatusResponse(token, wid, 1, 0) 48 | } -------------------------------------------------------------------------------- /service/wexin_user_register.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "Miniprogram-server-Golang/model" 5 | "Miniprogram-server-Golang/serializer" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | // 管理用户注册服务 11 | type WeixinUserRegister struct { 12 | UserID string `form:"userid" json:"userid" binding:"required"` 13 | Corpid string `form:"corpid" json:"corpid" binding:"required"` 14 | UID int `form:"uid" json:"uid" binding:"required"` 15 | Token string `form:"token" json:"token" binding:"required"` 16 | Name string `form:"name" json:"name" binding:"required"` 17 | PhoneNum string `form:"phone_num" json:"phone_num" binding:"required"` 18 | } 19 | 20 | // 判断用户是否注册过 21 | func (service *WeixinUserRegister) UserRegister(c *gin.Context) serializer.Response { 22 | 23 | if !model.CheckToken(service.UID, service.Token) { 24 | return serializer.ParamErr("token验证错误", nil) 25 | } 26 | 27 | //到organization表中查找是否有该企业 28 | var orgid string 29 | if err := model.DB.QueryRow("select id from organization where corp_code =?", service.Corpid).Scan(&orgid); err != nil || orgid == "" { 30 | return serializer.Err(10006, "获取企业信息失败", nil) 31 | } 32 | 33 | //到wx_mp_bind_info表中查找是否有绑定信息 34 | res, _ := model.DB.Query("select wx_uid from wx_mp_bind_info where wx_uid = ? and org_id = ? and username = ? and isbind = 1", service.UID, orgid, service.Name) 35 | 36 | if res.Next() { 37 | return serializer.BuildIsRegisteredResponse(0, 1) 38 | } else { 39 | res, _ := model.DB.Query("select org_id from wx_mp_bind_info where wx_uid = ? and username = ? and isbind = 1", service.UID, service.Name) 40 | if res.Next() { 41 | return serializer.Err(100020, "本微信已经绑定其他机构,不能重复绑定", nil) 42 | } 43 | result := model.DB.QueryRow("insert into wx_mp_bind_info(wx_uid,org_id,username,isbind) values(?,?,?,1)", service.UID, orgid, service.Name) 44 | if result == nil { 45 | return serializer.Err(50001, "注册失败", nil) 46 | } 47 | result = model.DB.QueryRow("update wx_mp_user set userid=?, name=?, phone_num=? where wid=?", service.UserID, service.Name, service.PhoneNum, service.UID) 48 | if result == nil { 49 | return serializer.Err(50001, "用户更新失败", nil) 50 | } 51 | } 52 | return serializer.BuildIsRegisteredResponse(0, 1) 53 | } 54 | --------------------------------------------------------------------------------