Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
nizhengjia888
gin-vue-admin
提交
1821468a
G
gin-vue-admin
项目概览
nizhengjia888
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
3
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,发现更多精彩内容 >>
提交
1821468a
编写于
9月 21, 2019
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提供了前端分页mixin解决方案
上级
86a9129c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
198 addition
and
62 deletion
+198
-62
QMPlusServer/controller/api/api.go
QMPlusServer/controller/api/api.go
+49
-0
QMPlusServer/controller/api/authority.go
QMPlusServer/controller/api/authority.go
+1
-1
QMPlusServer/controller/api/menu.go
QMPlusServer/controller/api/menu.go
+1
-1
QMPlusServer/model/dbModel/api.go
QMPlusServer/model/dbModel/api.go
+5
-3
QMPlusServer/model/dbModel/api_authority.go
QMPlusServer/model/dbModel/api_authority.go
+16
-1
QMPlusServer/router/api.go
QMPlusServer/router/api.go
+5
-3
QMPlusServer/router/base.go
QMPlusServer/router/base.go
+3
-3
QMPlusVuePage/src/api/api.js
QMPlusVuePage/src/api/api.js
+20
-0
QMPlusVuePage/src/view/superAdmin/api/api.vue
QMPlusVuePage/src/view/superAdmin/api/api.vue
+53
-5
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
+9
-23
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
+8
-22
QMPlusVuePage/src/view/superAdmin/mixins/infoList.js
QMPlusVuePage/src/view/superAdmin/mixins/infoList.js
+28
-0
未找到文件。
QMPlusServer/controller/api/api.go
浏览文件 @
1821468a
...
...
@@ -5,6 +5,7 @@ import (
"github.com/gin-gonic/gin"
"main/controller/servers"
"main/model/dbModel"
"main/model/modelInterface"
)
type
CreateApiParams
struct
{
...
...
@@ -54,3 +55,51 @@ func DeleteApi(c *gin.Context) {
servers
.
ReportFormat
(
c
,
true
,
"删除成功"
,
gin
.
H
{})
}
}
type
AuthAndPathIn
struct
{
AuthorityId
string
`json:"authorityId"`
Apis
[]
dbModel
.
Api
`json:"apis"`
}
// @Tags Api
// @Summary 创建api和角色关系
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body api.AuthAndPathIn true "创建api和角色关系"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/setAuthAndPath [post]
func
SetAuthAndPath
(
c
*
gin
.
Context
){
var
authAndPathIn
AuthAndPathIn
_
=
c
.
BindJSON
(
&
authAndPathIn
)
err
:=
new
(
dbModel
.
ApiAuthority
)
.
SetAuthAndPath
(
authAndPathIn
.
AuthorityId
,
authAndPathIn
.
Apis
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"添加失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"添加成功"
,
gin
.
H
{})
}
}
// @Tags api
// @Summary 分页获取角色列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取用户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getApiList [post]
func
GetApiList
(
c
*
gin
.
Context
)
{
var
pageInfo
modelInterface
.
PageInfo
_
=
c
.
BindJSON
(
&
pageInfo
)
err
,
list
,
total
:=
new
(
dbModel
.
Api
)
.
GetInfoList
(
pageInfo
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"获取数据失败,%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"获取数据成功"
,
gin
.
H
{
"list"
:
list
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
})
}
}
\ No newline at end of file
QMPlusServer/controller/api/authority.go
浏览文件 @
1821468a
...
...
@@ -76,7 +76,7 @@ func GetAuthorityList(c *gin.Context){
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"获取数据失败,%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"获取数据成功"
,
gin
.
H
{
"
authL
ist"
:
list
,
"
l
ist"
:
list
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
...
...
QMPlusServer/controller/api/menu.go
浏览文件 @
1821468a
...
...
@@ -43,7 +43,7 @@ func GetMenuList(c *gin.Context) {
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"获取数据失败,%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"获取数据成功"
,
gin
.
H
{
"
menuL
ist"
:
menuList
,
"
l
ist"
:
menuList
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
...
...
QMPlusServer/model/dbModel/api.go
浏览文件 @
1821468a
...
...
@@ -2,13 +2,14 @@ package dbModel
import
(
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
"main/controller/servers"
"main/init/qmsql"
"main/model/modelInterface"
)
type
Api
struct
{
gorm
.
Model
`json:"-"`
gorm
.
Model
Path
string
`json:"path"`
Description
string
`json:"description"`
}
...
...
@@ -16,7 +17,7 @@ type Api struct {
func
(
a
*
Api
)
CreateApi
()
(
err
error
)
{
findOne
:=
qmsql
.
DEFAULTDB
.
Where
(
"path = ?"
,
a
.
Path
)
.
Find
(
&
Menu
{})
.
Error
if
findOne
!=
nil
{
return
errors
.
New
(
"存在相同api"
)
}
else
{
err
=
qmsql
.
DEFAULTDB
.
Create
(
a
)
.
Error
}
...
...
@@ -29,7 +30,8 @@ func (a *Api) DeleteApi() (err error) {
}
func
(
a
*
Api
)
EditApi
()
(
err
error
)
{
err
=
qmsql
.
DEFAULTDB
.
Update
(
a
)
.
Update
(
&
Authority
{})
.
Error
err
=
qmsql
.
DEFAULTDB
.
Update
(
a
)
.
Error
err
=
qmsql
.
DEFAULTDB
.
Where
(
"path = ?"
,
a
.
Path
)
.
Update
(
"path"
,
a
.
Path
)
.
Error
return
err
}
...
...
QMPlusServer/model/dbModel/api_authority.go
浏览文件 @
1821468a
package
dbModel
import
"main/init/qmsql"
type
ApiAuthority
struct
{
AuthorityId
string
`json:"-"`
Api
Path
string
`json:"_"`
}
//创建角色api关联关系
func
(
a
*
ApiAuthority
)
SetAuthAndPath
(
authId
string
,
apis
[]
Api
)(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Where
(
"authority_id = ?"
,
authId
)
.
Delete
(
&
ApiAuthority
{})
.
Error
for
_
,
v
:=
range
apis
{
err
=
qmsql
.
DEFAULTDB
.
Create
(
&
ApiAuthority
{
AuthorityId
:
authId
,
Path
:
v
.
Path
})
.
Error
if
(
err
!=
nil
){
return
err
}
}
return
nil
}
\ No newline at end of file
QMPlusServer/router/api.go
浏览文件 @
1821468a
...
...
@@ -7,9 +7,11 @@ import (
)
func
InitApiRouter
(
Router
*
gin
.
Engine
)
{
User
Router
:=
Router
.
Group
(
"api"
)
.
Use
(
middleware
.
JWTAuth
())
Api
Router
:=
Router
.
Group
(
"api"
)
.
Use
(
middleware
.
JWTAuth
())
{
UserRouter
.
POST
(
"createApi"
,
api
.
CreateApi
)
UserRouter
.
POST
(
"deleteApi"
,
api
.
DeleteApi
)
ApiRouter
.
POST
(
"createApi"
,
api
.
CreateApi
)
ApiRouter
.
POST
(
"deleteApi"
,
api
.
DeleteApi
)
ApiRouter
.
POST
(
"setAuthAndPath"
,
api
.
SetAuthAndPath
)
ApiRouter
.
POST
(
"getApiList"
,
api
.
GetApiList
)
}
}
QMPlusServer/router/base.go
浏览文件 @
1821468a
...
...
@@ -6,9 +6,9 @@ import (
)
func
InitBaseRouter
(
Router
*
gin
.
Engine
)
{
User
Router
:=
Router
.
Group
(
"base"
)
Base
Router
:=
Router
.
Group
(
"base"
)
{
User
Router
.
POST
(
"regist"
,
api
.
Regist
)
User
Router
.
POST
(
"login"
,
api
.
Login
)
Base
Router
.
POST
(
"regist"
,
api
.
Regist
)
Base
Router
.
POST
(
"login"
,
api
.
Login
)
}
}
QMPlusVuePage/src/api/api.js
0 → 100644
浏览文件 @
1821468a
import
service
from
'
@/utils/request
'
// @Tags api
// @Summary 分页获取角色列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取用户列表"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /api/getApiList [post]
// {
// page int
// pageSize int
// }
export
const
getApiList
=
(
data
)
=>
{
return
service
({
url
:
"
/api/getApiList
"
,
method
:
'
post
'
,
data
})
}
\ No newline at end of file
QMPlusVuePage/src/view/superAdmin/api/api.vue
浏览文件 @
1821468a
<
template
>
<div>
新建api
<div>
<div
class=
"button-box clearflex"
>
<el-button
@
click=
"addApi"
type=
"primary"
>
新增api
</el-button>
</div>
<el-table
:data=
"tableData"
border
stripe
>
<el-table-column
label=
"id"
min-width=
"180"
prop=
"ID"
></el-table-column>
<el-table-column
label=
"api路径"
min-width=
"180"
prop=
"path"
></el-table-column>
<el-table-column
label=
"api简介"
min-width=
"180"
prop=
"description"
></el-table-column>
<el-table-column
fixed=
"right"
label=
"操作"
width=
"200"
>
<template
slot-scope=
"scope"
>
<el-button
@
click=
"editApi(scope.row)"
size=
"small"
type=
"text"
>
编辑
</el-button>
<el-button
@
click=
"deleteApi(scope.row)"
size=
"small"
type=
"text"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
<el-pagination
:current-page=
"page"
:page-size=
"pageSize"
:page-sizes=
"[10, 30, 50, 100]"
:style=
"{float:'right',padding:'20px'}"
:total=
"total"
@
current-change=
"handleCurrentChange"
@
size-change=
"handleSizeChange"
hide-on-single-page
layout=
"total, sizes, prev, pager, next, jumper"
></el-pagination>
</div>
</template>
<
script
>
import
{
getApiList
}
from
'
@/api/api
'
import
infoList
from
'
@/view/superAdmin/mixins/infoList
'
export
default
{
name
:
"
Api
"
,
name
:
'
Api
'
,
mixins
:[
infoList
],
data
()
{
return
{
listApi
:
getApiList
,
listKey
:
'
list
'
}
},
methods
:
{
addApi
()
{},
editApi
()
{},
deleteApi
()
{}
},
created
()
{
this
.
getTableData
()
}
}
</
script
>
<
style
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.button-box
{
padding
:
10px
20px
;
.el-button
{
float
:
right
;
}
}
</
style
>
\ No newline at end of file
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
浏览文件 @
1821468a
...
...
@@ -67,15 +67,15 @@ import {
createAuthority
}
from
'
@/api/authority
'
import
{
getBaseMenuTree
,
addMenuAuthority
,
getMenuAuthority
}
from
'
@/api/menu
'
import
infoList
from
'
@/view/superAdmin/mixins/infoList
'
export
default
{
name
:
'
Authority
'
,
mixins
:[
infoList
],
data
()
{
return
{
listApi
:
getAuthorityList
,
listKey
:
'
list
'
,
activeUserId
:
0
,
page
:
1
,
total
:
10
,
pageSize
:
10
,
tableData
:
[],
treeData
:
[],
treeIds
:
[],
defaultProps
:
{
...
...
@@ -91,16 +91,6 @@ export default {
}
},
methods
:
{
// 条数
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
getAuthList
()
},
// 页码
handleCurrentChange
(
val
)
{
this
.
page
=
val
this
.
getAuthList
()
},
// 删除角色
deleteAuth
(
row
)
{
this
.
$confirm
(
'
此操作将永久删除该角色, 是否继续?
'
,
'
提示
'
,
{
...
...
@@ -115,7 +105,7 @@ export default {
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
get
AuthList
()
this
.
get
TableData
()
}
})
.
catch
(()
=>
{
...
...
@@ -145,7 +135,7 @@ export default {
type
:
'
success
'
,
message
:
'
添加成功!
'
})
this
.
get
AuthList
()
this
.
get
TableData
()
this
.
closeDialog
()
}
this
.
initForm
()
...
...
@@ -155,11 +145,7 @@ export default {
addAuthority
()
{
this
.
dialogFormVisible
=
true
},
// 获取用户列表
async
getAuthList
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
const
table
=
await
getAuthorityList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
authList
},
// 关联用户列表关系
async
addAuthMenu
(
row
)
{
const
res1
=
await
getMenuAuthority
({
authorityId
:
row
.
authorityId
})
...
...
@@ -194,11 +180,11 @@ export default {
// 获取基础menu树
},
created
()
{
this
.
get
AuthList
()
this
.
get
TableData
()
}
}
</
script
>
<
style
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.button-box
{
padding
:
10px
20px
;
.el-button
{
...
...
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
浏览文件 @
1821468a
...
...
@@ -80,14 +80,14 @@
<
script
>
import
{
getMenuList
,
addBaseMenu
,
deleteBaseMenu
}
from
'
@/api/menu
'
import
infoList
from
'
@/view/superAdmin/mixins/infoList
'
export
default
{
name
:
'
Menus
'
,
mixins
:[
infoList
],
data
()
{
return
{
page
:
1
,
total
:
10
,
pageSize
:
10
,
tableData
:
[],
listApi
:
getMenuList
,
listKey
:
'
list
'
,
dialogFormVisible
:
false
,
form
:
{
path
:
''
,
...
...
@@ -103,14 +103,6 @@ export default {
}
},
methods
:
{
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
getMenuList
()
},
handleCurrentChange
(
val
)
{
this
.
page
=
val
this
.
getMenuList
()
},
deleteMenu
(
ID
)
{
this
.
$confirm
(
'
此操作将永久删除所有角色下该菜单, 是否继续?
'
,
'
提示
'
,
{
confirmButtonText
:
'
确定
'
,
...
...
@@ -124,7 +116,7 @@ export default {
type
:
'
success
'
,
message
:
'
删除成功!
'
})
this
.
get
MenuList
()
this
.
get
TableData
()
}
})
.
catch
(()
=>
{
...
...
@@ -158,7 +150,7 @@ export default {
type
:
'
success
'
,
message
:
'
添加成功!
'
})
this
.
get
AuthList
()
this
.
get
TableData
()
this
.
closeDialog
()
}
else
{
this
.
$message
({
...
...
@@ -174,17 +166,11 @@ export default {
this
.
form
.
parentId
=
String
(
id
)
this
.
dialogFormVisible
=
true
},
async
getMenuList
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
const
table
=
await
getMenuList
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
.
menuList
}
},
created
()
{
this
.
getMenuList
()
}
}
</
script
>
<
style
lang=
"scss"
>
<
style
scoped
lang=
"scss"
>
.button-box
{
padding
:
10px
20px
;
.el-button
{
...
...
QMPlusVuePage/src/view/superAdmin/mixins/infoList.js
0 → 100644
浏览文件 @
1821468a
export
default
{
data
()
{
return
{
page
:
1
,
total
:
10
,
pageSize
:
10
,
tableData
:
[],
}
},
methods
:
{
handleSizeChange
(
val
)
{
this
.
pageSize
=
val
this
.
getTableData
()
},
handleCurrentChange
(
val
)
{
this
.
page
=
val
this
.
getTableData
()
},
async
getTableData
(
page
=
this
.
page
,
pageSize
=
this
.
pageSize
)
{
const
table
=
await
this
.
listApi
({
page
,
pageSize
})
this
.
tableData
=
table
.
data
[
this
.
listKey
]
}
},
created
()
{
this
.
getTableData
()
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录