Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
97162680
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
344
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看板
提交
97162680
编写于
5月 19, 2020
作者:
L
Leonard Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复格式问题,重构嵌套层数过深的函数
上级
de757504
变更
38
隐藏空白更改
内联
并排
Showing
38 changed file
with
167 addition
and
172 deletion
+167
-172
server/api/v1/exa_breakpoint_continue.go
server/api/v1/exa_breakpoint_continue.go
+27
-28
server/api/v1/exa_file_upload_download.go
server/api/v1/exa_file_upload_download.go
+2
-2
server/api/v1/sys_api.go
server/api/v1/sys_api.go
+1
-1
server/api/v1/sys_authority.go
server/api/v1/sys_authority.go
+2
-2
server/api/v1/sys_auto_code.go
server/api/v1/sys_auto_code.go
+1
-1
server/api/v1/sys_system.go
server/api/v1/sys_system.go
+1
-1
server/api/v1/sys_user.go
server/api/v1/sys_user.go
+48
-51
server/initialize/db_table.go
server/initialize/db_table.go
+1
-1
server/initialize/mysql.go
server/initialize/mysql.go
+1
-1
server/initialize/router.go
server/initialize/router.go
+2
-2
server/initialize/sqlite.go
server/initialize/sqlite.go
+16
-16
server/main.go
server/main.go
+1
-1
server/middleware/casbin_rcba.go
server/middleware/casbin_rcba.go
+5
-5
server/middleware/cors.go
server/middleware/cors.go
+1
-1
server/middleware/jwt.go
server/middleware/jwt.go
+6
-6
server/middleware/loadtls.go
server/middleware/loadtls.go
+1
-1
server/model/request/sys_api.go
server/model/request/sys_api.go
+1
-1
server/model/sys_system.go
server/model/sys_system.go
+1
-1
server/model/sys_workflow.go
server/model/sys_workflow.go
+1
-1
server/model/sys_workflow_process.go
server/model/sys_workflow_process.go
+1
-1
server/router/exp_file_upload_and_download.go
server/router/exp_file_upload_and_download.go
+1
-1
server/router/sys_api.go
server/router/sys_api.go
+5
-5
server/router/sys_authority.go
server/router/sys_authority.go
+6
-6
server/router/sys_auto_code.go
server/router/sys_auto_code.go
+1
-1
server/router/sys_jwt.go
server/router/sys_jwt.go
+1
-1
server/router/sys_menu.go
server/router/sys_menu.go
+2
-2
server/router/sys_user.go
server/router/sys_user.go
+3
-3
server/service/sys_authority.go
server/service/sys_authority.go
+2
-2
server/service/sys_auto_code.go
server/service/sys_auto_code.go
+3
-3
server/service/sys_casbin.go
server/service/sys_casbin.go
+2
-2
server/service/sys_menu.go
server/service/sys_menu.go
+1
-1
server/service/sys_user.go
server/service/sys_user.go
+3
-3
server/utils/breakpoint_continue.go
server/utils/breakpoint_continue.go
+1
-1
server/utils/des.go
server/utils/des.go
+0
-1
server/utils/directory.go
server/utils/directory.go
+5
-5
server/utils/upload.go
server/utils/upload.go
+1
-1
server/utils/validator.go
server/utils/validator.go
+9
-9
server/utils/zipfiles.go
server/utils/zipfiles.go
+1
-1
未找到文件。
server/api/v1/exa_breakpoint_continue.go
浏览文件 @
97162680
...
...
@@ -3,7 +3,6 @@ package v1
import
(
"fmt"
"gin-vue-admin/global/response"
_
"gin-vue-admin/model/response"
resp
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
...
...
@@ -29,34 +28,34 @@ func BreakpointContinue(c *gin.Context) {
_
,
FileHeader
,
err
:=
c
.
Request
.
FormFile
(
"file"
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
f
,
err
:=
FileHeader
.
Open
()
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
cen
,
_
:=
ioutil
.
ReadAll
(
f
)
defer
f
.
Close
()
if
flag
:=
utils
.
CheckMd5
(
cen
,
chunkMd5
);
flag
{
err
,
file
:=
service
.
FindOrCreateFile
(
fileMd5
,
fileName
,
chunkTotal
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
err
,
pathc
:=
utils
.
BreakPointContinue
(
cen
,
fileName
,
chunkNumber
,
chunkTotal
,
fileMd5
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
err
=
service
.
CreateFileChunk
(
file
.
ID
,
pathc
,
chunkNumber
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
}
else
{
response
.
OkWithMessage
(
"切片创建成功"
,
c
)
}
}
}
}
else
{
}
}
return
}
f
,
err
:=
FileHeader
.
Open
()
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
defer
f
.
Close
()
cen
,
_
:=
ioutil
.
ReadAll
(
f
)
if
flag
:=
utils
.
CheckMd5
(
cen
,
chunkMd5
);
!
flag
{
return
}
err
,
file
:=
service
.
FindOrCreateFile
(
fileMd5
,
fileName
,
chunkTotal
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
err
,
pathc
:=
utils
.
BreakPointContinue
(
cen
,
fileName
,
chunkNumber
,
chunkTotal
,
fileMd5
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
if
err
=
service
.
CreateFileChunk
(
file
.
ID
,
pathc
,
chunkNumber
);
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
response
.
OkWithMessage
(
"切片创建成功"
,
c
)
}
// @Tags ExaFileUploadAndDownload
...
...
server/api/v1/exa_file_upload_download.go
浏览文件 @
97162680
...
...
@@ -26,12 +26,12 @@ func UploadFile(c *gin.Context) {
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"上传文件失败,%v"
,
err
),
c
)
}
else
{
//文件上传后拿到文件路径
//
文件上传后拿到文件路径
err
,
filePath
,
key
:=
utils
.
Upload
(
header
)
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"接收返回值失败,%v"
,
err
),
c
)
}
else
{
//修改数据库后得到修改后的user并且返回供前端使用
//
修改数据库后得到修改后的user并且返回供前端使用
var
file
model
.
ExaFileUploadAndDownload
file
.
Url
=
filePath
file
.
Name
=
header
.
Filename
...
...
server/api/v1/sys_api.go
浏览文件 @
97162680
...
...
@@ -68,7 +68,7 @@ func DeleteApi(c *gin.Context) {
}
}
//条件搜索后端看此api
//
条件搜索后端看此api
// @Tags SysApi
// @Summary 分页获取API列表
...
...
server/api/v1/sys_authority.go
浏览文件 @
97162680
...
...
@@ -93,7 +93,7 @@ func DeleteAuthority(c *gin.Context) {
response
.
FailWithMessage
(
AuthorityIdVerifyErr
.
Error
(),
c
)
return
}
//删除角色之前需要判断是否有用户正在使用此角色
//
删除角色之前需要判断是否有用户正在使用此角色
err
:=
service
.
DeleteAuthority
(
&
a
)
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"删除失败,%v"
,
err
),
c
)
...
...
@@ -127,7 +127,7 @@ func UpdateAuthority(c *gin.Context) {
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"更新失败,%v"
,
err
),
c
)
}
else
{
response
.
OkWithData
(
resp
.
SysAuthorityResponse
{
authority
},
c
)
response
.
OkWithData
(
resp
.
SysAuthorityResponse
{
Authority
:
authority
},
c
)
}
}
...
...
server/api/v1/sys_auto_code.go
浏览文件 @
97162680
...
...
@@ -80,7 +80,7 @@ func CreateTemp(c *gin.Context) {
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"创建失败,%v"
,
err
),
c
)
os
.
Remove
(
"./ginvueadmin.zip"
)
}
else
{
c
.
Writer
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
"attachment; filename=%s"
,
"ginvueadmin.zip"
))
//fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c
.
Writer
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
"attachment; filename=%s"
,
"ginvueadmin.zip"
))
//
fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c
.
Writer
.
Header
()
.
Add
(
"Content-Type"
,
"application/json"
)
c
.
Writer
.
Header
()
.
Add
(
"success"
,
"true"
)
c
.
File
(
"./ginvueadmin.zip"
)
...
...
server/api/v1/sys_system.go
浏览文件 @
97162680
...
...
@@ -42,7 +42,7 @@ func SetSystemConfig(c *gin.Context) {
}
}
//本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
//
本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
// @Tags system
// @Summary 设置配置文件内容
// @Security ApiKeyAuth
...
...
server/api/v1/sys_user.go
浏览文件 @
97162680
...
...
@@ -80,10 +80,10 @@ func Login(c *gin.Context) {
}
//登录以后签发jwt
//
登录以后签发jwt
func
tokenNext
(
c
*
gin
.
Context
,
user
model
.
SysUser
)
{
j
:=
&
middleware
.
JWT
{
[]
byte
(
global
.
GVA_CONFIG
.
JWT
.
SigningKey
),
// 唯一签名
SigningKey
:
[]
byte
(
global
.
GVA_CONFIG
.
JWT
.
SigningKey
),
// 唯一签名
}
clams
:=
request
.
CustomClaims
{
UUID
:
user
.
UUID
,
...
...
@@ -91,58 +91,55 @@ func tokenNext(c *gin.Context, user model.SysUser) {
NickName
:
user
.
NickName
,
AuthorityId
:
user
.
AuthorityId
,
StandardClaims
:
jwt
.
StandardClaims
{
NotBefore
:
int64
(
time
.
Now
()
.
Unix
()
-
1000
)
,
// 签名生效时间
ExpiresAt
:
int64
(
time
.
Now
()
.
Unix
()
+
60
*
60
*
24
*
7
)
,
// 过期时间 一周
Issuer
:
"qmPlus"
,
//
签名的发行者
NotBefore
:
time
.
Now
()
.
Unix
()
-
1000
,
// 签名生效时间
ExpiresAt
:
time
.
Now
()
.
Unix
()
+
60
*
60
*
24
*
7
,
// 过期时间 一周
Issuer
:
"qmPlus"
,
//
签名的发行者
},
}
token
,
err
:=
j
.
CreateToken
(
clams
)
if
err
!=
nil
{
response
.
FailWithMessage
(
"获取token失败"
,
c
)
return
}
if
!
global
.
GVA_CONFIG
.
System
.
UseMultipoint
{
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
return
}
var
loginJwt
model
.
JwtBlacklist
loginJwt
.
Jwt
=
token
err
,
jwtStr
:=
service
.
GetRedisJWT
(
user
.
Username
)
if
err
==
redis
.
Nil
{
if
err
:=
service
.
SetRedisJWT
(
loginJwt
,
user
.
Username
);
err
!=
nil
{
response
.
FailWithMessage
(
"设置登录状态失败"
,
c
)
return
}
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
}
else
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"%v"
,
err
),
c
)
}
else
{
if
global
.
GVA_CONFIG
.
System
.
UseMultipoint
{
var
loginJwt
model
.
JwtBlacklist
loginJwt
.
Jwt
=
token
err
,
jwtStr
:=
service
.
GetRedisJWT
(
user
.
Username
)
if
err
==
redis
.
Nil
{
err2
:=
service
.
SetRedisJWT
(
loginJwt
,
user
.
Username
)
if
err2
!=
nil
{
response
.
FailWithMessage
(
"设置登录状态失败"
,
c
)
}
else
{
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
}
}
else
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"%v"
,
err
),
c
)
}
else
{
var
blackJWT
model
.
JwtBlacklist
blackJWT
.
Jwt
=
jwtStr
err3
:=
service
.
JsonInBlacklist
(
blackJWT
)
if
err3
!=
nil
{
response
.
FailWithMessage
(
"jwt作废失败"
,
c
)
}
else
{
err2
:=
service
.
SetRedisJWT
(
loginJwt
,
user
.
Username
)
if
err2
!=
nil
{
response
.
FailWithMessage
(
"设置登录状态失败"
,
c
)
}
else
{
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
}
}
}
}
else
{
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
var
blackJWT
model
.
JwtBlacklist
blackJWT
.
Jwt
=
jwtStr
if
err
:=
service
.
JsonInBlacklist
(
blackJWT
);
err
!=
nil
{
response
.
FailWithMessage
(
"jwt作废失败"
,
c
)
return
}
if
err
:=
service
.
SetRedisJWT
(
loginJwt
,
user
.
Username
);
err
!=
nil
{
response
.
FailWithMessage
(
"设置登录状态失败"
,
c
)
return
}
response
.
OkWithData
(
resp
.
LoginResponse
{
User
:
user
,
Token
:
token
,
ExpiresAt
:
clams
.
StandardClaims
.
ExpiresAt
*
1000
,
},
c
)
}
}
...
...
@@ -189,21 +186,21 @@ type UserHeaderImg struct {
// @Router /user/uploadHeaderImg [post]
func
UploadHeaderImg
(
c
*
gin
.
Context
)
{
claims
,
_
:=
c
.
Get
(
"claims"
)
//获取头像文件
//
获取头像文件
// 这里我们通过断言获取 claims内的所有内容
waitUse
:=
claims
.
(
*
request
.
CustomClaims
)
uuid
:=
waitUse
.
UUID
_
,
header
,
err
:=
c
.
Request
.
FormFile
(
"headerImg"
)
//便于找到用户 以后从jwt中取
//
便于找到用户 以后从jwt中取
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"上传文件失败,%v"
,
err
),
c
)
}
else
{
//文件上传后拿到文件路径
//
文件上传后拿到文件路径
err
,
filePath
,
_
:=
utils
.
Upload
(
header
)
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"接收返回值失败,%v"
,
err
),
c
)
}
else
{
//修改数据库后得到修改后的user并且返回供前端使用
//
修改数据库后得到修改后的user并且返回供前端使用
err
,
user
:=
service
.
UploadHeaderImg
(
uuid
,
filePath
)
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"修改数据库链接失败,%v"
,
err
),
c
)
...
...
server/initialize/db_table.go
浏览文件 @
97162680
...
...
@@ -5,7 +5,7 @@ import (
"gin-vue-admin/model"
)
//注册数据库表专用
//
注册数据库表专用
func
DBTables
()
{
db
:=
global
.
GVA_DB
db
.
AutoMigrate
(
model
.
SysUser
{},
...
...
server/initialize/mysql.go
浏览文件 @
97162680
...
...
@@ -7,7 +7,7 @@ import (
"os"
)
//初始化数据库并产生数据库全局变量
//
初始化数据库并产生数据库全局变量
func
Mysql
()
{
admin
:=
global
.
GVA_CONFIG
.
Mysql
if
db
,
err
:=
gorm
.
Open
(
"mysql"
,
admin
.
Username
+
":"
+
admin
.
Password
+
"@("
+
admin
.
Path
+
")/"
+
admin
.
Dbname
+
"?"
+
admin
.
Config
);
err
!=
nil
{
...
...
server/initialize/router.go
浏览文件 @
97162680
...
...
@@ -10,11 +10,11 @@ import (
"github.com/swaggo/gin-swagger/swaggerFiles"
)
//初始化总路由
//
初始化总路由
func
Routers
()
*
gin
.
Engine
{
var
Router
=
gin
.
Default
()
//Router.Use(middleware.LoadTls()) // 打开就能玩https了
//
Router.Use(middleware.LoadTls()) // 打开就能玩https了
global
.
GVA_LOG
.
Debug
(
"use middleware logger"
)
// 跨域
Router
.
Use
(
middleware
.
Cors
())
...
...
server/initialize/sqlite.go
浏览文件 @
97162680
...
...
@@ -4,20 +4,20 @@ package initialize
// 感谢 sqlitet提供者 [rikugun] 作者github: https://github.com/rikugun
//import (
// "fmt"
// "gin-vue-admin/global"
// "github.com/jinzhu/gorm"
// _ "github.com/jinzhu/gorm/dialects/sqlite"
//)
//
import (
//
"fmt"
//
"gin-vue-admin/global"
//
"github.com/jinzhu/gorm"
//
_ "github.com/jinzhu/gorm/dialects/sqlite"
//
)
//
//
//
初始化数据库并产生数据库全局变量
//func Sqlite() {
// admin := global.GVA_CONFIG.Sqlite
// if db, err := gorm.Open("sqlite3", fmt.Sprintf("%s?%s", admin.Path,admin.Config)); err != nil {
// global.GVA_LOG.Error("DEFAULTDB数据库启动异常", err)
// } else {
// global.GVA_DB = db
// global.GVA_DB.LogMode(admin.LogMode)
// }
//}
//
//
初始化数据库并产生数据库全局变量
//
func Sqlite() {
//
admin := global.GVA_CONFIG.Sqlite
//
if db, err := gorm.Open("sqlite3", fmt.Sprintf("%s?%s", admin.Path,admin.Config)); err != nil {
//
global.GVA_LOG.Error("DEFAULTDB数据库启动异常", err)
//
} else {
//
global.GVA_DB = db
//
global.GVA_DB.LogMode(admin.LogMode)
//
}
//
}
server/main.go
浏览文件 @
97162680
...
...
@@ -18,7 +18,7 @@ func main() {
switch
global
.
GVA_CONFIG
.
System
.
DbType
{
case
"mysql"
:
initialize
.
Mysql
()
//case "sqlite":
//
case "sqlite":
// initialize.Sqlite() // sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可
default
:
initialize
.
Mysql
()
...
...
server/middleware/casbin_rcba.go
浏览文件 @
97162680
...
...
@@ -8,19 +8,19 @@ import (
"github.com/gin-gonic/gin"
)
//拦截器
//
拦截器
func
CasbinHandler
()
gin
.
HandlerFunc
{
return
func
(
c
*
gin
.
Context
)
{
claims
,
_
:=
c
.
Get
(
"claims"
)
waitUse
:=
claims
.
(
*
request
.
CustomClaims
)
//获取请求的URI
//
获取请求的URI
obj
:=
c
.
Request
.
URL
.
RequestURI
()
//获取请求方法
//
获取请求方法
act
:=
c
.
Request
.
Method
//获取用户的角色
//
获取用户的角色
sub
:=
waitUse
.
AuthorityId
e
:=
service
.
Casbin
()
//判断策略中是否存在
//
判断策略中是否存在
if
global
.
GVA_CONFIG
.
System
.
Env
==
"develop"
||
e
.
Enforce
(
sub
,
obj
,
act
)
{
c
.
Next
()
}
else
{
...
...
server/middleware/cors.go
浏览文件 @
97162680
...
...
@@ -15,7 +15,7 @@ func Cors() gin.HandlerFunc {
c
.
Header
(
"Access-Control-Expose-Headers"
,
"Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type"
)
c
.
Header
(
"Access-Control-Allow-Credentials"
,
"true"
)
//放行所有OPTIONS方法
//
放行所有OPTIONS方法
if
method
==
"OPTIONS"
{
c
.
AbortWithStatus
(
http
.
StatusNoContent
)
}
...
...
server/middleware/jwt.go
浏览文件 @
97162680
...
...
@@ -60,10 +60,10 @@ type JWT struct {
}
var
(
TokenExpired
error
=
errors
.
New
(
"Token is expired"
)
TokenNotValidYet
error
=
errors
.
New
(
"Token not active yet"
)
TokenMalformed
error
=
errors
.
New
(
"That's not even a token"
)
TokenInvalid
error
=
errors
.
New
(
"Couldn't handle this token:"
)
TokenExpired
=
errors
.
New
(
"Token is expired"
)
TokenNotValidYet
=
errors
.
New
(
"Token not active yet"
)
TokenMalformed
=
errors
.
New
(
"That's not even a token"
)
TokenInvalid
=
errors
.
New
(
"Couldn't handle this token:"
)
)
func
NewJWT
()
*
JWT
{
...
...
@@ -72,13 +72,13 @@ func NewJWT() *JWT {
}
}
//创建一个token
//
创建一个token
func
(
j
*
JWT
)
CreateToken
(
claims
request
.
CustomClaims
)
(
string
,
error
)
{
token
:=
jwt
.
NewWithClaims
(
jwt
.
SigningMethodHS256
,
claims
)
return
token
.
SignedString
(
j
.
SigningKey
)
}
//解析 token
//
解析 token
func
(
j
*
JWT
)
ParseToken
(
tokenString
string
)
(
*
request
.
CustomClaims
,
error
)
{
token
,
err
:=
jwt
.
ParseWithClaims
(
tokenString
,
&
request
.
CustomClaims
{},
func
(
token
*
jwt
.
Token
)
(
i
interface
{},
e
error
)
{
return
j
.
SigningKey
,
nil
...
...
server/middleware/loadtls.go
浏览文件 @
97162680
...
...
@@ -16,7 +16,7 @@ func LoadTls() gin.HandlerFunc {
})
err
:=
middleware
.
Process
(
c
.
Writer
,
c
.
Request
)
if
err
!=
nil
{
//
如果出现错误,请不要继续。
//
如果出现错误,请不要继续
fmt
.
Println
(
err
)
return
}
...
...
server/model/request/sys_api.go
浏览文件 @
97162680
...
...
@@ -2,7 +2,7 @@ package request
import
"gin-vue-admin/model"
//api分页条件查询及排序结构体
//
api分页条件查询及排序结构体
type
SearchApiParams
struct
{
model
.
SysApi
PageInfo
...
...
server/model/sys_system.go
浏览文件 @
97162680
...
...
@@ -4,7 +4,7 @@ import (
"gin-vue-admin/config"
)
//配置文件结构体
//
配置文件结构体
type
System
struct
{
Config
config
.
Server
}
server/model/sys_workflow.go
浏览文件 @
97162680
...
...
@@ -4,7 +4,7 @@ import (
"github.com/jinzhu/gorm"
)
//工作流属性表
//
工作流属性表
type
SysWorkflow
struct
{
gorm
.
Model
WorkflowNickName
string
`json:"workflowNickName"`
// 工作流名称
...
...
server/model/sys_workflow_process.go
浏览文件 @
97162680
...
...
@@ -7,7 +7,7 @@ type SysWorkFlowProcess struct {
gorm
.
Model
ApplicationID
uint
// 当前工作流所属申请的ID
CurrentNode
string
// 当前进度节点
HistoricalNode
string
//上一个进度节点
HistoricalNode
string
//
上一个进度节点
CurrentUser
string
// 当前进度操作人
HistoricalUser
string
// 上一个进度的操作人
State
bool
// 状态 是否是正在进行的状态
...
...
server/router/exp_file_upload_and_download.go
浏览文件 @
97162680
...
...
@@ -7,7 +7,7 @@ import (
func
InitFileUploadAndDownloadRouter
(
Router
*
gin
.
RouterGroup
)
{
FileUploadAndDownloadGroup
:=
Router
.
Group
(
"fileUploadAndDownload"
)
//.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
//
.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
{
FileUploadAndDownloadGroup
.
POST
(
"/upload"
,
v1
.
UploadFile
)
// 上传文件
FileUploadAndDownloadGroup
.
POST
(
"/getFileList"
,
v1
.
GetFileList
)
// 获取上传文件列表
...
...
server/router/sys_api.go
浏览文件 @
97162680
...
...
@@ -9,11 +9,11 @@ import (
func
InitApiRouter
(
Router
*
gin
.
RouterGroup
)
{
ApiRouter
:=
Router
.
Group
(
"api"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
ApiRouter
.
POST
(
"createApi"
,
v1
.
CreateApi
)
//创建Api
ApiRouter
.
POST
(
"deleteApi"
,
v1
.
DeleteApi
)
//删除Api
ApiRouter
.
POST
(
"getApiList"
,
v1
.
GetApiList
)
//获取Api列表
ApiRouter
.
POST
(
"getApiById"
,
v1
.
GetApiById
)
//获取单条Api消息
ApiRouter
.
POST
(
"updateApi"
,
v1
.
UpdateApi
)
//更新api
ApiRouter
.
POST
(
"createApi"
,
v1
.
CreateApi
)
//
创建Api
ApiRouter
.
POST
(
"deleteApi"
,
v1
.
DeleteApi
)
//
删除Api
ApiRouter
.
POST
(
"getApiList"
,
v1
.
GetApiList
)
//
获取Api列表
ApiRouter
.
POST
(
"getApiById"
,
v1
.
GetApiById
)
//
获取单条Api消息
ApiRouter
.
POST
(
"updateApi"
,
v1
.
UpdateApi
)
//
更新api
ApiRouter
.
POST
(
"getAllApis"
,
v1
.
GetAllApis
)
// 获取所有api
}
}
server/router/sys_authority.go
浏览文件 @
97162680
...
...
@@ -9,11 +9,11 @@ import (
func
InitAuthorityRouter
(
Router
*
gin
.
RouterGroup
)
{
AuthorityRouter
:=
Router
.
Group
(
"authority"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
AuthorityRouter
.
POST
(
"createAuthority"
,
v1
.
CreateAuthority
)
//创建角色
AuthorityRouter
.
POST
(
"deleteAuthority"
,
v1
.
DeleteAuthority
)
//删除角色
AuthorityRouter
.
PUT
(
"updateAuthority"
,
v1
.
UpdateAuthority
)
//更新角色
AuthorityRouter
.
POST
(
"copyAuthority"
,
v1
.
CopyAuthority
)
//更新角色
AuthorityRouter
.
POST
(
"getAuthorityList"
,
v1
.
GetAuthorityList
)
//获取角色列表
AuthorityRouter
.
POST
(
"setDataAuthority"
,
v1
.
SetDataAuthority
)
//设置角色资源权限
AuthorityRouter
.
POST
(
"createAuthority"
,
v1
.
CreateAuthority
)
//
创建角色
AuthorityRouter
.
POST
(
"deleteAuthority"
,
v1
.
DeleteAuthority
)
//
删除角色
AuthorityRouter
.
PUT
(
"updateAuthority"
,
v1
.
UpdateAuthority
)
//
更新角色
AuthorityRouter
.
POST
(
"copyAuthority"
,
v1
.
CopyAuthority
)
//
更新角色
AuthorityRouter
.
POST
(
"getAuthorityList"
,
v1
.
GetAuthorityList
)
//
获取角色列表
AuthorityRouter
.
POST
(
"setDataAuthority"
,
v1
.
SetDataAuthority
)
//
设置角色资源权限
}
}
server/router/sys_auto_code.go
浏览文件 @
97162680
...
...
@@ -9,6 +9,6 @@ import (
func
InitAutoCodeRouter
(
Router
*
gin
.
RouterGroup
)
{
AutoCodeRouter
:=
Router
.
Group
(
"autoCode"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
AutoCodeRouter
.
POST
(
"createTemp"
,
v1
.
CreateTemp
)
//创建自动化代码
AutoCodeRouter
.
POST
(
"createTemp"
,
v1
.
CreateTemp
)
//
创建自动化代码
}
}
server/router/sys_jwt.go
浏览文件 @
97162680
...
...
@@ -9,6 +9,6 @@ import (
func
InitJwtRouter
(
Router
*
gin
.
RouterGroup
)
{
ApiRouter
:=
Router
.
Group
(
"jwt"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
ApiRouter
.
POST
(
"jsonInBlacklist"
,
v1
.
JsonInBlacklist
)
//jwt加入黑名单
ApiRouter
.
POST
(
"jsonInBlacklist"
,
v1
.
JsonInBlacklist
)
//
jwt加入黑名单
}
}
server/router/sys_menu.go
浏览文件 @
97162680
...
...
@@ -9,7 +9,7 @@ import (
func
InitMenuRouter
(
Router
*
gin
.
RouterGroup
)
(
R
gin
.
IRoutes
)
{
MenuRouter
:=
Router
.
Group
(
"menu"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
MenuRouter
.
POST
(
"getMenu"
,
v1
.
GetMenu
)
//获取菜单树
MenuRouter
.
POST
(
"getMenu"
,
v1
.
GetMenu
)
//
获取菜单树
MenuRouter
.
POST
(
"getMenuList"
,
v1
.
GetMenuList
)
// 分页获取基础menu列表
MenuRouter
.
POST
(
"addBaseMenu"
,
v1
.
AddBaseMenu
)
// 新增菜单
MenuRouter
.
POST
(
"getBaseMenuTree"
,
v1
.
GetBaseMenuTree
)
// 获取用户动态路由
...
...
@@ -17,7 +17,7 @@ func InitMenuRouter(Router *gin.RouterGroup) (R gin.IRoutes) {
MenuRouter
.
POST
(
"getMenuAuthority"
,
v1
.
GetMenuAuthority
)
// 获取指定角色menu
MenuRouter
.
POST
(
"deleteBaseMenu"
,
v1
.
DeleteBaseMenu
)
// 删除菜单
MenuRouter
.
POST
(
"updateBaseMenu"
,
v1
.
UpdateBaseMenu
)
// 更新菜单
MenuRouter
.
POST
(
"getBaseMenuById"
,
v1
.
GetBaseMenuById
)
//根据id获取菜单
MenuRouter
.
POST
(
"getBaseMenuById"
,
v1
.
GetBaseMenuById
)
//
根据id获取菜单
}
return
MenuRouter
}
server/router/sys_user.go
浏览文件 @
97162680
...
...
@@ -10,9 +10,9 @@ func InitUserRouter(Router *gin.RouterGroup) {
UserRouter
:=
Router
.
Group
(
"user"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
UserRouter
.
POST
(
"changePassword"
,
v1
.
ChangePassword
)
// 修改密码
UserRouter
.
POST
(
"uploadHeaderImg"
,
v1
.
UploadHeaderImg
)
//上传头像
UserRouter
.
POST
(
"uploadHeaderImg"
,
v1
.
UploadHeaderImg
)
//
上传头像
UserRouter
.
POST
(
"getUserList"
,
v1
.
GetUserList
)
// 分页获取用户列表
UserRouter
.
POST
(
"setUserAuthority"
,
v1
.
SetUserAuthority
)
//设置用户权限
UserRouter
.
DELETE
(
"deleteUser"
,
v1
.
DeleteUser
)
//删除用户
UserRouter
.
POST
(
"setUserAuthority"
,
v1
.
SetUserAuthority
)
//
设置用户权限
UserRouter
.
DELETE
(
"deleteUser"
,
v1
.
DeleteUser
)
//
删除用户
}
}
server/service/sys_authority.go
浏览文件 @
97162680
...
...
@@ -112,7 +112,7 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
var
authority
[]
model
.
SysAuthority
err
=
db
.
Limit
(
limit
)
.
Offset
(
offset
)
.
Preload
(
"DataAuthorityId"
)
.
Where
(
"parent_id = 0"
)
.
Find
(
&
authority
)
.
Error
if
len
(
authority
)
>
0
{
for
k
,
_
:=
range
authority
{
for
k
:=
range
authority
{
err
=
findChildrenAuthority
(
&
authority
[
k
])
}
}
...
...
@@ -166,7 +166,7 @@ func SetMenuAuthority(auth *model.SysAuthority) error {
func
findChildrenAuthority
(
authority
*
model
.
SysAuthority
)
(
err
error
)
{
err
=
global
.
GVA_DB
.
Preload
(
"DataAuthorityId"
)
.
Where
(
"parent_id = ?"
,
authority
.
AuthorityId
)
.
Find
(
&
authority
.
Children
)
.
Error
if
len
(
authority
.
Children
)
>
0
{
for
k
,
_
:=
range
authority
.
Children
{
for
k
:=
range
authority
.
Children
{
err
=
findChildrenAuthority
(
&
authority
.
Children
[
k
])
}
}
...
...
server/service/sys_auto_code.go
浏览文件 @
97162680
...
...
@@ -43,16 +43,16 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
if
err
!=
nil
{
return
err
}
//自动化总目录
//
自动化总目录
_autoCode
:=
"./autoCode/"
//自动化后台代码目录
//
自动化后台代码目录
_te
:=
"./autoCode/te/"
_dir
:=
_te
+
autoCode
.
PackageName
_modeldir
:=
_te
+
autoCode
.
PackageName
+
"/model"
_apidir
:=
_te
+
autoCode
.
PackageName
+
"/api"
_routerdir
:=
_te
+
autoCode
.
PackageName
+
"/router"
_servicedir
:=
_te
+
autoCode
.
PackageName
+
"/service"
//自动化前台代码目录
//
自动化前台代码目录
_fe
:=
"./autoCode/fe/"
_fe_dir
:=
_fe
+
autoCode
.
PackageName
_fe_apidir
:=
_fe
+
autoCode
.
PackageName
+
"/api"
...
...
server/service/sys_casbin.go
浏览文件 @
97162680
...
...
@@ -117,7 +117,7 @@ func Casbin() *casbin.Enforcer {
func
ParamsMatch
(
fullNameKey1
string
,
key2
string
)
bool
{
key1
:=
strings
.
Split
(
fullNameKey1
,
"?"
)[
0
]
//剥离路径后再使用casbin的keyMatch2
//
剥离路径后再使用casbin的keyMatch2
return
util
.
KeyMatch2
(
key1
,
key2
)
}
...
...
@@ -132,5 +132,5 @@ func ParamsMatchFunc(args ...interface{}) (interface{}, error) {
name1
:=
args
[
0
]
.
(
string
)
name2
:=
args
[
1
]
.
(
string
)
return
(
bool
)(
ParamsMatch
(
name1
,
name2
)
),
nil
return
ParamsMatch
(
name1
,
name2
),
nil
}
server/service/sys_menu.go
浏览文件 @
97162680
...
...
@@ -92,7 +92,7 @@ func getBaseChildrenList(menu *model.SysBaseMenu, treeMap map[string][]model.Sys
// @auth (2020/04/05 20:22)
// @param menu *model.SysBaseMenu
// @return err error
//增加基础路由
//
增加基础路由
func
AddBaseMenu
(
menu
model
.
SysBaseMenu
)
(
err
error
)
{
findOne
:=
global
.
GVA_DB
.
Where
(
"name = ?"
,
menu
.
Name
)
.
Find
(
&
model
.
SysBaseMenu
{})
.
Error
...
...
server/service/sys_user.go
浏览文件 @
97162680
...
...
@@ -18,9 +18,9 @@ import (
func
Register
(
u
model
.
SysUser
)
(
err
error
,
userInter
model
.
SysUser
)
{
var
user
model
.
SysUser
//判断用户名是否注册
//
判断用户名是否注册
notRegister
:=
global
.
GVA_DB
.
Where
(
"username = ?"
,
u
.
Username
)
.
First
(
&
user
)
.
RecordNotFound
()
//notRegister为false表明读取到了 不能注册
//
notRegister为false表明读取到了 不能注册
if
!
notRegister
{
return
errors
.
New
(
"用户名已注册"
),
userInter
}
else
{
...
...
@@ -60,7 +60,7 @@ func Login(u *model.SysUser) (err error, userInter *model.SysUser) {
func
ChangePassword
(
u
*
model
.
SysUser
,
newPassword
string
)
(
err
error
,
userInter
*
model
.
SysUser
)
{
var
user
model
.
SysUser
//后期修改jwt+password模式
//
TODO:
后期修改jwt+password模式
u
.
Password
=
utils
.
MD5V
([]
byte
(
u
.
Password
))
err
=
global
.
GVA_DB
.
Where
(
"username = ? AND password = ?"
,
u
.
Username
,
u
.
Password
)
.
First
(
&
user
)
.
Update
(
"password"
,
utils
.
MD5V
([]
byte
(
newPassword
)))
.
Error
return
err
,
u
...
...
server/utils/breakpoint_continue.go
浏览文件 @
97162680
...
...
@@ -56,7 +56,7 @@ func MakeFile(fileName string, FileMd5 string) (error, string) {
}
_
=
os
.
MkdirAll
(
finishDir
,
os
.
ModePerm
)
fd
,
_
:=
os
.
OpenFile
(
finishDir
+
fileName
,
os
.
O_RDWR
|
os
.
O_CREATE
|
os
.
O_APPEND
,
0644
)
for
k
,
_
:=
range
rd
{
for
k
:=
range
rd
{
content
,
_
:=
ioutil
.
ReadFile
(
breakpointDir
+
FileMd5
+
"/"
+
fileName
+
"_"
+
strconv
.
Itoa
(
k
))
_
,
err
=
fd
.
Write
(
content
)
if
err
!=
nil
{
...
...
server/utils/des.go
浏览文件 @
97162680
...
...
@@ -37,5 +37,4 @@ func DecryptDES(src []byte) []byte {
blockmode
.
CryptBlocks
(
src
,
src
)
src
=
unpadding
(
src
)
return
src
}
server/utils/directory.go
浏览文件 @
97162680
...
...
@@ -32,19 +32,19 @@ func CreateDir(dirs ...string) (err error) {
for
_
,
v
:=
range
dirs
{
exist
,
err
:=
PathExists
(
v
)
if
err
!=
nil
{
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
//
log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
return
err
}
if
exist
{
//log.L.Info(fmt.Sprintf("has dir![%v]\n"+_dir))
//
log.L.Info(fmt.Sprintf("has dir![%v]\n"+_dir))
}
else
{
//log.L.Info(fmt.Sprintf("no dir![%v]\n"+_dir))
//
log.L.Info(fmt.Sprintf("no dir![%v]\n"+_dir))
// 创建文件夹
err
=
os
.
Mkdir
(
v
,
os
.
ModePerm
)
if
err
!=
nil
{
//log.L.Error(fmt.Sprintf("mkdir error![%v]\n",err))
//
log.L.Error(fmt.Sprintf("mkdir error![%v]\n",err))
}
else
{
//log.L.Info("mkdir success!\n")
//
log.L.Info("mkdir success!\n")
}
}
}
...
...
server/utils/upload.go
浏览文件 @
97162680
...
...
@@ -55,7 +55,7 @@ func DeleteFile(key string) error {
}
// 指定空间所在的区域,如果不指定将自动探测
// 如果没有特殊需求,默认不需要指定
//cfg.Zone=&storage.ZoneHuabei
//
cfg.Zone=&storage.ZoneHuabei
bucketManager
:=
storage
.
NewBucketManager
(
mac
,
&
cfg
)
err
:=
bucketManager
.
Delete
(
global
.
GVA_CONFIG
.
Qiniu
.
Bucket
,
key
)
if
err
!=
nil
{
...
...
server/utils/validator.go
浏览文件 @
97162680
...
...
@@ -28,32 +28,32 @@ func NotEmpty() string {
return
"notEmpty"
}
//小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Lt
(
mark
string
)
string
{
return
"lt="
+
mark
}
//小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Le
(
mark
string
)
string
{
return
"le="
+
mark
}
//等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Eq
(
mark
string
)
string
{
return
"eq="
+
mark
}
//不等于入参(!=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
不等于入参(!=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Ne
(
mark
string
)
string
{
return
"ne="
+
mark
}
//大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Ge
(
mark
string
)
string
{
return
"ge="
+
mark
}
//大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
//
大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
func
Gt
(
mark
string
)
string
{
return
"gt="
+
mark
}
...
...
@@ -70,14 +70,14 @@ func Verify(st interface{}, roleMap Rules) (err error) {
}
typ
:=
reflect
.
TypeOf
(
st
)
val
:=
reflect
.
ValueOf
(
st
)
//获取reflect.Type类型
val
:=
reflect
.
ValueOf
(
st
)
//
获取reflect.Type类型
kd
:=
val
.
Kind
()
//获取到st对应的类别
kd
:=
val
.
Kind
()
//
获取到st对应的类别
if
kd
!=
reflect
.
Struct
{
return
errors
.
New
(
"expect struct"
)
}
num
:=
val
.
NumField
()
//遍历结构体的所有字段
//
遍历结构体的所有字段
for
i
:=
0
;
i
<
num
;
i
++
{
tagVal
:=
typ
.
Field
(
i
)
val
:=
val
.
Field
(
i
)
...
...
server/utils/zipfiles.go
浏览文件 @
97162680
...
...
@@ -38,7 +38,7 @@ func ZipFiles(filename string, files []string, oldform, newform string) error {
return
err
}
//使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面
//
使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面
header
.
Name
=
strings
.
Replace
(
file
,
oldform
,
newform
,
-
1
)
// 优化压缩
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录