Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
0c461a94
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
332
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,发现更多精彩内容 >>
提交
0c461a94
编写于
4月 04, 2021
作者:
C
closetool
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: casbin gorm-adapter has no sqlite3 support
Signed-off-by:
N
closetool
<
c299999999@qq.com
>
上级
fd4af6e7
变更
33
展开全部
隐藏空白更改
内联
并排
Showing
33 changed file
with
229 addition
and
240 deletion
+229
-240
server/api/v1/exa_breakpoint_continue.go
server/api/v1/exa_breakpoint_continue.go
+2
-2
server/api/v1/exa_simple_uploader.go
server/api/v1/exa_simple_uploader.go
+1
-1
server/api/v1/sys_api.go
server/api/v1/sys_api.go
+2
-3
server/api/v1/sys_casbin.go
server/api/v1/sys_casbin.go
+0
-1
server/api/v1/sys_menu.go
server/api/v1/sys_menu.go
+2
-2
server/config/excel.go
server/config/excel.go
+1
-1
server/config/gorm.go
server/config/gorm.go
+1
-1
server/config/redis.go
server/config/redis.go
+1
-1
server/core/server_other.go
server/core/server_other.go
+1
-1
server/core/server_win.go
server/core/server_win.go
+1
-1
server/global/global.go
server/global/global.go
+1
-1
server/go.mod
server/go.mod
+4
-8
server/initialize/redis.go
server/initialize/redis.go
+1
-1
server/model/request/sys_dictionary.go
server/model/request/sys_dictionary.go
+4
-4
server/model/request/sys_dictionary_detail.go
server/model/request/sys_dictionary_detail.go
+4
-4
server/model/sys_authority.go
server/model/sys_authority.go
+1
-1
server/router/sys_api.go
server/router/sys_api.go
+6
-6
server/router/sys_system.go
server/router/sys_system.go
+1
-1
server/service/exa_excel_parse.go
server/service/exa_excel_parse.go
+22
-22
server/service/sys_api.go
server/service/sys_api.go
+3
-5
server/service/sys_casbin.go
server/service/sys_casbin.go
+3
-3
server/service/sys_system.go
server/service/sys_system.go
+3
-4
server/service/sys_user.go
server/service/sys_user.go
+2
-3
server/source/api.go
server/source/api.go
+0
-2
server/source/casbin.go
server/source/casbin.go
+149
-148
server/source/file.go
server/source/file.go
+1
-1
server/utils/constant.go
server/utils/constant.go
+1
-1
server/utils/directory.go
server/utils/directory.go
+1
-1
server/utils/rotatelogs_unix.go
server/utils/rotatelogs_unix.go
+1
-1
server/utils/rotatelogs_windows.go
server/utils/rotatelogs_windows.go
+1
-1
server/utils/server.go
server/utils/server.go
+4
-5
server/utils/upload/local.go
server/utils/upload/local.go
+1
-0
server/utils/upload/qiniu.go
server/utils/upload/qiniu.go
+3
-3
未找到文件。
server/api/v1/exa_breakpoint_continue.go
浏览文件 @
0c461a94
...
...
@@ -82,7 +82,7 @@ func FindFile(c *gin.Context) {
global
.
GVA_LOG
.
Error
(
"查找失败!"
,
zap
.
Any
(
"err"
,
err
))
response
.
FailWithMessage
(
"查找失败"
,
c
)
}
else
{
response
.
OkWithDetailed
(
response
.
FileResponse
{
File
:
file
},
"查找成功"
,
c
)
response
.
OkWithDetailed
(
response
.
FileResponse
{
File
:
file
},
"查找成功"
,
c
)
}
}
...
...
@@ -122,7 +122,7 @@ func RemoveChunk(c *gin.Context) {
err
=
service
.
DeleteFileChunk
(
fileMd5
,
fileName
,
filePath
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"缓存切片删除失败!"
,
zap
.
Any
(
"err"
,
err
))
response
.
FailWithDetailed
(
response
.
FilePathResponse
{
FilePath
:
filePath
},
"缓存切片删除失败"
,
c
)
response
.
FailWithDetailed
(
response
.
FilePathResponse
{
FilePath
:
filePath
},
"缓存切片删除失败"
,
c
)
}
else
{
response
.
OkWithDetailed
(
response
.
FilePathResponse
{
FilePath
:
filePath
},
"缓存切片删除成功"
,
c
)
}
...
...
server/api/v1/exa_simple_uploader.go
浏览文件 @
0c461a94
...
...
@@ -69,7 +69,7 @@ func CheckFileMd5(c *gin.Context) {
response
.
OkWithDetailed
(
gin
.
H
{
"chunks"
:
chunks
,
"isDone"
:
isDone
,
},
"查询成功"
,
c
)
},
"查询成功"
,
c
)
}
}
...
...
server/api/v1/sys_api.go
浏览文件 @
0c461a94
...
...
@@ -148,7 +148,6 @@ func GetAllApis(c *gin.Context) {
}
}
// @Tags SysApi
// @Summary 删除选中Api
// @Security ApiKeyAuth
...
...
@@ -164,6 +163,6 @@ func DeleteApisByIds(c *gin.Context) {
global
.
GVA_LOG
.
Error
(
"删除失败!"
,
zap
.
Any
(
"err"
,
err
))
response
.
FailWithMessage
(
"删除失败"
,
c
)
}
else
{
response
.
OkWithMessage
(
"删除成功"
,
c
)
response
.
OkWithMessage
(
"删除成功"
,
c
)
}
}
\ No newline at end of file
}
server/api/v1/sys_casbin.go
浏览文件 @
0c461a94
...
...
@@ -51,4 +51,3 @@ func GetPolicyPathByAuthorityId(c *gin.Context) {
paths
:=
service
.
GetPolicyPathByAuthorityId
(
casbin
.
AuthorityId
)
response
.
OkWithDetailed
(
response
.
PolicyPathResponse
{
Paths
:
paths
},
"获取成功"
,
c
)
}
server/api/v1/sys_menu.go
浏览文件 @
0c461a94
...
...
@@ -214,6 +214,6 @@ func GetMenuList(c *gin.Context) {
Total
:
total
,
Page
:
pageInfo
.
Page
,
PageSize
:
pageInfo
.
PageSize
,
},
"获取成功"
,
c
)
},
"获取成功"
,
c
)
}
}
\ No newline at end of file
}
server/config/excel.go
浏览文件 @
0c461a94
...
...
@@ -2,4 +2,4 @@ package config
type
Excel
struct
{
Dir
string
`mapstructure:"dir" json:"dir" yaml:"dir"`
}
\ No newline at end of file
}
server/config/gorm.go
浏览文件 @
0c461a94
...
...
@@ -14,4 +14,4 @@ type Mysql struct {
func
(
m
*
Mysql
)
Dsn
()
string
{
return
m
.
Username
+
":"
+
m
.
Password
+
"@tcp("
+
m
.
Path
+
")/"
+
m
.
Dbname
+
"?"
+
m
.
Config
}
\ No newline at end of file
}
server/config/redis.go
浏览文件 @
0c461a94
...
...
@@ -4,4 +4,4 @@ type Redis struct {
DB
int
`mapstructure:"db" json:"db" yaml:"db"`
Addr
string
`mapstructure:"addr" json:"addr" yaml:"addr"`
Password
string
`mapstructure:"password" json:"password" yaml:"password"`
}
\ No newline at end of file
}
server/core/server_other.go
浏览文件 @
0c461a94
...
...
@@ -14,4 +14,4 @@ func initServer(address string, router *gin.Engine) server {
s
.
WriteTimeout
=
10
*
time
.
Second
s
.
MaxHeaderBytes
=
1
<<
20
return
s
}
\ No newline at end of file
}
server/core/server_win.go
浏览文件 @
0c461a94
...
...
@@ -16,4 +16,4 @@ func initServer(address string, router *gin.Engine) server {
WriteTimeout
:
10
*
time
.
Second
,
MaxHeaderBytes
:
1
<<
20
,
}
}
\ No newline at end of file
}
server/global/global.go
浏览文件 @
0c461a94
...
...
@@ -15,5 +15,5 @@ var (
GVA_CONFIG
config
.
Server
GVA_VP
*
viper
.
Viper
//GVA_LOG *oplogging.Logger
GVA_LOG
*
zap
.
Logger
GVA_LOG
*
zap
.
Logger
)
server/go.mod
浏览文件 @
0c461a94
...
...
@@ -8,9 +8,8 @@ require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/casbin/casbin v1.9.1
github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/casbin/casbin/v2 v2.25.6
github.com/casbin/gorm-adapter/v3 v3.2.5
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
github.com/fsnotify/fsnotify v1.4.9
...
...
@@ -30,7 +29,6 @@ require (
github.com/lestrrat-go/file-rotatelogs v2.3.0+incompatible
github.com/lestrrat-go/strftime v1.0.3 // indirect
github.com/mailru/easyjson v0.7.1 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/mojocn/base64Captcha v1.3.1
github.com/onsi/ginkgo v1.7.0 // indirect
...
...
@@ -42,8 +40,8 @@ require (
github.com/shirou/gopsutil v3.21.1+incompatible
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.1
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/swag v1.6.7
...
...
@@ -56,8 +54,6 @@ require (
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gorm.io/driver/mysql v
0.3.0
gorm.io/driver/mysql v
1.0.1
gorm.io/gorm v1.20.9
)
replace github.com/casbin/gorm-adapter/v3 => github.com/casbin/gorm-adapter/v3 v3.0.2
server/initialize/redis.go
浏览文件 @
0c461a94
...
...
@@ -17,7 +17,7 @@ func Redis() {
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"redis connect ping failed, err:"
,
zap
.
Any
(
"err"
,
err
))
}
else
{
global
.
GVA_LOG
.
Info
(
"redis connect ping response:"
,
zap
.
String
(
"pong"
,
pong
))
global
.
GVA_LOG
.
Info
(
"redis connect ping response:"
,
zap
.
String
(
"pong"
,
pong
))
global
.
GVA_REDIS
=
client
}
}
server/model/request/sys_dictionary.go
浏览文件 @
0c461a94
...
...
@@ -2,7 +2,7 @@ package request
import
"gin-vue-admin/model"
type
SysDictionarySearch
struct
{
model
.
SysDictionary
PageInfo
}
\ No newline at end of file
type
SysDictionarySearch
struct
{
model
.
SysDictionary
PageInfo
}
server/model/request/sys_dictionary_detail.go
浏览文件 @
0c461a94
...
...
@@ -2,7 +2,7 @@ package request
import
"gin-vue-admin/model"
type
SysDictionaryDetailSearch
struct
{
model
.
SysDictionaryDetail
PageInfo
}
\ No newline at end of file
type
SysDictionaryDetailSearch
struct
{
model
.
SysDictionaryDetail
PageInfo
}
server/model/sys_authority.go
浏览文件 @
0c461a94
...
...
@@ -14,5 +14,5 @@ type SysAuthority struct {
DataAuthorityId
[]
SysAuthority
`json:"dataAuthorityId" gorm:"many2many:sys_data_authority_id"`
Children
[]
SysAuthority
`json:"children" gorm:"-"`
SysBaseMenus
[]
SysBaseMenu
`json:"menus" gorm:"many2many:sys_authority_menus;"`
DefaultRouter
string
`json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"`
DefaultRouter
string
`json:"defaultRouter" gorm:"comment:默认菜单;default:dashboard"`
}
server/router/sys_api.go
浏览文件 @
0c461a94
...
...
@@ -9,12 +9,12 @@ import (
func
InitApiRouter
(
Router
*
gin
.
RouterGroup
)
{
ApiRouter
:=
Router
.
Group
(
"api"
)
.
Use
(
middleware
.
OperationRecord
())
{
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
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
ApiRouter
.
DELETE
(
"deleteApisByIds"
,
v1
.
DeleteApisByIds
)
// 删除选中api
}
}
server/router/sys_system.go
浏览文件 @
0c461a94
...
...
@@ -12,6 +12,6 @@ func InitSystemRouter(Router *gin.RouterGroup) {
SystemRouter
.
POST
(
"getSystemConfig"
,
v1
.
GetSystemConfig
)
// 获取配置文件内容
SystemRouter
.
POST
(
"setSystemConfig"
,
v1
.
SetSystemConfig
)
// 设置配置文件内容
SystemRouter
.
POST
(
"getServerInfo"
,
v1
.
GetServerInfo
)
// 获取服务器信息
SystemRouter
.
POST
(
"reloadSystem"
,
v1
.
ReloadSystem
)
// 重启服务
SystemRouter
.
POST
(
"reloadSystem"
,
v1
.
ReloadSystem
)
// 重启服务
}
}
server/service/exa_excel_parse.go
浏览文件 @
0c461a94
...
...
@@ -11,29 +11,29 @@ import (
func
ParseInfoList2Excel
(
infoList
[]
model
.
SysBaseMenu
,
filePath
string
)
error
{
excel
:=
excelize
.
NewFile
()
excel
.
SetSheetRow
(
"Sheet1"
,
"A1"
,
&
[]
string
{
"ID"
,
"路由Name"
,
"路由Path"
,
"是否隐藏"
,
"父节点"
,
"排序"
,
"文件名称"
})
for
i
,
menu
:=
range
infoList
{
axis
:=
fmt
.
Sprintf
(
"A%d"
,
i
+
2
)
excel
.
SetSheetRow
(
"Sheet1"
,
axis
,
&
[]
interface
{}{
menu
.
ID
,
menu
.
Name
,
menu
.
Path
,
menu
.
Hidden
,
menu
.
ParentId
,
menu
.
Sort
,
menu
.
Component
,
})
}
excel
.
SetSheetRow
(
"Sheet1"
,
"A1"
,
&
[]
string
{
"ID"
,
"路由Name"
,
"路由Path"
,
"是否隐藏"
,
"父节点"
,
"排序"
,
"文件名称"
})
for
i
,
menu
:=
range
infoList
{
axis
:=
fmt
.
Sprintf
(
"A%d"
,
i
+
2
)
excel
.
SetSheetRow
(
"Sheet1"
,
axis
,
&
[]
interface
{}{
menu
.
ID
,
menu
.
Name
,
menu
.
Path
,
menu
.
Hidden
,
menu
.
ParentId
,
menu
.
Sort
,
menu
.
Component
,
})
}
excel
.
SaveAs
(
filePath
)
return
nil
}
func
ParseExcel2InfoList
()
([]
model
.
SysBaseMenu
,
error
)
{
skipHeader
:=
true
fixedHeader
:=
[]
string
{
"ID"
,
"路由Name"
,
"路由Path"
,
"是否隐藏"
,
"父节点"
,
"排序"
,
"文件名称"
}
file
,
err
:=
excelize
.
OpenFile
(
global
.
GVA_CONFIG
.
Excel
.
Dir
+
"ExcelImport.xlsx"
)
fixedHeader
:=
[]
string
{
"ID"
,
"路由Name"
,
"路由Path"
,
"是否隐藏"
,
"父节点"
,
"排序"
,
"文件名称"
}
file
,
err
:=
excelize
.
OpenFile
(
global
.
GVA_CONFIG
.
Excel
.
Dir
+
"ExcelImport.xlsx"
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
menus
:=
make
([]
model
.
SysBaseMenu
,
0
)
rows
,
err
:=
file
.
Rows
(
"Sheet1"
)
...
...
@@ -63,11 +63,11 @@ func ParseExcel2InfoList() ([]model.SysBaseMenu, error) {
GVA_MODEL
:
global
.
GVA_MODEL
{
ID
:
uint
(
id
),
},
Name
:
row
[
1
],
Path
:
row
[
2
],
Hidden
:
hidden
,
ParentId
:
row
[
4
],
Sort
:
sort
,
Name
:
row
[
1
],
Path
:
row
[
2
],
Hidden
:
hidden
,
ParentId
:
row
[
4
],
Sort
:
sort
,
Component
:
row
[
6
],
}
menus
=
append
(
menus
,
menu
)
...
...
@@ -88,4 +88,4 @@ func compareStrSlice(a, b []string) bool {
}
}
return
true
}
\ No newline at end of file
}
server/service/sys_api.go
浏览文件 @
0c461a94
...
...
@@ -5,6 +5,7 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gorm.io/gorm"
)
...
...
@@ -130,8 +131,6 @@ func UpdateApi(api model.SysApi) (err error) {
return
err
}
//@author: [piexlmax](https://github.com/piexlmax)
//@function: DeleteApis
//@description: 删除选中API
...
...
@@ -139,7 +138,6 @@ func UpdateApi(api model.SysApi) (err error) {
//@return: err error
func
DeleteApisByIds
(
ids
request
.
IdsReq
)
(
err
error
)
{
err
=
global
.
GVA_DB
.
Delete
(
&
[]
model
.
SysApi
{},
"id in ?"
,
ids
.
Ids
)
.
Error
err
=
global
.
GVA_DB
.
Delete
(
&
[]
model
.
SysApi
{},
"id in ?"
,
ids
.
Ids
)
.
Error
return
err
return
}
\ No newline at end of file
}
server/service/sys_casbin.go
浏览文件 @
0c461a94
...
...
@@ -5,11 +5,12 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"github.com/casbin/casbin/util"
"strings"
"github.com/casbin/casbin/v2"
"github.com/casbin/casbin/v2/util"
gormadapter
"github.com/casbin/gorm-adapter/v3"
_
"github.com/go-sql-driver/mysql"
"strings"
)
//@author: [piexlmax](https://github.com/piexlmax)
...
...
@@ -58,7 +59,6 @@ func UpdateCasbinApi(oldPath string, newPath string, oldMethod string, newMethod
//@param: authorityId string
//@return: pathMaps []request.CasbinInfo
func
GetPolicyPathByAuthorityId
(
authorityId
string
)
(
pathMaps
[]
request
.
CasbinInfo
)
{
e
:=
Casbin
()
list
:=
e
.
GetFilteredPolicy
(
0
,
authorityId
)
...
...
server/service/sys_system.go
浏览文件 @
0c461a94
...
...
@@ -41,19 +41,18 @@ func SetSystemConfig(system model.System) (err error) {
func
GetServerInfo
()
(
server
*
utils
.
Server
,
err
error
)
{
var
s
utils
.
Server
s
.
Os
=
utils
.
InitOS
()
if
s
.
Cpu
,
err
=
utils
.
InitCPU
();
err
!=
nil
{
if
s
.
Cpu
,
err
=
utils
.
InitCPU
();
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"func utils.InitCPU() Failed!"
,
zap
.
String
(
"err"
,
err
.
Error
()))
return
&
s
,
err
}
if
s
.
Rrm
,
err
=
utils
.
InitRAM
();
err
!=
nil
{
if
s
.
Rrm
,
err
=
utils
.
InitRAM
();
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"func utils.InitRAM() Failed!"
,
zap
.
String
(
"err"
,
err
.
Error
()))
return
&
s
,
err
}
if
s
.
Disk
,
err
=
utils
.
InitDisk
();
err
!=
nil
{
if
s
.
Disk
,
err
=
utils
.
InitDisk
();
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"func utils.InitDisk() Failed!"
,
zap
.
String
(
"err"
,
err
.
Error
()))
return
&
s
,
err
}
return
&
s
,
nil
}
server/service/sys_user.go
浏览文件 @
0c461a94
...
...
@@ -10,7 +10,6 @@ import (
"gorm.io/gorm"
)
//@author: [piexlmax](https://github.com/piexlmax)
//@function: Register
//@description: 用户注册
...
...
@@ -125,8 +124,8 @@ func FindUserById(id int) (err error, user *model.SysUser) {
func
FindUserByUuid
(
uuid
string
)
(
err
error
,
user
*
model
.
SysUser
)
{
var
u
model
.
SysUser
if
err
=
global
.
GVA_DB
.
Where
(
"`uuid` = ?"
,
uuid
)
.
First
(
&
u
)
.
Error
;
err
!=
nil
{
if
err
=
global
.
GVA_DB
.
Where
(
"`uuid` = ?"
,
uuid
)
.
First
(
&
u
)
.
Error
;
err
!=
nil
{
return
errors
.
New
(
"用户不存在"
),
&
u
}
return
nil
,
&
u
}
\ No newline at end of file
}
server/source/api.go
浏览文件 @
0c461a94
...
...
@@ -88,8 +88,6 @@ var apis = []model.SysApi{
{
global
.
GVA_MODEL
{
ID
:
85
,
CreatedAt
:
time
.
Now
(),
UpdatedAt
:
time
.
Now
()},
"/api/deleteApisByIds"
,
"批量删除api"
,
"api"
,
"DELETE"
},
}
//@author: [SliverHorn](https://github.com/SliverHorn)
//@description: sys_apis 表数据初始化
func
(
a
*
api
)
Init
()
error
{
...
...
server/source/casbin.go
浏览文件 @
0c461a94
此差异已折叠。
点击以展开。
server/source/file.go
浏览文件 @
0c461a94
...
...
@@ -31,4 +31,4 @@ func (f *file) Init() error {
color
.
Info
.
Println
(
"
\n
[Mysql] --> exa_file_upload_and_downloads 表初始数据成功!"
)
return
nil
})
}
\ No newline at end of file
}
server/utils/constant.go
浏览文件 @
0c461a94
package
utils
const
(
ConfigEnv
=
"GVA_CONFIG"
ConfigEnv
=
"GVA_CONFIG"
ConfigFile
=
"config.yaml"
)
server/utils/directory.go
浏览文件 @
0c461a94
...
...
@@ -39,7 +39,7 @@ func CreateDir(dirs ...string) (err error) {
global
.
GVA_LOG
.
Debug
(
"create directory"
+
v
)
err
=
os
.
MkdirAll
(
v
,
os
.
ModePerm
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"create directory"
+
v
,
zap
.
Any
(
" error:"
,
err
))
global
.
GVA_LOG
.
Error
(
"create directory"
+
v
,
zap
.
Any
(
" error:"
,
err
))
}
}
}
...
...
server/utils/rotatelogs_unix.go
浏览文件 @
0c461a94
...
...
@@ -27,4 +27,4 @@ func GetWriteSyncer() (zapcore.WriteSyncer, error) {
return
zapcore
.
NewMultiWriteSyncer
(
zapcore
.
AddSync
(
os
.
Stdout
),
zapcore
.
AddSync
(
fileWriter
)),
err
}
return
zapcore
.
AddSync
(
fileWriter
),
err
}
\ No newline at end of file
}
server/utils/rotatelogs_windows.go
浏览文件 @
0c461a94
...
...
@@ -24,4 +24,4 @@ func GetWriteSyncer() (zapcore.WriteSyncer, error) {
return
zapcore
.
NewMultiWriteSyncer
(
zapcore
.
AddSync
(
os
.
Stdout
),
zapcore
.
AddSync
(
fileWriter
)),
err
}
return
zapcore
.
AddSync
(
fileWriter
),
err
}
\ No newline at end of file
}
server/utils/server.go
浏览文件 @
0c461a94
...
...
@@ -35,7 +35,6 @@ type Cpu struct {
Cores
int
`json:"cores"`
}
type
Rrm
struct
{
UsedMB
int
`json:"usedMb"`
TotalMB
int
`json:"totalMb"`
...
...
@@ -89,9 +88,9 @@ func InitCPU() (c Cpu, err error) {
//@return: r Rrm, err error
func
InitRAM
()
(
r
Rrm
,
err
error
)
{
if
u
,
err
:=
mem
.
VirtualMemory
();
err
!=
nil
{
if
u
,
err
:=
mem
.
VirtualMemory
();
err
!=
nil
{
return
r
,
err
}
else
{
}
else
{
r
.
UsedMB
=
int
(
u
.
Used
)
/
MB
r
.
TotalMB
=
int
(
u
.
Total
)
/
MB
r
.
UsedPercent
=
int
(
u
.
UsedPercent
)
...
...
@@ -105,7 +104,7 @@ func InitRAM() (r Rrm, err error) {
//@return: d Disk, err error
func
InitDisk
()
(
d
Disk
,
err
error
)
{
if
u
,
err
:=
disk
.
Usage
(
"/"
);
err
!=
nil
{
if
u
,
err
:=
disk
.
Usage
(
"/"
);
err
!=
nil
{
return
d
,
err
}
else
{
d
.
UsedMB
=
int
(
u
.
Used
)
/
MB
...
...
@@ -115,4 +114,4 @@ func InitDisk() (d Disk, err error) {
d
.
UsedPercent
=
int
(
u
.
UsedPercent
)
}
return
d
,
nil
}
\ No newline at end of file
}
server/utils/upload/local.go
浏览文件 @
0c461a94
package
upload
import
(
"errors"
"gin-vue-admin/global"
...
...
server/utils/upload/qiniu.go
浏览文件 @
0c461a94
...
...
@@ -60,7 +60,7 @@ func (*Qiniu) DeleteFile(key string) error {
mac
:=
qbox
.
NewMac
(
global
.
GVA_CONFIG
.
Qiniu
.
AccessKey
,
global
.
GVA_CONFIG
.
Qiniu
.
SecretKey
)
cfg
:=
qiniuConfig
()
bucketManager
:=
storage
.
NewBucketManager
(
mac
,
cfg
)
if
err
:=
bucketManager
.
Delete
(
global
.
GVA_CONFIG
.
Qiniu
.
Bucket
,
key
);
err
!=
nil
{
if
err
:=
bucketManager
.
Delete
(
global
.
GVA_CONFIG
.
Qiniu
.
Bucket
,
key
);
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"function bucketManager.Delete() Filed"
,
zap
.
Any
(
"err"
,
err
.
Error
()))
return
errors
.
New
(
"function bucketManager.Delete() Filed, err:"
+
err
.
Error
())
}
...
...
@@ -76,7 +76,7 @@ func (*Qiniu) DeleteFile(key string) error {
func
qiniuConfig
()
*
storage
.
Config
{
cfg
:=
storage
.
Config
{
UseHTTPS
:
global
.
GVA_CONFIG
.
Qiniu
.
UseHTTPS
,
UseHTTPS
:
global
.
GVA_CONFIG
.
Qiniu
.
UseHTTPS
,
UseCdnDomains
:
global
.
GVA_CONFIG
.
Qiniu
.
UseCdnDomains
,
}
switch
global
.
GVA_CONFIG
.
Qiniu
.
Zone
{
// 根据配置文件进行初始化空间对应的机房
...
...
@@ -92,4 +92,4 @@ func qiniuConfig() *storage.Config {
cfg
.
Zone
=
&
storage
.
ZoneXinjiapo
}
return
&
cfg
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录