You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

376 lines
16 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <div align=center>
  2. <img src="http://qmplusimg.henrongyi.top/gvalogo.jpg" width=300" height="300" />
  3. </div>
  4. <div align=center>
  5. <img src="https://img.shields.io/badge/golang-1.12-blue"/>
  6. <img src="https://img.shields.io/badge/gin-1.4.0-lightBlue"/>
  7. <img src="https://img.shields.io/badge/vue-2.6.10-brightgreen"/>
  8. <img src="https://img.shields.io/badge/element--ui-2.12.0-green"/>
  9. <img src="https://img.shields.io/badge/gorm-1.9.12-red"/>
  10. </div>
  11. English | [简体中文](./README.md)
  12. # Project Guidelines
  13. [Online Documentation](https://www.gin-vue-admin.com/) : https://www.gin-vue-admin.com/
  14. [Development Steps](https://www.gin-vue-admin.com/docs/help) (Contributor: <a href="https://github.com/LLemonGreen">LLemonGreen</a> And <a href="https://github.com/fkk0509">Fann</a>)
  15. - Web UI Framework:[element-ui](https://github.com/ElemeFE/element)
  16. - Server Framework:[gin](https://github.com/gin-gonic/gin)
  17. ## 1. Basic Introduction
  18. ### 1.1 Project Introduction
  19. [Online Demo](http://demo.gin-vue-admin.com/)
  20. username:admin
  21. password:123456
  22. > Gin-vue-admin is a full-stack (frontend and backend separation) framework designed for management system.
  23. > It integrates multiple functions, such as JWT authentication, dynamic routing, dynamic menu, casbin authentication, form generator, code generator, etc. So that you can focus more time on your business Requirements.
  24. Hi! Thank you for choosing gin-vue-admin.
  25. Gin-vue-admin is a full-stack (frontend and backend separation) framework for developers, designers and product managers.
  26. We are excited that you are interested in contributing to gin-vue-admin. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.
  27. ### 1.2 Contributing Guide
  28. #### 1.2.1 Issue Guidelines
  29. - Issues are exclusively for bug reports, feature requests and design-related topics. Other questions may be closed directly. If any questions come up when you are using Element, please hit [Gitter](https://gitter.im/element-en/Lobby) for help.
  30. - Before submitting an issue, please check if similar problems have already been issued.
  31. #### 1.2.2 Pull Request Guidelines
  32. - Fork this repository to your own account. Do not create branches here.
  33. - Commit info should be formatted as `[File Name]: Info about commit.` (e.g. `README.md: Fix xxx bug`)
  34. - <font color=red>Make sure PRs are created to `develop` branch instead of `master` branch.</font>
  35. - If your PR fixes a bug, please provide a description about the related bug.
  36. - Merging a PR takes two maintainers: one approves the changes after reviewing, and then the other reviews and merges.
  37. ### 1.3 Version list
  38. - master: 2.0 code, for prod
  39. - develop: 2.0 dev code, for test
  40. - [gin-vue-admin_v2_dev](https://github.com/flipped-aurora/gin-vue-admin/tree/gin-vue-admin_v2_dev) (v2.0 [GormV1](https://v1.gorm.io) Stable branch)
  41. - [gva_gormv2_dev](https://github.com/flipped-aurora/gin-vue-admin/tree/gva_gormv2_dev) (v2.0 [GormV2](https://v2.gorm.io) Development branch)
  42. ## 2. Getting started
  43. ```
  44. - node version > v8.6.0
  45. - golang version >= v1.14
  46. - IDE recommendation: Goland
  47. - We recommend you to apply for your own cloud service in QINIU. Replace the public key, private key, warehouse name and default url address with your own, so as not to mess up the test database.
  48. ```
  49. > Use docker-compose to experience this project
  50. - Installation docker-compose [Official document](https://docs.docker.com/compose/install/)
  51. - ```shell script
  52. # Install on Linux
  53. # 1.1 Run this command to download the current stable version of Docker Compose
  54. sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  55. # 1.2 Apply executable permissions to binary files
  56. sudo chmod +x /usr/local/bin/docker-compose
  57. ```
  58. - ```shell script
  59. # Use Python's pip installation
  60. pip3 install docker-compose -i https://pypi.tuna.tsinghua.edu.cn/simple
  61. ```
  62. - Use Docker Desktop
  63. - Windows: https://hub.docker.com/editions/community/docker-ce-desktop-windows
  64. - Mac: https://hub.docker.com/editions/community/docker-ce-desktop-mac/
  65. - Use git to clone this project
  66. - ```git
  67. git clone https://github.com/flipped-aurora/gin-vue-admin.git
  68. ```
  69. - Use docker-compose up to start the startup project with one click
  70. - ```shell script
  71. # Use docker-compose to start four containers
  72. docker-compose up
  73. # If you modify some configuration options, you can use this command to repackage the image
  74. docker-compose up --build
  75. # Use docker-compose to start in the background
  76. docker-compose up -d
  77. ```
  78. - Web project preview [http://127.0.0.1:8000](http://127.0.0.1:8000)
  79. - swagger APIs [http://127.0.0.1:8888/swagger/index.html](http://127.0.0.1:8888/swagger/index.html)
  80. - If the internal ip of the server's 177.7.0.12 container is occupied, the place to be modified is
  81. - Replace 177.7.0.12 on line 39 of [docker-compose.yaml](./docker-compose.yaml) with the ip you want
  82. - Replace 177.7.0.12 in line 20 of [.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf) with the ip you want
  83. - docker-compose uses a custom docker network
  84. - ```dockerfile
  85. networks:
  86. network:
  87. ipam:
  88. driver: default
  89. config:
  90. - subnet: '177.7.0.0/16'
  91. ```
  92. - Subnet address, the default gateway is 177.7.0.1 (docker-compose V2 needs to write, V3 does not need),For specific information, see the [official document](https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address)
  93. - The default network name is gin-vue-admin_network, and the default is bridge mode
  94. - If the subnet is modified, the ipv4_address of each service needs to be modified, and the ip of the server on line 20 of [.docker-compose/nginx/conf.d/my.conf](.docker-compose/nginx/conf.d/my.conf) also needs to be modified
  95. > <font color=red>**Use docker-compose to deploy this project need attention**</font>
  96. - For mysql database, please use a local database installed on the server disk.
  97. - Avoid using mysql in the docker container, there may be write problems, io is lower than the host machine, docker's persistence mechanism problem
  98. - [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) is for docker-compose ==experience this project==, prohibit the use of [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize project data, Database initialization[Please use this method](https://www.gin-vue-admin.com/docs/help#step1%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E5%88%9D%E5%A7%8B%E5%8C%96)
  99. - Use [init.sql](.docker-compose/docker-entrypoint-initdb.d/init.sql) to initialize all problems, please bear it yourself, and have nothing to do with this project
  100. - When deploying using docker-compose of this project,Please modify the [nginx configuration](.docker-compose/nginx/conf.d/my.conf), mysql configuration, networks configuration, redis configuration corresponding to [docker-compose.yaml](./docker-compose.yaml), and make changes as needed.
  101. ### 2.1 Web
  102. ```bash
  103. # clone the project
  104. git clone https://github.com/piexlmax/gin-vue-admin.git
  105. # enter the project directory
  106. cd web
  107. # install dependency
  108. npm install
  109. # develop
  110. npm run serve
  111. ```
  112. ### 2.2 Server
  113. ```bash
  114. # using go.mod
  115. # install go modules
  116. go list (go mod tidy)
  117. # build the server
  118. go build
  119. ```
  120. > Zap log library usage guide && configuration guide
  121. The configuration of the Zap log library selects zap under [config.yaml](./server/config.yaml)
  122. ```yaml
  123. # zap logger configuration
  124. zap:
  125. level: 'debug'
  126. format: 'console'
  127. prefix: '[GIN-VUE-ADMIN]'
  128. director: 'log'
  129. link_name: 'latest_log'
  130. show_line: true
  131. encode_level: 'LowercaseColorLevelEncoder'
  132. stacktrace_key: 'stacktrace'
  133. log_in_console: true
  134. ```
  135. | Configuration Name | Type Of Configuration | Description |
  136. | ------------------ | --------------------- | ------------------------------------------------------------ |
  137. | level | string | For a detailed description of the level mode, please see the official [zap documentation](https://pkg.go.dev/go.uber.org/zap?tab=doc#pkg-constants) <br />info: info mode, stack information without errors, only output information<br />debug: debug mode, stack details with errors<br />warn:warn mode<br />error: error mode, stack details with error<br />dpanic: dpanic mode<br />panic: panic mode<br />fatal: fatal mode<br /> |
  138. | format | string | console: Output log in console format<br />json: json format output log |
  139. | prefix | string | Log prefix |
  140. | director | string | The folder to store the log can be modified, no need to create it manually |
  141. | link_name | string | [A soft connection file](https://baike.baidu.com/item/%E8%BD%AF%E9%93%BE%E6%8E%A5) of link_name will be generated in the server directory, and the link is the latest log file of the director configuration item |
  142. | show_line | bool | Display the line number, the default is true, it is not recommended to modify |
  143. | encode_level | string | LowercaseLevelEncoder: lowercase<br /> LowercaseColorLevelEncoder: lowercase with color<br />CapitalLevelEncoder: uppercase<br />CapitalColorLevelEncoder: uppercase with color |
  144. | stacktrace_key | string | The name of the stack, that is, the key of josn when outputting the log in json format |
  145. | log_in_console | bool | Whether to output to the console, the default is true |
  146. - Development environment || Debug environment configuration recommendations
  147. - `level:debug`
  148. - `format:console`
  149. - `encode_level:LowercaseColorLevelEncoder`或者`encode_leve:CapitalColorLevelEncoder`
  150. - Deployment environment configuration recommendations
  151. - `level:error`
  152. - `format:json`
  153. - `encode_level: LowercaseLevelEncoder `或者 `encode_level:CapitalLevelEncoder`
  154. - `log_in_console: false`
  155. - <font color=red>Suggestions are only suggestions, you can proceed according to your own needs, and suggestions are for reference only</font>
  156. ### 2.3 API docs auto-generation using swagger
  157. #### 2.3.1 install swagger
  158. ##### (1) Using VPN or outside mainland China
  159. ````
  160. go get -u github.com/swaggo/swag/cmd/swag
  161. ````
  162. ##### (2) In mainland China
  163. In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/)
  164. ````bash
  165. If you are using Go version 1.13 and above (recommended)
  166. # Enable Go Modules function
  167. go env -w GO111MODULE=on
  168. # Configure GOPROXY environment variables
  169. go env -w GOPROXY=https://goproxy.io,direct
  170. If you are using Go version 1.12 and below
  171. go env -w GO111MODULE=on
  172. go env -w GOPROXY=https://goproxy.io
  173. # Use the following command to download swag
  174. go get -u github.com/swaggo/swag/cmd/swag
  175. ````
  176. #### 2.3.2 API docs generation
  177. ````
  178. cd server
  179. swag init
  180. ````
  181. After executing the above command,`docs` will show in `server/`,then open your browser, jump into `http://localhost:8888/swagger/index.html` to see the swagger APIs.
  182. ## 3. Technical selection
  183. - Frontend: using `Element-UI` based on vue,to code the page.
  184. - Backend: using `Gin` to quickly build basic RESTful API. `Gin` is a web framework written in Go (Golang).
  185. - DB: `MySql`(5.6.44),using `gorm` to implement data manipulation, added support for SQLite databases.
  186. - Cache: using `Redis` to implement the recording of the JWT token of the currently active user and implement the multi-login restriction.
  187. - API: using Swagger to auto generate APIs docs。
  188. - Config: using `fsnotify` and `viper` to implement `yaml` config file。
  189. - Log: using `go-logging` record logs。
  190. ## 4. Project Architecture
  191. ### 4.1 Architecture Diagram
  192. ![Architecture diagram](http://qmplusimg.henrongyi.top/gva/gin-vue-admin.png)
  193. ### 4.2 Front-end Detailed Design Diagram (Contributor: <a href="https://github.com/baobeisuper">baobeisuper</a>)
  194. ![Front-end Detailed Design Diagram](http://qmplusimg.henrongyi.top/naotu.png)
  195. ### 4.3 Project Layout
  196. ```
  197. ├─server (backend)
  198. │ ├─api (API entrance)
  199. │ ├─config (config file)
  200. │ ├─core (core code)
  201. │ ├─docs (swagger APIs docs)
  202. │ ├─global (global objet)
  203. │ ├─initialiaze (initialiazation)
  204. │ ├─middleware (middle ware)
  205. │ ├─model (model and services)
  206. │ ├─resource (resources, such as static pages, templates)
  207. │ ├─router (routers)
  208. │ ├─service (services)
  209. │ └─utils (common utilities)
  210. └─web (frontend)
  211. ├─public (deploy templates)
  212. └─src (source code)
  213. ├─api (frontend APIs)
  214. ├─assets (static files)
  215. ├─components(components)
  216. ├─router (frontend routers)
  217. ├─store (vuex state management)
  218. ├─style (common styles)
  219. ├─utils (frontend common utilitie)
  220. └─view (pages)
  221. ```
  222. ## 5. Features
  223. - Authority management: Authority management based on `jwt` and `casbin`.
  224. - File upload & download: File upload operation based on Qiniu Cloud (In order to make it easier for everyone to test, I have provided various important tokens of my Qiniu test number, and I urge you not to make things a mess).
  225. - Pagination Encapsulation:The frontend uses mixins to encapsulate paging, and the paging method can call mixins
  226. - User management: The system administrator assigns user roles and role permissions.
  227. - Role management: Create the main object of permission control, and then assign different API permissions and menu permissions to the role.
  228. - Menu management: User dynamic menu configuration implementation, assigning different menus to different roles.
  229. - API management: Different users can call different API permissions.
  230. - Configuration management: The configuration file can be modified in the web page (the test environment does not provide this function).
  231. - Rich text editor: Embed MarkDown editor function.
  232. - Conditional search: Add an example of conditional search.
  233. - Restful example: You can see sample APIs in user management module.
  234. ```
  235. fontend code file: src\view\superAdmin\api\api.vue
  236. backend code file: model\dnModel\api.go
  237. ```
  238. - Multi-login restriction: Change `userMultipoint` to true in `system` in `config.yaml` (You need to configure redis and redis parameters yourself. During the test period, please report in time if there is a bug).
  239. - Upload file by chunk:Provides examples of file upload and large file upload by chunk.
  240. - Form Builder:With the help of [@form-generator](https://github.com/JakHuang/form-generator).
  241. - Code generator: Providing backend with basic logic and simple curd code generator.
  242. ## 6. To-do list
  243. - [ ] upload & export Excel
  244. - [ ] e-chart
  245. - [ ] workflow, task transfer function
  246. - [ ] frontend independent mode, mock
  247. ## 7. Knowledge base
  248. ### 7.1 Team blog
  249. > https://www.yuque.com/flipped-aurora
  250. >
  251. >There are video courses about frontend framework in our blo. If you think the project is helpful to you, you can add my personal WeChat:shouzi_1994,your comments is welcomed。
  252. ### 7.2 Video courses
  253. (1) Development environment course
  254. > Bilibili:https://www.bilibili.com/video/BV1Fg4y187Bw/
  255. (2) Template course
  256. > Bilibili:https://www.bilibili.com/video/BV16K4y1r7BD/
  257. (3)2.0 version introduction and development experience
  258. > Bilibili:https://www.bilibili.com/video/BV1aV411d7Gm#reply2831798461
  259. (4) Golang basic course (coming soon)
  260. > https://space.bilibili.com/322210472/channel/detail?cid=108884
  261. ## 8. Contacts
  262. ### 8.1 Groups
  263. #### QQ group: 622360840
  264. | QQ group |d
  265. | :---: |
  266. | <img src="http://qmplusimg.henrongyi.top/qq.jpg" width="180"/> |
  267. #### Wechat group: comment "加入gin-vue-admin交流群"
  268. | Wechat |
  269. | :---: |
  270. | <img width="150" src="http://qmplusimg.henrongyi.top/qrjjz.png">
  271. #### [About Us](https://www.gin-vue-admin.com/about/)
  272. ## 9. Donate
  273. If you find this project useful, you can buy author a glass of juice :tropical_drink: [here](https://www.gin-vue-admin.com/docs/coffee)
  274. ## 10. Commercial considerations
  275. If you use this project for commercial purposes, please comply with the Apache2.0 agreement and retain the author's technical support statement.