Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞鱼0526
gin-vue-admin
提交
baafb593
G
gin-vue-admin
项目概览
飞鱼0526
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
2
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,发现更多精彩内容 >>
提交
baafb593
编写于
9月 01, 2021
作者:
S
songzhibin97
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into gva_gormv2_dev
上级
2fb22c69
c81293a0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
37 addition
and
10 deletion
+37
-10
server/core/viper.go
server/core/viper.go
+11
-0
server/global/global.go
server/global/global.go
+3
-0
server/go.mod
server/go.mod
+1
-4
server/service/system/jwt_black_list.go
server/service/system/jwt_black_list.go
+22
-6
未找到文件。
server/core/viper.go
浏览文件 @
baafb593
...
...
@@ -5,6 +5,11 @@ import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/service/system"
"github.com/songzhibin97/gkit/cache/local_cache"
"github.com/flipped-aurora/gin-vue-admin/server/global"
_
"github.com/flipped-aurora/gin-vue-admin/server/packfile"
...
...
@@ -54,5 +59,11 @@ func Viper(path ...string) *viper.Viper {
fmt
.
Println
(
err
)
}
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
_
=
filepath
.
Abs
(
".."
)
global
.
BlackCache
=
local_cache
.
NewCache
(
local_cache
.
SetDefaultExpire
(
time
.
Duration
(
global
.
GVA_CONFIG
.
JWT
.
ExpiresTime
)))
// 从db加载jwt数据
if
global
.
GVA_DB
!=
nil
{
system
.
LoadAll
()
}
return
v
}
server/global/global.go
浏览文件 @
baafb593
...
...
@@ -2,6 +2,7 @@ package global
import
(
"github.com/flipped-aurora/gin-vue-admin/server/utils/timer"
"github.com/songzhibin97/gkit/cache/local_cache"
"golang.org/x/sync/singleflight"
...
...
@@ -23,4 +24,6 @@ var (
GVA_LOG
*
zap
.
Logger
GVA_Timer
timer
.
Timer
=
timer
.
NewTimerTask
()
GVA_Concurrency_Control
=
&
singleflight
.
Group
{}
BlackCache
local_cache
.
Cache
)
server/go.mod
浏览文件 @
baafb593
...
...
@@ -3,7 +3,6 @@ module github.com/flipped-aurora/gin-vue-admin/server
go 1.16
require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
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
...
...
@@ -15,7 +14,6 @@ require (
github.com/fsnotify/fsnotify v1.4.9
github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6
github.com/gin-gonic/gin v1.6.3
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.3 // indirect
github.com/go-openapi/swag v0.19.15 // indirect
...
...
@@ -32,11 +30,11 @@ require (
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/mojocn/base64Captcha v1.3.1
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/qiniu/api.v7/v7 v7.4.1
github.com/robfig/cron/v3 v3.0.1
github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil v3.21.1+incompatible
github.com/songzhibin97/gkit v1.1.1
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
...
...
@@ -52,7 +50,6 @@ require (
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/tools v0.1.5 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/ini.v1 v1.55.0 // indirect
gorm.io/driver/mysql v1.0.1
gorm.io/gorm v1.20.7
...
...
server/service/system/jwt_black_list.go
浏览文件 @
baafb593
...
...
@@ -2,13 +2,10 @@ package system
import
(
"context"
"errors"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/system"
"gorm.io/gorm"
)
type
JwtService
struct
{
...
...
@@ -22,6 +19,11 @@ type JwtService struct {
func
(
jwtService
*
JwtService
)
JsonInBlacklist
(
jwtList
system
.
JwtBlacklist
)
(
err
error
)
{
err
=
global
.
GVA_DB
.
Create
(
&
jwtList
)
.
Error
if
err
!=
nil
{
return
}
global
.
BlackCache
.
SetDefault
(
jwtList
.
Jwt
,
struct
{
}{})
return
}
...
...
@@ -32,9 +34,11 @@ func (jwtService *JwtService) JsonInBlacklist(jwtList system.JwtBlacklist) (err
//@return: bool
func
(
jwtService
*
JwtService
)
IsBlacklist
(
jwt
string
)
bool
{
err
:=
global
.
GVA_DB
.
Where
(
"jwt = ?"
,
jwt
)
.
First
(
&
system
.
JwtBlacklist
{})
.
Error
isNotFound
:=
errors
.
Is
(
err
,
gorm
.
ErrRecordNotFound
)
return
!
isNotFound
_
,
ok
:=
global
.
BlackCache
.
Get
(
jwt
)
return
ok
//err := global.GVA_DB.Where("jwt = ?", jwt).First(&system.JwtBlacklist{}).Error
//isNotFound := errors.Is(err, gorm.ErrRecordNotFound)
//return !isNotFound
}
//@author: [piexlmax](https://github.com/piexlmax)
...
...
@@ -60,3 +64,15 @@ func (jwtService *JwtService) SetRedisJWT(jwt string, userName string) (err erro
err
=
global
.
GVA_REDIS
.
Set
(
context
.
Background
(),
userName
,
jwt
,
timer
)
.
Err
()
return
err
}
func
LoadAll
()
{
var
data
[]
string
err
:=
global
.
GVA_DB
.
Find
(
&
system
.
JwtBlacklist
{})
.
Select
(
"jwt"
)
.
Find
(
&
data
)
.
Error
if
err
!=
nil
{
// 从db加载jwt数据
for
i
:=
range
data
{
global
.
BlackCache
.
SetDefault
(
data
[
i
],
struct
{
}{})
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录