Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
474e07b8
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
9 个月 前同步成功
通知
324
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,体验更适合开发者的 AI 搜索 >>
提交
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) {
// @return error
func
DeleteApi
(
a
model
.
SysApi
)
(
err
error
)
{
err
=
global
.
GVA_DB
.
Delete
(
a
)
.
Error
ClearCasbin
(
1
,
a
.
Path
)
ClearCasbin
(
1
,
a
.
Path
,
a
.
Method
)
return
err
}
...
...
@@ -111,15 +111,19 @@ func GetApiById(id float64) (err error, api model.SysApi) {
// @return error
func
UpdateApi
(
a
model
.
SysApi
)
(
err
error
)
{
var
oldA
model
.
SysApi
flag
:=
global
.
GVA_DB
.
Where
(
"path = ? AND method = ?"
,
a
.
Path
,
a
.
Method
)
.
Find
(
&
model
.
SysApi
{})
.
RecordNotFound
()
if
!
flag
{
return
errors
.
New
(
"存在相同api路径"
)
}
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
()
if
!
flag
{
return
errors
.
New
(
"存在相同api路径"
)
}
}
if
err
!=
nil
{
return
err
}
else
{
err
=
UpdateCasbinApi
(
oldA
.
Path
,
a
.
Path
)
err
=
UpdateCasbinApi
(
oldA
.
Path
,
a
.
Path
,
oldA
.
Method
,
a
.
Method
)
if
err
!=
nil
{
return
err
}
else
{
...
...
server/service/sys_casbin.go
浏览文件 @
474e07b8
...
...
@@ -51,9 +51,9 @@ func AddCasbin(cm model.CasbinModel) bool {
// @param oldPath string
// @param newPath string
// @return error
func
UpdateCasbinApi
(
oldPath
string
,
newPath
string
)
error
{
func
UpdateCasbinApi
(
oldPath
string
,
newPath
string
,
oldMethod
string
,
newMethod
string
)
error
{
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
}
...
...
@@ -78,9 +78,9 @@ func GetPolicyPathByAuthorityId(authorityId string) []string {
// @param v int
// @param p string
// @return bool
func
ClearCasbin
(
v
int
,
p
string
)
bool
{
func
ClearCasbin
(
v
int
,
p
...
string
)
bool
{
e
:=
Casbin
()
return
e
.
RemoveFilteredPolicy
(
v
,
p
)
return
e
.
RemoveFilteredPolicy
(
v
,
p
...
)
}
...
...
web/src/view/superAdmin/api/api.vue
浏览文件 @
474e07b8
...
...
@@ -8,8 +8,8 @@
<el-form-item
label=
"描述"
>
<el-input
placeholder=
"描述"
v-model=
"searchInfo.description"
></el-input>
</el-form-item>
<el-form-item
label=
"请求"
>
<el-select
placeholder=
"请选择"
clearable
v-model=
"searchInfo.method"
>
<el-form-item
label=
"请求"
>
<el-select
clearable
placeholder=
"请选择"
v-model=
"searchInfo.method"
>
<el-option
:key=
"item.value"
:label=
"`$
{item.label}(${item.value})`"
...
...
@@ -26,12 +26,12 @@
</el-form-item>
</el-form>
</div>
<el-table
@
sort-change=
"sortChange"
:data=
"tableData
"
border
stripe
>
<el-table-column
sortable=
"custom"
label=
"id"
min-width=
"60"
prop=
"ID
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api路径"
min-width=
"150"
prop=
"path
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api分组"
min-width=
"150"
prop=
"apiGroup
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"api简介"
min-width=
"150"
prop=
"description
"
></el-table-column>
<el-table-column
sortable=
"custom"
label=
"请求"
min-width=
"150"
prop=
"method
"
>
<el-table
:data=
"tableData"
@
sort-change=
"sortChange
"
border
stripe
>
<el-table-column
label=
"id"
min-width=
"60"
prop=
"ID"
sortable=
"custom
"
></el-table-column>
<el-table-column
label=
"api路径"
min-width=
"150"
prop=
"path"
sortable=
"custom
"
></el-table-column>
<el-table-column
label=
"api分组"
min-width=
"150"
prop=
"apiGroup"
sortable=
"custom
"
></el-table-column>
<el-table-column
label=
"api简介"
min-width=
"150"
prop=
"description"
sortable=
"custom
"
></el-table-column>
<el-table-column
label=
"请求"
min-width=
"150"
prop=
"method"
sortable=
"custom
"
>
<template
slot-scope=
"scope"
>
<div>
{{
scope
.
row
.
method
}}
...
...
@@ -64,7 +64,7 @@
layout=
"total, sizes, prev, pager, next, jumper"
></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-item
label=
"路径"
prop=
"path"
>
<el-input
autocomplete=
"off"
v-model=
"form.path"
></el-input>
...
...
@@ -107,7 +107,7 @@ import {
deleteApi
}
from
'
@/api/api
'
import
infoList
from
'
@/components/mixins/infoList
'
import
{
toSQLLine
}
from
'
@/utils/stringFun
'
import
{
toSQLLine
}
from
'
@/utils/stringFun
'
const
methodOptions
=
[
{
value
:
'
POST
'
,
...
...
@@ -138,6 +138,7 @@ export default {
return
{
listApi
:
getApiList
,
dialogFormVisible
:
false
,
dialogTitle
:
'
新增Api
'
,
form
:
{
path
:
''
,
apiGroup
:
''
,
...
...
@@ -148,7 +149,9 @@ export default {
type
:
''
,
rules
:
{
path
:
[{
required
:
true
,
message
:
'
请输入api路径
'
,
trigger
:
'
blur
'
}],
apiGroup
:
[{
required
:
true
,
message
:
'
请输入组名称
'
,
trigger
:
'
blur
'
}],
apiGroup
:
[
{
required
:
true
,
message
:
'
请输入组名称
'
,
trigger
:
'
blur
'
}
],
method
:
[
{
required
:
true
,
message
:
'
请选择请求方式
'
,
trigger
:
'
blur
'
}
],
...
...
@@ -160,12 +163,12 @@ export default {
},
methods
:
{
// 排序
sortChange
({
prop
,
order
})
{
if
(
prop
)
{
sortChange
({
prop
,
order
})
{
if
(
prop
)
{
this
.
searchInfo
.
orderKey
=
toSQLLine
(
prop
)
this
.
searchInfo
.
desc
=
order
==
"
descending
"
this
.
searchInfo
.
desc
=
order
==
'
descending
'
}
this
.
getTableData
()
this
.
getTableData
()
},
//条件搜索前端看此方法
onSubmit
()
{
...
...
@@ -181,6 +184,16 @@ export default {
this
.
dialogFormVisible
=
false
},
openDialog
(
type
)
{
switch
(
type
)
{
case
'
addApi
'
:
this
.
dialogTitlethis
=
'
新增Api
'
break
case
'
edit
'
:
this
.
dialogTitlethis
=
'
编辑Api
'
break
default
:
break
}
this
.
type
=
type
this
.
dialogFormVisible
=
true
},
...
...
web/src/view/superAdmin/authority/authority.vue
浏览文件 @
474e07b8
...
...
@@ -22,7 +22,7 @@
</el-table-column>
</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-item
label=
"父级角色ID"
prop=
"parentId"
>
<el-input
autocomplete=
"off"
disabled
v-model=
"form.parentId"
></el-input>
...
...
@@ -79,6 +79,7 @@ export default {
drawer
:
false
,
activeRow
:
{},
activeUserId
:
0
,
dialogTitle
:
"
新增角色
"
,
dialogFormVisible
:
false
,
apiDialogFlag
:
false
,
form
:
{
...
...
web/src/view/superAdmin/menu/menu.vue
浏览文件 @
474e07b8
...
...
@@ -35,7 +35,7 @@
</el-table-column>
</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-item
label=
"路由name"
prop=
"path"
>
<el-input
autocomplete=
"off"
placeholder=
"唯一英文字符串"
v-model=
"form.path"
></el-input>
...
...
@@ -89,6 +89,7 @@ export default {
return
{
listApi
:
getMenuList
,
dialogFormVisible
:
false
,
dialogTitle
:
"
新增菜单
"
,
form
:
{
ID
:
0
,
path
:
''
,
...
...
@@ -198,12 +199,14 @@ export default {
},
// 添加菜单方法,id为 0则为添加根菜单
addMenu
(
id
)
{
this
.
dialogTitle
=
"
新增菜单
"
this
.
form
.
parentId
=
String
(
id
)
this
.
isEdit
=
false
this
.
dialogFormVisible
=
true
},
// 修改菜单方法
async
editMenu
(
id
)
{
this
.
dialogTitle
=
"
编辑菜单
"
const
res
=
await
getBaseMenuById
({
id
})
this
.
form
=
res
.
data
.
menu
this
.
dialogFormVisible
=
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录