Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
e794ef05
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
332
Star
18154
Fork
5505
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e794ef05
编写于
4月 20, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加角色复制后台功能 修复swagger不能带token的问题
上级
8d668c6d
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
456 addition
and
11 deletion
+456
-11
server/api/v1/sys_authority.go
server/api/v1/sys_authority.go
+19
-0
server/docs/docs.go
server/docs/docs.go
+147
-5
server/docs/swagger.json
server/docs/swagger.json
+147
-1
server/docs/swagger.yaml
server/docs/swagger.yaml
+93
-0
server/initialize/router.go
server/initialize/router.go
+1
-0
server/main.go
server/main.go
+7
-0
server/model/response/sys_authority.go
server/model/response/sys_authority.go
+5
-0
server/model/response/sys_casbin.go
server/model/response/sys_casbin.go
+3
-1
server/router/sys_authority.go
server/router/sys_authority.go
+1
-0
server/service/sys_authority.go
server/service/sys_authority.go
+29
-0
server/service/sys_casbin.go
server/service/sys_casbin.go
+4
-4
未找到文件。
server/api/v1/sys_authority.go
浏览文件 @
e794ef05
...
...
@@ -29,6 +29,25 @@ func CreateAuthority(c *gin.Context) {
}
}
// @Tags authority
// @Summary 拷贝角色
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body response.SysAuthorityCopyResponse true "拷贝角色"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"拷贝成功"}"
// @Router /authority/copyAuthority [post]
func
CopyAuthority
(
c
*
gin
.
Context
)
{
var
copyInfo
resp
.
SysAuthorityCopyResponse
_
=
c
.
ShouldBindJSON
(
&
copyInfo
)
err
,
authBack
:=
service
.
CopyAuthority
(
copyInfo
)
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"创建失败,%v"
,
err
),
c
)
}
else
{
response
.
OkWithData
(
resp
.
SysAuthorityResponse
{
Authority
:
authBack
},
c
)
}
}
// @Tags authority
// @Summary 删除角色
// @Security ApiKeyAuth
...
...
server/docs/docs.go
浏览文件 @
e794ef05
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2020-04-
15 09:37:13.5084762 +0800 CST m=+0.1265666
01
// 2020-04-
20 14:50:58.4141704 +0800 CST m=+0.8816397
01
package
docs
...
...
@@ -248,6 +248,45 @@ var doc = `{
}
}
},
"/authority/copyAuthority": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authority"
],
"summary": "拷贝角色",
"parameters": [
{
"description": "拷贝角色",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/response.SysAuthorityCopyResponse"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"拷贝成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/authority/createAuthority": {
"post": {
"security": [
...
...
@@ -404,6 +443,45 @@ var doc = `{
}
}
},
"/authority/updateAuthority": {
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"authority"
],
"summary": "设置角色资源权限",
"parameters": [
{
"description": "设置角色资源权限",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/model.SysAuthority"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"设置成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/autoCode/createTemp": {
"post": {
"security": [
...
...
@@ -1588,6 +1666,45 @@ var doc = `{
}
}
},
"/user/deleteUser": {
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"SysUser"
],
"summary": "删除用户",
"parameters": [
{
"description": "删除用户",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/request.SetUserAuth"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"修改成功\"}",
"schema": {
"type": "string"
}
}
}
}
},
"/user/getUserList": {
"post": {
"security": [
...
...
@@ -2072,12 +2189,18 @@ var doc = `{
"component": {
"type": "string"
},
"defaultMenu": {
"type": "boolean"
},
"hidden": {
"type": "boolean"
},
"icon": {
"type": "string"
},
"keepAlive": {
"type": "boolean"
},
"name": {
"type": "string"
},
...
...
@@ -2317,6 +2440,25 @@ var doc = `{
"type": "string"
}
}
},
"response.SysAuthorityCopyResponse": {
"type": "object",
"properties": {
"authority": {
"type": "object",
"$ref": "#/definitions/model.SysAuthority"
},
"oldAuthorityId": {
"type": "integer"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "x-token",
"in": "header"
}
}
}`
...
...
@@ -2332,12 +2474,12 @@ type swaggerInfo struct {
// SwaggerInfo holds exported Swagger Info so clients can modify it
var
SwaggerInfo
=
swaggerInfo
{
Version
:
""
,
Version
:
"
0.0.1
"
,
Host
:
""
,
BasePath
:
""
,
BasePath
:
"
/
"
,
Schemes
:
[]
string
{},
Title
:
""
,
Description
:
""
,
Title
:
"
Swagger Example API
"
,
Description
:
"
This is a sample Server pets
"
,
}
type
s
struct
{}
...
...
server/docs/swagger.json
浏览文件 @
e794ef05
{
"swagger"
:
"2.0"
,
"info"
:
{
"description"
:
"This is a sample Server pets"
,
"title"
:
"Swagger Example API"
,
"contact"
:
{},
"license"
:
{}
"license"
:
{},
"version"
:
"0.0.1"
},
"basePath"
:
"/"
,
"paths"
:
{
"/api/createApi"
:
{
"post"
:
{
...
...
@@ -227,6 +231,45 @@
}
}
},
"/authority/copyAuthority"
:
{
"post"
:
{
"security"
:
[
{
"ApiKeyAuth"
:
[]
}
],
"consumes"
:
[
"application/json"
],
"produces"
:
[
"application/json"
],
"tags"
:
[
"authority"
],
"summary"
:
"拷贝角色"
,
"parameters"
:
[
{
"description"
:
"拷贝角色"
,
"name"
:
"data"
,
"in"
:
"body"
,
"required"
:
true
,
"schema"
:
{
"type"
:
"object"
,
"$ref"
:
"#/definitions/response.SysAuthorityCopyResponse"
}
}
],
"responses"
:
{
"200"
:
{
"description"
:
"{
\"
success
\"
:true,
\"
data
\"
:{},
\"
msg
\"
:
\"
拷贝成功
\"
}"
,
"schema"
:
{
"type"
:
"string"
}
}
}
}
},
"/authority/createAuthority"
:
{
"post"
:
{
"security"
:
[
...
...
@@ -383,6 +426,45 @@
}
}
},
"/authority/updateAuthority"
:
{
"post"
:
{
"security"
:
[
{
"ApiKeyAuth"
:
[]
}
],
"consumes"
:
[
"application/json"
],
"produces"
:
[
"application/json"
],
"tags"
:
[
"authority"
],
"summary"
:
"设置角色资源权限"
,
"parameters"
:
[
{
"description"
:
"设置角色资源权限"
,
"name"
:
"data"
,
"in"
:
"body"
,
"required"
:
true
,
"schema"
:
{
"type"
:
"object"
,
"$ref"
:
"#/definitions/model.SysAuthority"
}
}
],
"responses"
:
{
"200"
:
{
"description"
:
"{
\"
success
\"
:true,
\"
data
\"
:{},
\"
msg
\"
:
\"
设置成功
\"
}"
,
"schema"
:
{
"type"
:
"string"
}
}
}
}
},
"/autoCode/createTemp"
:
{
"post"
:
{
"security"
:
[
...
...
@@ -1567,6 +1649,45 @@
}
}
},
"/user/deleteUser"
:
{
"delete"
:
{
"security"
:
[
{
"ApiKeyAuth"
:
[]
}
],
"consumes"
:
[
"application/json"
],
"produces"
:
[
"application/json"
],
"tags"
:
[
"SysUser"
],
"summary"
:
"删除用户"
,
"parameters"
:
[
{
"description"
:
"删除用户"
,
"name"
:
"data"
,
"in"
:
"body"
,
"required"
:
true
,
"schema"
:
{
"type"
:
"object"
,
"$ref"
:
"#/definitions/request.SetUserAuth"
}
}
],
"responses"
:
{
"200"
:
{
"description"
:
"{
\"
success
\"
:true,
\"
data
\"
:{},
\"
msg
\"
:
\"
修改成功
\"
}"
,
"schema"
:
{
"type"
:
"string"
}
}
}
}
},
"/user/getUserList"
:
{
"post"
:
{
"security"
:
[
...
...
@@ -2051,12 +2172,18 @@
"component"
:
{
"type"
:
"string"
},
"defaultMenu"
:
{
"type"
:
"boolean"
},
"hidden"
:
{
"type"
:
"boolean"
},
"icon"
:
{
"type"
:
"string"
},
"keepAlive"
:
{
"type"
:
"boolean"
},
"name"
:
{
"type"
:
"string"
},
...
...
@@ -2296,6 +2423,25 @@
"type"
:
"string"
}
}
},
"response.SysAuthorityCopyResponse"
:
{
"type"
:
"object"
,
"properties"
:
{
"authority"
:
{
"type"
:
"object"
,
"$ref"
:
"#/definitions/model.SysAuthority"
},
"oldAuthorityId"
:
{
"type"
:
"integer"
}
}
}
},
"securityDefinitions"
:
{
"ApiKeyAuth"
:
{
"type"
:
"apiKey"
,
"name"
:
"x-token"
,
"in"
:
"header"
}
}
}
\ No newline at end of file
server/docs/swagger.yaml
浏览文件 @
e794ef05
basePath
:
/
definitions
:
config.Captcha
:
properties
:
...
...
@@ -217,10 +218,14 @@ definitions:
type
:
array
component
:
type
:
string
defaultMenu
:
type
:
boolean
hidden
:
type
:
boolean
icon
:
type
:
string
keepAlive
:
type
:
boolean
name
:
type
:
string
parentId
:
...
...
@@ -380,9 +385,20 @@ definitions:
uuid
:
type
:
string
type
:
object
response.SysAuthorityCopyResponse
:
properties
:
authority
:
$ref
:
'
#/definitions/model.SysAuthority'
type
:
object
oldAuthorityId
:
type
:
integer
type
:
object
info
:
contact
:
{}
description
:
This is a sample Server pets
license
:
{}
title
:
Swagger Example API
version
:
0.0.1
paths
:
/api/createApi
:
post
:
...
...
@@ -520,6 +536,30 @@ paths:
summary
:
创建基础api
tags
:
-
SysApi
/authority/copyAuthority
:
post
:
consumes
:
-
application/json
parameters
:
-
description
:
拷贝角色
in
:
body
name
:
data
required
:
true
schema
:
$ref
:
'
#/definitions/response.SysAuthorityCopyResponse'
type
:
object
produces
:
-
application/json
responses
:
"
200"
:
description
:
'
{"success":true,"data":{},"msg":"拷贝成功"}'
schema
:
type
:
string
security
:
-
ApiKeyAuth
:
[]
summary
:
拷贝角色
tags
:
-
authority
/authority/createAuthority
:
post
:
consumes
:
...
...
@@ -616,6 +656,30 @@ paths:
summary
:
设置角色资源权限
tags
:
-
authority
/authority/updateAuthority
:
post
:
consumes
:
-
application/json
parameters
:
-
description
:
设置角色资源权限
in
:
body
name
:
data
required
:
true
schema
:
$ref
:
'
#/definitions/model.SysAuthority'
type
:
object
produces
:
-
application/json
responses
:
"
200"
:
description
:
'
{"success":true,"data":{},"msg":"设置成功"}'
schema
:
type
:
string
security
:
-
ApiKeyAuth
:
[]
summary
:
设置角色资源权限
tags
:
-
authority
/autoCode/createTemp
:
post
:
consumes
:
...
...
@@ -1343,6 +1407,30 @@ paths:
summary
:
用户修改密码
tags
:
-
SysUser
/user/deleteUser
:
delete
:
consumes
:
-
application/json
parameters
:
-
description
:
删除用户
in
:
body
name
:
data
required
:
true
schema
:
$ref
:
'
#/definitions/request.SetUserAuth'
type
:
object
produces
:
-
application/json
responses
:
"
200"
:
description
:
'
{"success":true,"data":{},"msg":"修改成功"}'
schema
:
type
:
string
security
:
-
ApiKeyAuth
:
[]
summary
:
删除用户
tags
:
-
SysUser
/user/getUserList
:
post
:
consumes
:
...
...
@@ -1438,4 +1526,9 @@ paths:
summary
:
注册工作流
tags
:
-
workflow
securityDefinitions
:
ApiKeyAuth
:
in
:
header
name
:
x-token
type
:
apiKey
swagger
:
"
2.0"
server/initialize/router.go
浏览文件 @
e794ef05
...
...
@@ -11,6 +11,7 @@ import (
)
//初始化总路由
func
Routers
()
*
gin
.
Engine
{
var
Router
=
gin
.
Default
()
...
...
server/main.go
浏览文件 @
e794ef05
...
...
@@ -7,6 +7,13 @@ import (
//"runtime"
)
// @title Swagger Example API
// @version 0.0.1
// @description This is a sample Server pets
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name x-token
// @BasePath /
func
main
()
{
switch
global
.
GVA_CONFIG
.
System
.
DbType
{
case
"mysql"
:
...
...
server/model/response/sys_authority.go
浏览文件 @
e794ef05
...
...
@@ -5,3 +5,8 @@ import "gin-vue-admin/model"
type
SysAuthorityResponse
struct
{
Authority
model
.
SysAuthority
`json:"authority"`
}
type
SysAuthorityCopyResponse
struct
{
Authority
model
.
SysAuthority
`json:"authority"`
OldAuthorityId
string
`json:"oldAuthorityId"`
}
server/model/response/sys_casbin.go
浏览文件 @
e794ef05
package
response
import
"gin-vue-admin/model/request"
type
PolicyPathResponse
struct
{
Paths
[]
map
[
string
]
string
`json:"paths"`
Paths
[]
request
.
CasbinInfo
`json:"paths"`
}
server/router/sys_authority.go
浏览文件 @
e794ef05
...
...
@@ -12,6 +12,7 @@ func InitAuthorityRouter(Router *gin.RouterGroup) {
AuthorityRouter
.
POST
(
"createAuthority"
,
v1
.
CreateAuthority
)
//创建角色
AuthorityRouter
.
POST
(
"deleteAuthority"
,
v1
.
DeleteAuthority
)
//删除角色
AuthorityRouter
.
PUT
(
"updateAuthority"
,
v1
.
UpdateAuthority
)
//更新角色
AuthorityRouter
.
POST
(
"copyAuthority"
,
v1
.
CopyAuthority
)
//更新角色
AuthorityRouter
.
POST
(
"getAuthorityList"
,
v1
.
GetAuthorityList
)
//获取角色列表
AuthorityRouter
.
POST
(
"setDataAuthority"
,
v1
.
SetDataAuthority
)
//设置角色资源权限
}
...
...
server/service/sys_authority.go
浏览文件 @
e794ef05
...
...
@@ -5,6 +5,8 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"strconv"
)
// @title CreateAuthority
...
...
@@ -19,6 +21,33 @@ func CreateAuthority(auth model.SysAuthority) (err error, authority model.SysAut
return
err
,
auth
}
// @title CopyAuthority
// @description 复制一个角色
// @auth (2020/04/05 20:22)
// @param copyInfo response.SysAuthorityCopyResponse
// @return error
// @return authority model.SysAuthority
func
CopyAuthority
(
copyInfo
response
.
SysAuthorityCopyResponse
)
(
err
error
,
authority
model
.
SysAuthority
)
{
copyInfo
.
Authority
.
Children
=
[]
model
.
SysAuthority
{}
err
,
menus
:=
GetMenuAuthority
(
copyInfo
.
OldAuthorityId
)
var
baseMenu
[]
model
.
SysBaseMenu
for
_
,
v
:=
range
menus
{
intNum
,
_
:=
strconv
.
Atoi
(
v
.
MenuId
)
v
.
SysBaseMenu
.
ID
=
uint
(
intNum
)
baseMenu
=
append
(
baseMenu
,
v
.
SysBaseMenu
)
}
copyInfo
.
Authority
.
SysBaseMenus
=
baseMenu
err
=
global
.
GVA_DB
.
Create
(
&
copyInfo
.
Authority
)
.
Error
paths
:=
GetPolicyPathByAuthorityId
(
copyInfo
.
OldAuthorityId
)
err
=
UpdateCasbin
(
copyInfo
.
Authority
.
AuthorityId
,
paths
)
if
err
!=
nil
{
_
=
DeleteAuthority
(
&
copyInfo
.
Authority
)
}
return
err
,
copyInfo
.
Authority
}
// @title UpdateAuthority
// @description 更改一个角色
// @auth (2020/04/05 20:22)
...
...
server/service/sys_casbin.go
浏览文件 @
e794ef05
...
...
@@ -71,13 +71,13 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
// @param authorityId string
// @return []string
func
GetPolicyPathByAuthorityId
(
authorityId
string
)
(
pathMaps
[]
map
[
string
]
string
)
{
func
GetPolicyPathByAuthorityId
(
authorityId
string
)
(
pathMaps
[]
request
.
CasbinInfo
)
{
e
:=
Casbin
()
list
:=
e
.
GetFilteredPolicy
(
0
,
authorityId
)
for
_
,
v
:=
range
list
{
pathMaps
=
append
(
pathMaps
,
map
[
string
]
string
{
"path"
:
v
[
1
],
"method"
:
v
[
2
],
pathMaps
=
append
(
pathMaps
,
request
.
CasbinInfo
{
Path
:
v
[
1
],
Method
:
v
[
2
],
})
}
return
pathMaps
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录