更新文档

This commit is contained in:
zhangwenjian committed 2020-03-17 14:46:27 +08:00
1 parent 7a804676aa
commit 7a43a01964
7 files changed
+402 -103

No files matched your search

+83 -81
View File
@@ -4,137 +4,138 @@
<img src="https://img.shields.io/github/license/mashape/apistatus.svg" alt="license"> <img src="https://img.shields.io/github/license/mashape/apistatus.svg" alt="license">
</a> </a>
English | [简体中文](./README.zh-CN.md)
##### Gin + Vue + Element UI based front-end and back-end separated permission management system
##### 基于Gin + Vue + Element UI的前后端分离权限管理系统 ## ✨ Feature
- Follow RESTful API design specifications
- Provides rich middleware support based on GIN WEB API framework (user authentication, cross domain, access log, tracking ID, etc.)
- Casbin-based RBAC access control model
- JWT certification
- Support Swagger documentation (based on swaggo)
- GORM-based database storage that can expand many types of databases
- Simple model mapping of configuration files to quickly get the desired configuration
- TODO: unit test
## ✨ 特性 ## 🎁 Built-in functions
- 遵循 RESTful API 设计规范 1. User management: The user is the system operator. This function mainly completes the system user configuration.
2. Department management: configure the system organization (company, department, group), and display the tree structure to support data permissions.
3. Post management: Configure system users to hold positions.
4. Menu management: configure system menus, operation permissions, button permission labels, etc.
5. Role management: role menu permissions assignment, setting roles to divide data range permissions by organization.
6. Dictionary management: to maintain some fixed data often used in the system.
7. Parameter management: Dynamically configure common parameters for the system.
8. Operation log: system normal operation log record and query; system exception information log record and query.
9. Login log: The system login log record query contains login exceptions.
10. System interface: Automatically generate related api interface documents according to business code.
- 基于 GIN WEB API 框架,提供了丰富的中间件支持(用户认证、跨域、访问日志、追踪ID等) ## Configuration details
- 基于Casbin的 RBAC 访问控制模型 1. Configuration file description
- JWT 认证
- 支持 Swagger 文档(基于swaggo)
- 基于 GORM 的数据库存储,可扩展多种类型数据库
- 配置文件简单的模型映射,快速能够得到想要的配置
- TODO: 单元测试
## 🎁 内置
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
3. 岗位管理:配置系统用户所属担任职务。
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
7. 参数管理:对系统动态配置常用参数。
8. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
9. 登录日志:系统登录日志记录查询包含登录异常。
10. 系统接口:根据业务代码自动生成相关的api接口文档。
## 配置详情
1. 配置文件说明
```yml ```yml
settings: settings:
application: application:
# 项目启动环境 # Project launch environment
env: dev env: dev
# 当 env:demo 时,GET以外的请求操作提示 # When env: demo, prompts for request operations other than GET
envmsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!" envmsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!"
# 主机ip 或者域名,默认0.0.0.0 # Host IP or domain name, default 0.0.0.0
host: 0.0.0.0 host: 0.0.0.0
# 是否需要初始化数据库结构以及基本数据;true:需要;false:不需要 # Whether to initialize the database structure and basic data; true: required; false: not required
isinit: false isinit: false
# JWT加密字符串 # JWT encrypted string
jwtsecret: 123abc jwtsecret: 123abc
# log存放路径 # log storage path
logpath: temp/logs/log.log logpath: temp/logs/log.log
# 服务名称 # application name
name: go-admin name: go-admin
# 服务端口 # application port
port: 8000 port: 8000
readtimeout: 1 readtimeout: 1
writertimeout: 2 writertimeout: 2
database: database:
# 数据库名称 # database name
database: dbname database: dbname
# 数据库类型 # database type
dbtype: mysql dbtype: mysql
# 数据库地址 # database host
host: 127.0.0.1 host: 127.0.0.1
# 数据库密码 # database password
password: password password: password
# 数据库端口 # database port
port: 3306 port: 3306
# 数据库用户名 # database username
username: root username: root
redis: redis:
# redis链接地址 # redis addresss
addr: 0.0.0.0:6379 addr: 0.0.0.0:6379
# db # db
db: 0 db: 0
# 密码 # password
password: password password: password
# 读超时时长 # read timeout
readtimeout: 50 readtimeout: 50
``` ```
2. 文件路径 go-admin/src/goadmin/config/settings.yml 2. file path go-admin/src/goadmin/config/settings.yml
## 📦 本地开发 ## 📦 evelopment
首次启动说明
First start instructions
```bash ```bash
# 获取代码 # Get the code
git clone https://github.com/wenjianzhang/go-admin.git git clone https://github.com/wenjianzhang/go-admin.git
# 进入工作路径 # Enter working path
cd ./goadmin/src/goadmin cd ./goadmin/src/goadmin
# 编译项目 # Build the project
go build go build
# 修改配置 # Change setting
vi ./config/setting.yml (更改isinit和数据库连接) vi ./config/setting.yml (Note: Change isinit and database connection)
# 1. 配置文件中修改数据库信息 # 1. Database information in the configuration file
# 注意: settings.database 下对应的配置数据) # Note: the corresponding configuration data under settings.database
# 2. 确认数据库初始化参数 # 2. Confirm database initialization parameters
# 注意: settings.application.isinit 如果是首次启动,请把当前值设置成true,系统会自动初始化数据库结构以及基本的数据信息; # Note: If this is the first time settings.application.isinit is set, please set the current value to true, the system will automatically initialize the database structure and basic data information;
# 3. 确认log路径 # 3. Confirm the log path
# 启动项目,也可以用IDE进行调试 # Start the project or debug with the IDE
./goadmin ./goadmin
# 也可以在WIKI中查看说明 # See also instructions in WIKI
``` ```
Document generation
文档生成
```bash ```bash
swag init swag init
``` ```
如果没有swag命令 go get安装一下即可 If there is no `swag` command go get installed
```bash ```bash
go get -u github.com/swaggo/swag/cmd/swag go get -u github.com/swaggo/swag/cmd/swag
``` ```
交叉编译
Cross compilation
```bash ```bash
env GOOS=windows GOARCH=amd64 go build main.go env GOOS=windows GOARCH=amd64 go build main.go
@@ -144,13 +145,13 @@ env GOOS=linux GOARCH=amd64 go build main.go
``` ```
## 🔗 在线体验 ## 🔗 Online Demo
> admin / 123456 > admin / 123456
演示地址:[http://www.zhangwj.com](http://www.zhangwj.com/#/login) Demo address:[http://www.zhangwj.com](http://www.zhangwj.com/#/login)
## 🤝 使用的开源项目 ## 🤝 Open source projects used
[gin](https://github.com/gin-gonic/gin) [gin](https://github.com/gin-gonic/gin)
[casbin](https://github.com/casbin/casbin) [casbin](https://github.com/casbin/casbin)
@@ -168,19 +169,20 @@ env GOOS=linux GOARCH=amd64 go build main.go
[ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue) [ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue)
## 版本
#### 2020-03-15 新功能及优化 ## Version
1. 添加用户头像上传 #### 2020-03-15 New Features and Optimization
2. 添加用户密码修改
3. 操作日志页面调整
4. 优化验证码背景色
看到好多体验的朋友验证码错误,所以调整了对比度,方便大家体验! 1. Add user avatar upload
2. Add user password modification
3. Operation log page adjustment
4. Optimize captcha background color
I saw a lot of friends who experience the wrong verification code, so I adjusted the contrast for everyone to experience!
## 🤝 特别感谢 ## 🤝 Thanks
[chengxiao](https://github.com/chengxiao) [chengxiao](https://github.com/chengxiao)
@@ -190,4 +192,4 @@ env GOOS=linux GOARCH=amd64 go build main.go
Copyright (c) 2020 wenjianzhang Copyright (c) 2020 wenjianzhang
添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢! [中文]qq technical exchange group: 74520518
+193
View File
@@ -0,0 +1,193 @@
# go-admin
<a href="https://github.com/wenjianzhang/go-admin/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/mashape/apistatus.svg" alt="license">
</a>
[English](./README.md) | 简体中文
##### 基于Gin + Vue + Element UI的前后端分离权限管理系统
## ✨ 特性
- 遵循 RESTful API 设计规范
- 基于 GIN WEB API 框架,提供了丰富的中间件支持(用户认证、跨域、访问日志、追踪ID等)
- 基于Casbin的 RBAC 访问控制模型
- JWT 认证
- 支持 Swagger 文档(基于swaggo)
- 基于 GORM 的数据库存储,可扩展多种类型数据库
- 配置文件简单的模型映射,快速能够得到想要的配置
- TODO: 单元测试
## 🎁 内置
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
3. 岗位管理:配置系统用户所属担任职务。
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
7. 参数管理:对系统动态配置常用参数。
8. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
9. 登录日志:系统登录日志记录查询包含登录异常。
10. 系统接口:根据业务代码自动生成相关的api接口文档。
## 配置详情
1. 配置文件说明
```yml
settings:
application:
# 项目启动环境
env: dev
# 当 env:demo 时,GET以外的请求操作提示
envmsg: "谢谢您的参与,但为了大家更好的体验,所以本次提交就算了吧!"
# 主机ip 或者域名,默认0.0.0.0
host: 0.0.0.0
# 是否需要初始化数据库结构以及基本数据;true:需要;false:不需要
isinit: false
# JWT加密字符串
jwtsecret: 123abc
# log存放路径
logpath: temp/logs/log.log
# 服务名称
name: go-admin
# 服务端口
port: 8000
readtimeout: 1
writertimeout: 2
database:
# 数据库名称
database: dbname
# 数据库类型
dbtype: mysql
# 数据库地址
host: 127.0.0.1
# 数据库密码
password: password
# 数据库端口
port: 3306
# 数据库用户名
username: root
redis:
# redis链接地址
addr: 0.0.0.0:6379
# db
db: 0
# 密码
password: password
# 读超时时长
readtimeout: 50
```
2. 文件路径 go-admin/src/goadmin/config/settings.yml
## 📦 本地开发
首次启动说明
```bash
# 获取代码
git clone https://github.com/wenjianzhang/go-admin.git
# 进入工作路径
cd ./goadmin/src/goadmin
# 编译项目
go build
# 修改配置
vi ./config/setting.yml (更改isinit和数据库连接)
# 1. 配置文件中修改数据库信息
# 注意: settings.database 下对应的配置数据)
# 2. 确认数据库初始化参数
# 注意: settings.application.isinit 如果是首次启动,请把当前值设置成true,系统会自动初始化数据库结构以及基本的数据信息;
# 3. 确认log路径
# 启动项目,也可以用IDE进行调试
./goadmin
# 也可以在WIKI中查看说明
```
文档生成
```bash
swag init
```
如果没有swag命令 go get安装一下即可
```bash
go get -u github.com/swaggo/swag/cmd/swag
```
交叉编译
```bash
env GOOS=windows GOARCH=amd64 go build main.go
# or
env GOOS=linux GOARCH=amd64 go build main.go
```
## 🔗 在线体验
> admin / 123456
演示地址:[http://www.zhangwj.com](http://www.zhangwj.com/#/login)
## 🤝 使用的开源项目
[gin](https://github.com/gin-gonic/gin)
[casbin](https://github.com/casbin/casbin)
[spf13/viper](https://github.com/spf13/viper)
[gorm](https://github.com/jinzhu/gorm)
[gin-swagger](https://github.com/swaggo/gin-swagger)
[jwt-go](https://github.com/dgrijalva/jwt-go)
[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
[ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue)
## 版本
#### 2020-03-15 新功能及优化
1. 添加用户头像上传
2. 添加用户密码修改
3. 操作日志页面调整
4. 优化验证码背景色
看到好多体验的朋友验证码错误,所以调整了对比度,方便大家体验!
## 🤝 特别感谢
[chengxiao](https://github.com/chengxiao)
## License
[MIT](https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md)
Copyright (c) 2020 wenjianzhang
qq技术交流群: 74520518
+44 -7
View File
@@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at // This file was generated by swaggo/swag at
// 2020-03-13 22:08:25.834082 +0800 CST m=+0.100276337 // 2020-03-17 14:25:08.714368 +0800 CST m=+0.081722206
package docs package docs
@@ -20,7 +20,10 @@ var doc = `{
"description": "{{.Description}}", "description": "{{.Description}}",
"title": "{{.Title}}", "title": "{{.Title}}",
"contact": {}, "contact": {},
"license": {}, "license": {
"name": "MIT",
"url": "https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md"
},
"version": "{{.Version}}" "version": "{{.Version}}"
}, },
"host": "{{.Host}}", "host": "{{.Host}}",
@@ -433,9 +436,9 @@ var doc = `{
"application/json" "application/json"
], ],
"tags": [ "tags": [
"配置" "字典数据"
], ],
"summary": "添加配置", "summary": "添加字典数据",
"parameters": [ "parameters": [
{ {
"description": "data", "description": "data",
@@ -444,7 +447,7 @@ var doc = `{
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/models.Config" "$ref": "#/definitions/models.DictType"
} }
} }
], ],
@@ -2015,6 +2018,35 @@ var doc = `{
} }
} }
}, },
"/api/v1/user/profileAvatar": {
"post": {
"description": "获取JSON",
"consumes": [
"multipart/form-data"
],
"tags": [
"用户"
],
"summary": "修改头像",
"parameters": [
{
"type": "file",
"description": "file",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "{\"code\": -1, \"message\": \"添加失败\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/login": { "/login": {
"post": { "post": {
"description": "获取token", "description": "获取token",
@@ -2625,6 +2657,11 @@ var doc = `{
"models.Response": { "models.Response": {
"type": "object", "type": "object",
"properties": { "properties": {
"code": {
"description": "代码",
"type": "integer",
"example": 200
},
"data": { "data": {
"description": "数据集", "description": "数据集",
"type": "object" "type": "object"
@@ -2917,8 +2954,8 @@ var SwaggerInfo = swaggerInfo{
Host: "", Host: "",
BasePath: "", BasePath: "",
Schemes: []string{}, Schemes: []string{},
Title: "goadmin API", Title: "go-admin API",
Description: "Swagger.", Description: "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢!",
} }
type s struct{} type s struct{}
+43 -6
View File
@@ -1,10 +1,13 @@
{ {
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {
"description": "Swagger.", "description": "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢!",
"title": "goadmin API", "title": "go-admin API",
"contact": {}, "contact": {},
"license": {}, "license": {
"name": "MIT",
"url": "https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md"
},
"version": "0.0.1" "version": "0.0.1"
}, },
"paths": { "paths": {
@@ -415,9 +418,9 @@
"application/json" "application/json"
], ],
"tags": [ "tags": [
"配置" "字典数据"
], ],
"summary": "添加配置", "summary": "添加字典数据",
"parameters": [ "parameters": [
{ {
"description": "data", "description": "data",
@@ -426,7 +429,7 @@
"required": true, "required": true,
"schema": { "schema": {
"type": "object", "type": "object",
"$ref": "#/definitions/models.Config" "$ref": "#/definitions/models.DictType"
} }
} }
], ],
@@ -1997,6 +2000,35 @@
} }
} }
}, },
"/api/v1/user/profileAvatar": {
"post": {
"description": "获取JSON",
"consumes": [
"multipart/form-data"
],
"tags": [
"用户"
],
"summary": "修改头像",
"parameters": [
{
"type": "file",
"description": "file",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "{\"code\": -1, \"message\": \"添加失败\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/login": { "/login": {
"post": { "post": {
"description": "获取token", "description": "获取token",
@@ -2607,6 +2639,11 @@
"models.Response": { "models.Response": {
"type": "object", "type": "object",
"properties": { "properties": {
"code": {
"description": "代码",
"type": "integer",
"example": 200
},
"data": { "data": {
"description": "数据集", "description": "数据集",
"type": "object" "type": "object"
+33 -6
View File
@@ -288,6 +288,10 @@ definitions:
type: object type: object
models.Response: models.Response:
properties: properties:
code:
description: 代码
example: 200
type: integer
data: data:
description: 数据集 description: 数据集
type: object type: object
@@ -482,9 +486,13 @@ definitions:
type: object type: object
info: info:
contact: {} contact: {}
description: Swagger. description: |-
license: {} 基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档
title: goadmin API 添加微信号: zwj891129 进入技术交流微信群 请备注,谢谢!
license:
name: MIT
url: https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md
title: go-admin API
version: 0.0.1 version: 0.0.1
paths: paths:
/api/v1/config: /api/v1/config:
@@ -724,7 +732,7 @@ paths:
name: data name: data
required: true required: true
schema: schema:
$ref: '#/definitions/models.Config' $ref: '#/definitions/models.DictType'
type: object type: object
responses: responses:
"200": "200":
@@ -733,9 +741,9 @@ paths:
type: string type: string
security: security:
- Bearer: [] - Bearer: []
summary: 添加配置 summary: 添加字典数据
tags: tags:
- 配置 - 字典数据
put: put:
consumes: consumes:
- application/json - application/json
@@ -1741,6 +1749,25 @@ paths:
summary: 获取当前登录用户 summary: 获取当前登录用户
tags: tags:
- 个人中心 - 个人中心
/api/v1/user/profileAvatar:
post:
consumes:
- multipart/form-data
description: 获取JSON
parameters:
- description: file
in: formData
name: file
required: true
type: file
responses:
"200":
description: '{"code": -1, "message": "添加失败"}'
schema:
type: string
summary: 修改头像
tags:
- 用户
/login: /login:
post: post:
consumes: consumes:
+5 -2
View File
@@ -9,9 +9,12 @@ import (
"log" "log"
) )
// @title goadmin API // @title go-admin API
// @version 0.0.1 // @version 0.0.1
// @description Swagger. // @description 基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档
// @description 添加qq群: 74520518 进入技术交流群 请备注,谢谢!
// @license.name MIT
// @license.url https://github.com/wenjianzhang/go-admin/blob/master/LICENSE.md
// @securityDefinitions.apikey Bearer // @securityDefinitions.apikey Bearer
// @in header // @in header
+1 -1
View File
@@ -2,7 +2,7 @@ package models
type Response struct { type Response struct {
// 代码 // 代码
Code int `json:"code" example:"200,500,400,401"` Code int `json:"code" example:"200"`
// 数据集 // 数据集
Data interface{} `json:"data"` Data interface{} `json:"data"`
// 错误消息 // 错误消息