pixel
5 years ago
12 changed files with 198 additions and 62 deletions
-
49QMPlusServer/controller/api/api.go
-
2QMPlusServer/controller/api/authority.go
-
2QMPlusServer/controller/api/menu.go
-
8QMPlusServer/model/dbModel/api.go
-
17QMPlusServer/model/dbModel/api_authority.go
-
8QMPlusServer/router/api.go
-
6QMPlusServer/router/base.go
-
20QMPlusVuePage/src/api/api.js
-
56QMPlusVuePage/src/view/superAdmin/api/api.vue
-
32QMPlusVuePage/src/view/superAdmin/authority/authority.vue
-
30QMPlusVuePage/src/view/superAdmin/menu/menu.vue
-
28QMPlusVuePage/src/view/superAdmin/mixins/infoList.js
@ -1,6 +1,21 @@ |
|||
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 |
|||
} |
@ -0,0 +1,20 @@ |
|||
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 |
|||
}) |
|||
} |
@ -1,14 +1,62 @@ |
|||
<template> |
|||
<div> |
|||
新建api |
|||
<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' |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
}, |
|||
methods: { |
|||
|
|||
addApi() {}, |
|||
editApi() {}, |
|||
deleteApi() {} |
|||
}, |
|||
created() { |
|||
this.getTableData() |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped lang="scss"> |
|||
.button-box { |
|||
padding: 10px 20px; |
|||
.el-button { |
|||
float: right; |
|||
} |
|||
} |
|||
</style> |
@ -0,0 +1,28 @@ |
|||
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() |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue