Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Elij4h
gin-vue-admin
提交
474e07b8
G
gin-vue-admin
项目概览
Elij4h
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
474e07b8
编写于
4月 09, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改编辑方法逻辑,前端细节调整
上级
d5346012
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
48 addition
and
27 deletion
+48
-27
server/service/sys_api.go
server/service/sys_api.go
+10
-6
server/service/sys_casbin.go
server/service/sys_casbin.go
+4
-4
web/src/view/superAdmin/api/api.vue
web/src/view/superAdmin/api/api.vue
+28
-15
web/src/view/superAdmin/authority/authority.vue
web/src/view/superAdmin/authority/authority.vue
+2
-1
web/src/view/superAdmin/menu/menu.vue
web/src/view/superAdmin/menu/menu.vue
+4
-1
未找到文件。
server/service/sys_api.go
浏览文件 @
474e07b8
...
@@ -30,7 +30,7 @@ func CreateApi(a model.SysApi) (err error) {
...
@@ -30,7 +30,7 @@ func CreateApi(a model.SysApi) (err error) {
// @return error
// @return error
func
DeleteApi
(
a
model
.
SysApi
)
(
err
error
)
{
func
DeleteApi
(
a
model
.
SysApi
)
(
err
error
)
{
err
=
global
.
GVA_DB
.
Delete
(
a
)
.
Error
err
=
global
.
GVA_DB
.
Delete
(
a
)
.
Error
ClearCasbin
(
1
,
a
.
Path
)
ClearCasbin
(
1
,
a
.
Path
,
a
.
Method
)
return
err
return
err
}
}
...
@@ -111,15 +111,19 @@ func GetApiById(id float64) (err error, api model.SysApi) {
...
@@ -111,15 +111,19 @@ func GetApiById(id float64) (err error, api model.SysApi) {
// @return error
// @return error
func
UpdateApi
(
a
model
.
SysApi
)
(
err
error
)
{
func
UpdateApi
(
a
model
.
SysApi
)
(
err
error
)
{
var
oldA
model
.
SysApi
var
oldA
model
.
SysApi
err
=
global
.
GVA_DB
.
Where
(
"id = ?"
,
a
.
ID
)
.
First
(
&
oldA
)
.
Error
if
oldA
.
Path
!=
a
.
Path
||
oldA
.
Method
!=
a
.
Method
{
flag
:=
global
.
GVA_DB
.
Where
(
"path = ? AND method = ?"
,
a
.
Path
,
a
.
Method
)
.
Find
(
&
model
.
SysApi
{})
.
RecordNotFound
()
flag
:=
global
.
GVA_DB
.
Where
(
"path = ? AND method = ?"
,
a
.
Path
,
a
.
Method
)
.
Find
(
&
model
.
SysApi
{})
.
RecordNotFound
()
if
!
flag
{
if
!
flag
{
return
errors
.
New
(
"存在相同api路径"
)
return
errors
.
New
(
"存在相同api路径"
)
}
}
err
=
global
.
GVA_DB
.
Where
(
"id = ?"
,
a
.
ID
)
.
First
(
&
oldA
)
.
Error
}
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
else
{
}
else
{
err
=
UpdateCasbinApi
(
oldA
.
Path
,
a
.
Path
)
err
=
UpdateCasbinApi
(
oldA
.
Path
,
a
.
Path
,
oldA
.
Method
,
a
.
Method
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
else
{
}
else
{
...
...
server/service/sys_casbin.go
浏览文件 @
474e07b8
...
@@ -51,9 +51,9 @@ func AddCasbin(cm model.CasbinModel) bool {
...
@@ -51,9 +51,9 @@ func AddCasbin(cm model.CasbinModel) bool {
// @param oldPath string
// @param oldPath string
// @param newPath string
// @param newPath string
// @return error
// @return error
func
UpdateCasbinApi
(
oldPath
string
,
newPath
string
)
error
{
func
UpdateCasbinApi
(
oldPath
string
,
newPath
string
,
oldMethod
string
,
newMethod
string
)
error
{
var
cs
[]
model
.
CasbinModel
var
cs
[]
model
.
CasbinModel
err
:=
global
.
GVA_DB
.
Table
(
"casbin_rule"
)
.
Where
(
"v1 = ?
"
,
oldPath
)
.
Find
(
&
cs
)
.
Update
(
"v1"
,
newPath
)
.
Error
err
:=
global
.
GVA_DB
.
Table
(
"casbin_rule"
)
.
Where
(
"v1 = ?
AND v2 = ?"
,
oldPath
,
oldMethod
)
.
Find
(
&
cs
)
.
Update
(
"v1"
,
newPath
)
.
Update
(
"v2"
,
newMethod
)
.
Error
return
err
return
err
}
}
...
@@ -78,9 +78,9 @@ func GetPolicyPathByAuthorityId(authorityId string) []string {
...
@@ -78,9 +78,9 @@ func GetPolicyPathByAuthorityId(authorityId string) []string {
// @param v int
// @param v int
// @param p string
// @param p string
// @return bool
// @return bool
func
ClearCasbin
(
v
int
,
p
string
)
bool
{
func
ClearCasbin
(
v
int
,
p
...
string
)
bool
{
e
:=
Casbin
()
e
:=
Casbin
()
return
e
.
RemoveFilteredPolicy
(
v
,
p
)
return
e
.
RemoveFilteredPolicy
(
v
,
p
...
)
}
}
...
...
web/src/view/superAdmin/api/api.vue
浏览文件 @
474e07b8
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<el-input
placeholder=
"描述"
v-model=
"searchInfo.description"
></el-input>
<el-input
placeholder=
"描述"
v-model=
"searchInfo.description"
></el-input>
</el-form-item>
</el-form-item>
<el-form-item
label=
"请求"
>
<el-form-item
label=
"请求"
>
<el-select
placeholder=
"请选择"
clearable
v-model=
"searchInfo.method"
>
<el-select
clearable
placeholder=
"请选择"
v-model=
"searchInfo.method"
>
<el-option
<el-option
:key=
"item.value"
:key=
"item.value"
:label=
"`$
{item.label}(${item.value})`"
:label=
"`$
{item.label}(${item.value})`"
...
@@ -26,12 +26,12 @@
...
@@ -26,12 +26,12 @@
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</div>
</div>
<el-table
@
sort-change=
"sortChange"
:data=
"tableData
"
border
stripe
>
<el-table
:data=
"tableData"
@
sort-change=
"sortChange
"
border
stripe
>
<el-table-column
sortable=
"custom"
label=
"id"
min-width=
"60"
prop=
"ID
"
></el-table-column>
<el-table-column
label=
"id"
min-width=
"60"
prop=
"ID"
sortable=
"custom
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api路径"
min-width=
"150"
prop=
"path
"
></el-table-column>
<el-table-column
label=
"api路径"
min-width=
"150"
prop=
"path"
sortable=
"custom
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api分组"
min-width=
"150"
prop=
"apiGroup
"
></el-table-column>
<el-table-column
label=
"api分组"
min-width=
"150"
prop=
"apiGroup"
sortable=
"custom
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api简介"
min-width=
"150"
prop=
"description
"
></el-table-column>
<el-table-column
label=
"api简介"
min-width=
"150"
prop=
"description"
sortable=
"custom
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"请求"
min-width=
"150"
prop=
"method
"
>
<el-table-column
label=
"请求"
min-width=
"150"
prop=
"method"
sortable=
"custom
"
>
<template
slot-scope=
"scope"
>
<template
slot-scope=
"scope"
>
<div>
<div>
{{
scope
.
row
.
method
}}
{{
scope
.
row
.
method
}}
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
layout=
"total, sizes, prev, pager, next, jumper"
layout=
"total, sizes, prev, pager, next, jumper"
></el-pagination>
></el-pagination>
<el-dialog
:before-close=
"closeDialog"
:
visible.sync=
"dialogFormVisible"
title=
"新增Api
"
>
<el-dialog
:before-close=
"closeDialog"
:
title=
"dialogTitle"
:visible.sync=
"dialogFormVisible
"
>
<el-form
:inline=
"true"
:model=
"form"
:rules=
"rules"
label-width=
"80px"
ref=
"apiForm"
>
<el-form
:inline=
"true"
:model=
"form"
:rules=
"rules"
label-width=
"80px"
ref=
"apiForm"
>
<el-form-item
label=
"路径"
prop=
"path"
>
<el-form-item
label=
"路径"
prop=
"path"
>
<el-input
autocomplete=
"off"
v-model=
"form.path"
></el-input>
<el-input
autocomplete=
"off"
v-model=
"form.path"
></el-input>
...
@@ -107,7 +107,7 @@ import {
...
@@ -107,7 +107,7 @@ import {
deleteApi
deleteApi
}
from
'
@/api/api
'
}
from
'
@/api/api
'
import
infoList
from
'
@/components/mixins/infoList
'
import
infoList
from
'
@/components/mixins/infoList
'
import
{
toSQLLine
}
from
'
@/utils/stringFun
'
import
{
toSQLLine
}
from
'
@/utils/stringFun
'
const
methodOptions
=
[
const
methodOptions
=
[
{
{
value
:
'
POST
'
,
value
:
'
POST
'
,
...
@@ -138,6 +138,7 @@ export default {
...
@@ -138,6 +138,7 @@ export default {
return
{
return
{
listApi
:
getApiList
,
listApi
:
getApiList
,
dialogFormVisible
:
false
,
dialogFormVisible
:
false
,
dialogTitle
:
'
新增Api
'
,
form
:
{
form
:
{
path
:
''
,
path
:
''
,
apiGroup
:
''
,
apiGroup
:
''
,
...
@@ -148,7 +149,9 @@ export default {
...
@@ -148,7 +149,9 @@ export default {
type
:
''
,
type
:
''
,
rules
:
{
rules
:
{
path
:
[{
required
:
true
,
message
:
'
请输入api路径
'
,
trigger
:
'
blur
'
}],
path
:
[{
required
:
true
,
message
:
'
请输入api路径
'
,
trigger
:
'
blur
'
}],
apiGroup
:
[{
required
:
true
,
message
:
'
请输入组名称
'
,
trigger
:
'
blur
'
}],
apiGroup
:
[
{
required
:
true
,
message
:
'
请输入组名称
'
,
trigger
:
'
blur
'
}
],
method
:
[
method
:
[
{
required
:
true
,
message
:
'
请选择请求方式
'
,
trigger
:
'
blur
'
}
{
required
:
true
,
message
:
'
请选择请求方式
'
,
trigger
:
'
blur
'
}
],
],
...
@@ -160,10 +163,10 @@ export default {
...
@@ -160,10 +163,10 @@ export default {
},
},
methods
:
{
methods
:
{
// 排序
// 排序
sortChange
({
prop
,
order
})
{
sortChange
({
prop
,
order
})
{
if
(
prop
)
{
if
(
prop
)
{
this
.
searchInfo
.
orderKey
=
toSQLLine
(
prop
)
this
.
searchInfo
.
orderKey
=
toSQLLine
(
prop
)
this
.
searchInfo
.
desc
=
order
==
"
descending
"
this
.
searchInfo
.
desc
=
order
==
'
descending
'
}
}
this
.
getTableData
()
this
.
getTableData
()
},
},
...
@@ -181,6 +184,16 @@ export default {
...
@@ -181,6 +184,16 @@ export default {
this
.
dialogFormVisible
=
false
this
.
dialogFormVisible
=
false
},
},
openDialog
(
type
)
{
openDialog
(
type
)
{
switch
(
type
)
{
case
'
addApi
'
:
this
.
dialogTitlethis
=
'
新增Api
'
break
case
'
edit
'
:
this
.
dialogTitlethis
=
'
编辑Api
'
break
default
:
break
}
this
.
type
=
type
this
.
type
=
type
this
.
dialogFormVisible
=
true
this
.
dialogFormVisible
=
true
},
},
...
...
web/src/view/superAdmin/authority/authority.vue
浏览文件 @
474e07b8
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<!-- 新增角色弹窗 -->
<!-- 新增角色弹窗 -->
<el-dialog
:visible.sync=
"dialogFormVisible"
title=
"新增角色
"
>
<el-dialog
:visible.sync=
"dialogFormVisible"
:title=
"dialogTitle
"
>
<el-form
:model=
"form"
:rules=
"rules"
ref=
"authorityForm"
>
<el-form
:model=
"form"
:rules=
"rules"
ref=
"authorityForm"
>
<el-form-item
label=
"父级角色ID"
prop=
"parentId"
>
<el-form-item
label=
"父级角色ID"
prop=
"parentId"
>
<el-input
autocomplete=
"off"
disabled
v-model=
"form.parentId"
></el-input>
<el-input
autocomplete=
"off"
disabled
v-model=
"form.parentId"
></el-input>
...
@@ -79,6 +79,7 @@ export default {
...
@@ -79,6 +79,7 @@ export default {
drawer
:
false
,
drawer
:
false
,
activeRow
:
{},
activeRow
:
{},
activeUserId
:
0
,
activeUserId
:
0
,
dialogTitle
:
"
新增角色
"
,
dialogFormVisible
:
false
,
dialogFormVisible
:
false
,
apiDialogFlag
:
false
,
apiDialogFlag
:
false
,
form
:
{
form
:
{
...
...
web/src/view/superAdmin/menu/menu.vue
浏览文件 @
474e07b8
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<el-dialog
:before-close=
"handleClose"
:visible.sync=
"dialogFormVisible"
title=
"新增菜单
"
>
<el-dialog
:before-close=
"handleClose"
:visible.sync=
"dialogFormVisible"
:title=
"dialogTitle
"
>
<el-form
:inline=
"true"
:model=
"form"
:rules=
"rules"
label-width=
"85px"
ref=
"menuForm"
>
<el-form
:inline=
"true"
:model=
"form"
:rules=
"rules"
label-width=
"85px"
ref=
"menuForm"
>
<el-form-item
label=
"路由name"
prop=
"path"
>
<el-form-item
label=
"路由name"
prop=
"path"
>
<el-input
autocomplete=
"off"
placeholder=
"唯一英文字符串"
v-model=
"form.path"
></el-input>
<el-input
autocomplete=
"off"
placeholder=
"唯一英文字符串"
v-model=
"form.path"
></el-input>
...
@@ -89,6 +89,7 @@ export default {
...
@@ -89,6 +89,7 @@ export default {
return
{
return
{
listApi
:
getMenuList
,
listApi
:
getMenuList
,
dialogFormVisible
:
false
,
dialogFormVisible
:
false
,
dialogTitle
:
"
新增菜单
"
,
form
:
{
form
:
{
ID
:
0
,
ID
:
0
,
path
:
''
,
path
:
''
,
...
@@ -198,12 +199,14 @@ export default {
...
@@ -198,12 +199,14 @@ export default {
},
},
// 添加菜单方法,id为 0则为添加根菜单
// 添加菜单方法,id为 0则为添加根菜单
addMenu
(
id
)
{
addMenu
(
id
)
{
this
.
dialogTitle
=
"
新增菜单
"
this
.
form
.
parentId
=
String
(
id
)
this
.
form
.
parentId
=
String
(
id
)
this
.
isEdit
=
false
this
.
isEdit
=
false
this
.
dialogFormVisible
=
true
this
.
dialogFormVisible
=
true
},
},
// 修改菜单方法
// 修改菜单方法
async
editMenu
(
id
)
{
async
editMenu
(
id
)
{
this
.
dialogTitle
=
"
编辑菜单
"
const
res
=
await
getBaseMenuById
({
id
})
const
res
=
await
getBaseMenuById
({
id
})
this
.
form
=
res
.
data
.
menu
this
.
form
=
res
.
data
.
menu
this
.
dialogFormVisible
=
true
this
.
dialogFormVisible
=
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录