Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
62678966
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
342
Star
18155
Fork
5506
代码
文件
提交
分支
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,发现更多精彩内容 >>
未验证
提交
62678966
编写于
12月 28, 2019
作者:
G
Grant
提交者:
GitHub
12月 28, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2 from piexlmax/master
update
上级
e1958efb
f2e5d401
变更
12
展开全部
显示空白变更内容
内联
并排
Showing
12 changed file
with
214 addition
and
95 deletion
+214
-95
QMPlusServer/config/config.go
QMPlusServer/config/config.go
+17
-6
QMPlusServer/controller/servers/upload.go
QMPlusServer/controller/servers/upload.go
+3
-2
QMPlusServer/db/qmplus.sql
QMPlusServer/db/qmplus.sql
+77
-45
QMPlusServer/init/qmsql/initMysql.go
QMPlusServer/init/qmsql/initMysql.go
+1
-1
QMPlusServer/main.go
QMPlusServer/main.go
+6
-6
QMPlusServer/model/sysModel/sys_authority.go
QMPlusServer/model/sysModel/sys_authority.go
+27
-5
QMPlusServer/model/sysModel/sys_casbin.go
QMPlusServer/model/sysModel/sys_casbin.go
+2
-1
QMPlusServer/static/config/config.json
QMPlusServer/static/config/config.json
+16
-0
QMPlusVuePage/src/utils/request.js
QMPlusVuePage/src/utils/request.js
+27
-3
QMPlusVuePage/src/view/example/upload/upload.vue
QMPlusVuePage/src/view/example/upload/upload.vue
+8
-1
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
+28
-23
README.md
README.md
+2
-2
未找到文件。
QMPlusServer/config/config.go
浏览文件 @
62678966
...
...
@@ -7,9 +7,15 @@ import (
)
type
Config
struct
{
Admin
Admin
MysqlAdmin
MysqlAdmin
Qiniu
Qiniu
CasbinConfig
CasbinConfig
}
type
Admin
struct
{
type
CasbinConfig
struct
{
ModelPath
string
// casbin model地址配置
}
type
MysqlAdmin
struct
{
// mysql admin 数据库配置
Username
string
Password
string
Path
string
...
...
@@ -17,12 +23,17 @@ type Admin struct {
Config
string
}
var
Dbconfig
Config
type
Qiniu
struct
{
// 七牛 密钥配置
AccessKey
string
SecretKey
string
}
var
GinVueAdminconfig
Config
func
init
()
{
v
:=
viper
.
New
()
v
.
SetConfigName
(
"config"
)
// 设置配置文件名 (不带后缀)
v
.
AddConfigPath
(
"./static/
db
config/"
)
// 第一个搜索路径
v
.
AddConfigPath
(
"./static/config/"
)
// 第一个搜索路径
v
.
SetConfigType
(
"json"
)
err
:=
v
.
ReadInConfig
()
// 搜索路径,并读取配置数据
if
err
!=
nil
{
...
...
@@ -32,7 +43,7 @@ func init() {
v
.
OnConfigChange
(
func
(
e
fsnotify
.
Event
)
{
fmt
.
Println
(
"Config file changed:"
,
e
.
Name
)
})
if
err
:=
v
.
Unmarshal
(
&
Db
config
);
err
!=
nil
{
if
err
:=
v
.
Unmarshal
(
&
GinVueAdmin
config
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
}
QMPlusServer/controller/servers/upload.go
浏览文件 @
62678966
...
...
@@ -3,14 +3,15 @@ package servers
import
(
"context"
"fmt"
"gin-vue-admin/config"
"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/storage"
"mime/multipart"
"time"
)
var
accessKey
string
=
"25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ"
// 你在七牛云的accessKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
secretKey
string
=
"pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY"
// 你在七牛云的secretKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
accessKey
string
=
config
.
GinVueAdminconfig
.
Qiniu
.
AccessKey
// 你在七牛云的accessKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
secretKey
string
=
config
.
GinVueAdminconfig
.
Qiniu
.
SecretKey
// 你在七牛云的secretKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
// 接收两个参数 一个文件流 一个 bucket 你的七牛云标准空间的名字
func
Upload
(
file
*
multipart
.
FileHeader
,
bucket
string
,
urlPath
string
)
(
err
error
,
path
string
,
key
string
)
{
...
...
QMPlusServer/db/qmplus.sql
浏览文件 @
62678966
此差异已折叠。
点击以展开。
QMPlusServer/init/qmsql/initMysql.go
浏览文件 @
62678966
...
...
@@ -10,7 +10,7 @@ import (
var
DEFAULTDB
*
gorm
.
DB
//初始化数据库并产生数据库全局变量
func
InitMysql
(
admin
config
.
Admin
)
*
gorm
.
DB
{
func
InitMysql
(
admin
config
.
Mysql
Admin
)
*
gorm
.
DB
{
if
db
,
err
:=
gorm
.
Open
(
"mysql"
,
admin
.
Username
+
":"
+
admin
.
Password
+
"@("
+
admin
.
Path
+
")/"
+
admin
.
Dbname
+
"?"
+
admin
.
Config
);
err
!=
nil
{
log
.
Printf
(
"DEFAULTDB数据库启动异常%S"
,
err
)
}
else
{
...
...
QMPlusServer/main.go
浏览文件 @
62678966
...
...
@@ -21,7 +21,7 @@ import (
func
main
()
{
qmlog
.
InitLog
()
// 初始化日志
db
:=
qmsql
.
InitMysql
(
config
.
Dbconfig
.
Admin
)
// 链接初始化数据库
db
:=
qmsql
.
InitMysql
(
config
.
GinVueAdminconfig
.
Mysql
Admin
)
// 链接初始化数据库
registTable
.
RegistTable
(
db
)
//注册数据库表
defer
qmsql
.
DEFAULTDB
.
Close
()
// 程序结束前关闭数据库链接
Router
:=
initRouter
.
InitRouter
()
//注册路由
...
...
QMPlusServer/model/sysModel/sys_authority.go
浏览文件 @
62678966
...
...
@@ -12,6 +12,8 @@ type SysAuthority struct {
gorm
.
Model
AuthorityId
string
`json:"authorityId" gorm:"not null;unique"`
AuthorityName
string
`json:"authorityName"`
ParentId
string
`json:"parentId"`
Children
[]
SysAuthority
`json:"children"`
}
// 创建角色
...
...
@@ -23,9 +25,14 @@ func (a *SysAuthority) CreateAuthority() (err error, authority *SysAuthority) {
// 删除角色
func
(
a
*
SysAuthority
)
DeleteAuthority
()
(
err
error
)
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"authority_id = ?"
,
a
.
AuthorityId
)
.
Find
(
&
SysUser
{})
.
Error
if
err
!=
nil
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"parentId = ?"
,
a
.
AuthorityId
)
.
Find
(
&
SysAuthority
{})
.
Error
if
err
!=
nil
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"authority_id = ?"
,
a
.
AuthorityId
)
.
First
(
a
)
.
Unscoped
()
.
Delete
(
a
)
.
Error
new
(
CasbinModel
)
.
clearCasbin
(
0
,
a
.
AuthorityId
)
}
else
{
err
=
errors
.
New
(
"此角色存在子角色不允许删除"
)
}
}
else
{
err
=
errors
.
New
(
"此角色有用户正在使用禁止删除"
)
}
...
...
@@ -40,7 +47,22 @@ func (a *SysAuthority) GetInfoList(info modelInterface.PageInfo) (err error, lis
return
}
else
{
var
authority
[]
SysAuthority
err
=
db
.
Find
(
&
authority
)
.
Error
err
=
db
.
Where
(
"parent_id = 0"
)
.
Find
(
&
authority
)
.
Error
if
len
(
authority
)
>
0
{
for
k
,
_
:=
range
authority
{
err
=
findChildrenAuthority
(
&
authority
[
k
])
}
}
return
err
,
authority
,
total
}
}
func
findChildrenAuthority
(
authority
*
SysAuthority
)
(
err
error
)
{
err
=
qmsql
.
DEFAULTDB
.
Where
(
"parent_id = ?"
,
authority
.
AuthorityId
)
.
Find
(
&
authority
.
Children
)
.
Error
if
len
(
authority
.
Children
)
>
0
{
for
k
,
_
:=
range
authority
.
Children
{
err
=
findChildrenAuthority
(
&
authority
.
Children
[
k
])
}
}
return
err
}
QMPlusServer/model/sysModel/sys_casbin.go
浏览文件 @
62678966
...
...
@@ -2,6 +2,7 @@ package sysModel
import
(
"errors"
"gin-vue-admin/config"
"gin-vue-admin/init/qmsql"
"github.com/casbin/casbin"
gormadapter
"github.com/casbin/gorm-adapter"
...
...
@@ -83,7 +84,7 @@ func ParamsMatchFunc(args ...interface{}) (interface{}, error) {
//持久化到数据库 引入自定义规则
func
Casbin
()
*
casbin
.
Enforcer
{
a
:=
gormadapter
.
NewAdapterByDB
(
qmsql
.
DEFAULTDB
)
e
:=
casbin
.
NewEnforcer
(
"./static/rbacmodel/rbac_model.conf"
,
a
)
e
:=
casbin
.
NewEnforcer
(
config
.
GinVueAdminconfig
.
CasbinConfig
.
ModelPath
,
a
)
e
.
AddFunction
(
"ParamsMatch"
,
ParamsMatchFunc
)
e
.
LoadPolicy
()
return
e
...
...
QMPlusServer/static/
db
config/config.json
→
QMPlusServer/static/config/config.json
浏览文件 @
62678966
{
"
a
dmin"
:
{
"
mysqlA
dmin"
:
{
"username"
:
"root"
,
"password"
:
"Aa@6447985"
,
"path"
:
"127.0.0.1:3306"
,
"dbname"
:
"qmplus"
,
"config"
:
"charset=utf8&parseTime=True&loc=Local"
},
"qiniu"
:
{
"accessKey"
:
"25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ"
,
"secretKey"
:
"pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY"
},
"casbinConfig"
:{
"modelPath"
:
"./static/rbacmodel/rbac_model.conf"
}
}
\ No newline at end of file
QMPlusVuePage/src/utils/request.js
浏览文件 @
62678966
import
axios
from
'
axios
'
;
// 引入axios
import
{
Message
}
from
'
element-ui
'
;
import
{
Message
,
Loading
}
from
'
element-ui
'
;
import
{
store
}
from
'
@/store/index
'
const
service
=
axios
.
create
({
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
timeout
:
99999
})
let
acitveAxios
=
0
let
loadingInstance
let
timer
const
showLoading
=
()
=>
{
acitveAxios
++
if
(
timer
)
{
clearTimeout
(
timer
)
}
timer
=
setTimeout
(()
=>
{
if
(
acitveAxios
>
0
)
{
loadingInstance
=
Loading
.
service
({
fullscreen
:
true
})
}
},
400
);
}
//http request 拦截器
const
closeLoading
=
()
=>
{
acitveAxios
--
if
(
acitveAxios
<=
0
)
{
clearTimeout
(
timer
)
loadingInstance
&&
loadingInstance
.
close
()
}
}
//http request 拦截器
service
.
interceptors
.
request
.
use
(
config
=>
{
showLoading
()
const
token
=
store
.
getters
[
'
user/token
'
]
config
.
data
=
JSON
.
stringify
(
config
.
data
);
config
.
headers
=
{
...
...
@@ -19,6 +40,7 @@ service.interceptors.request.use(
return
config
;
},
error
=>
{
closeLoading
()
Message
({
showClose
:
true
,
message
:
error
,
...
...
@@ -32,6 +54,7 @@ service.interceptors.request.use(
//http response 拦截器
service
.
interceptors
.
response
.
use
(
response
=>
{
closeLoading
()
if
(
response
.
data
.
success
)
{
return
response
.
data
}
else
{
...
...
@@ -47,6 +70,7 @@ service.interceptors.response.use(
}
},
error
=>
{
closeLoading
()
Message
({
showClose
:
true
,
message
:
error
,
...
...
QMPlusVuePage/src/view/example/upload/upload.vue
浏览文件 @
62678966
<
template
>
<div>
<div
v-loading.fullscreen.lock=
"fullscreenLoading"
>
<el-upload
:action=
"`$
{path}/fileUploadAndDownload/upload`"
:before-upload="checkFile"
...
...
@@ -64,6 +64,7 @@ export default {
mixins
:
[
infoList
],
data
()
{
return
{
fullscreenLoading
:
false
,
listApi
:
getFileList
,
listKey
:
'
list
'
,
path
:
path
,
...
...
@@ -121,14 +122,17 @@ export default {
})
},
checkFile
(
file
)
{
this
.
fullscreenLoading
=
true
const
isJPG
=
file
.
type
===
'
image/jpeg
'
const
isPng
=
file
.
type
===
'
image/png
'
const
isLt2M
=
file
.
size
/
1024
/
1024
<
2
if
(
!
isJPG
&&
!
isPng
)
{
this
.
$message
.
error
(
'
上传头像图片只能是 JPG或png 格式!
'
)
this
.
fullscreenLoading
=
false
}
if
(
!
isLt2M
)
{
this
.
$message
.
error
(
'
上传头像图片大小不能超过 2MB!
'
)
this
.
fullscreenLoading
=
false
}
return
(
isPng
||
isJPG
)
&&
isLt2M
},
...
...
@@ -140,12 +144,15 @@ export default {
if
(
res
.
success
)
{
this
.
getTableData
()
}
this
.
fullscreenLoading
=
false
},
uploadError
()
{
this
.
$message
({
type
:
'
error
'
,
message
:
'
上传失败
'
})
this
.
fullscreenLoading
=
false
},
downloadFile
(
row
)
{
downloadImage
(
row
.
url
,
row
.
name
)
...
...
QMPlusVuePage/src/view/superAdmin/authority/authority.vue
浏览文件 @
62678966
<
template
>
<div
class=
"authority"
>
<div
class=
"button-box clearflex"
>
<el-button
@
click=
"addAuthority"
type=
"primary"
>
新增角色
</el-button>
<el-button
@
click=
"addAuthority
('0')
"
type=
"primary"
>
新增角色
</el-button>
</div>
<el-table
:data=
"tableData"
border
stripe
>
<el-table
:data=
"tableData"
style=
"width: 100%"
row-key=
"ID"
border
stripe
:tree-props=
"
{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column
label=
"id"
min-width=
"180"
prop=
"ID"
></el-table-column>
<el-table-column
label=
"角色id"
min-width=
"180"
prop=
"authorityId"
></el-table-column>
<el-table-column
label=
"角色名称"
min-width=
"180"
prop=
"authorityName"
></el-table-column>
...
...
@@ -11,23 +17,17 @@
<template
slot-scope=
"scope"
>
<el-button
@
click=
"opdendrawer(scope.row)"
size=
"small"
type=
"text"
>
设置权限
</el-button>
<el-button
@
click=
"deleteAuth(scope.row)"
size=
"small"
type=
"text"
>
删除角色
</el-button>
<el-button
@
click=
"addAuthority(scope.row.authorityId)"
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"
layout=
"total, sizes, prev, pager, next, jumper"
></el-pagination>
<!-- 新增角色弹窗 -->
<el-dialog
:visible.sync=
"dialogFormVisible"
title=
"新增角色"
>
<el-form
:model=
"form"
>
<el-form-item
label=
"父级角色ID"
>
<el-input
autocomplete=
"off"
disabled
v-model=
"form.parentId"
></el-input>
</el-form-item>
<el-form-item
label=
"角色ID"
>
<el-input
autocomplete=
"off"
v-model=
"form.authorityId"
></el-input>
</el-form-item>
...
...
@@ -81,7 +81,8 @@ export default {
apiDialogFlag
:
false
,
form
:
{
authorityId
:
''
,
authorityName
:
''
authorityName
:
''
,
parentId
:
'
0
'
}
}
},
...
...
@@ -146,9 +147,13 @@ export default {
this
.
dialogFormVisible
=
false
},
// 增加角色
addAuthority
()
{
addAuthority
(
parentId
)
{
this
.
form
.
parentId
=
parentId
this
.
dialogFormVisible
=
true
}
},
created
(){
this
.
pageSize
=
999
}
}
</
script
>
...
...
README.md
浏览文件 @
62678966
...
...
@@ -108,8 +108,8 @@ swag init
项目文件夹下面会有 doc文件夹出现
这时候登录 localhost:8888/swagger/index.html
就可以看到 swagger文档啦
##
个人
博客
http
://www
.henrongyi.top,内有前端框架教学视频,GOLANG基础入门视频正在筹备中。
##
团队
博客
http
s://blog
.henrongyi.top,内有前端框架教学视频,GOLANG基础入门视频正在筹备中。
如果觉得项目对您有所帮助可以添加我的个人微信:shouzi_1994,欢迎您提出宝贵的需求。
## 最后
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录