From fb2199c94890bbeb6a738dfa36a75416e395ef72 Mon Sep 17 00:00:00 2001 From: songzhibin97 <718428482@qq.com> Date: Mon, 12 Jul 2021 19:23:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9redis=E5=8C=85,?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=8E=A8=E8=8D=90=E7=9A=84v8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/global/global.go | 2 +- server/go.mod | 6 +----- server/initialize/redis.go | 6 ++++-- server/service/jwt_black_list.go | 8 +++++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/global/global.go b/server/global/global.go index 829714b0..404bb8ae 100644 --- a/server/global/global.go +++ b/server/global/global.go @@ -9,7 +9,7 @@ import ( "gin-vue-admin/config" - "github.com/go-redis/redis" + "github.com/go-redis/redis/v8" "github.com/spf13/viper" "gorm.io/gorm" ) diff --git a/server/go.mod b/server/go.mod index 6eb7497d..df07108b 100644 --- a/server/go.mod +++ b/server/go.mod @@ -20,8 +20,8 @@ require ( github.com/go-openapi/swag v0.19.8 // indirect github.com/go-playground/validator/v10 v10.3.0 // indirect github.com/go-redis/redis v6.15.7+incompatible + github.com/go-redis/redis/v8 v8.11.0 github.com/go-sql-driver/mysql v1.5.0 - github.com/golang/protobuf v1.4.2 // indirect github.com/gookit/color v1.3.1 github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84 @@ -31,8 +31,6 @@ require ( github.com/mailru/easyjson v0.7.1 // indirect github.com/mitchellh/mapstructure v1.2.2 // indirect github.com/mojocn/base64Captcha v1.3.1 - github.com/onsi/ginkgo v1.7.0 // indirect - github.com/onsi/gomega v1.4.3 // indirect 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 @@ -52,10 +50,8 @@ require ( go.uber.org/zap v1.10.0 golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/tools v0.0.0-20200324003944-a576cf524670 // indirect 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 v1.0.1 gorm.io/gorm v1.20.7 ) diff --git a/server/initialize/redis.go b/server/initialize/redis.go index f9571ddf..6ecc5a8e 100644 --- a/server/initialize/redis.go +++ b/server/initialize/redis.go @@ -1,8 +1,10 @@ package initialize import ( + "context" "gin-vue-admin/global" - "github.com/go-redis/redis" + + "github.com/go-redis/redis/v8" "go.uber.org/zap" ) @@ -13,7 +15,7 @@ func Redis() { Password: redisCfg.Password, // no password set DB: redisCfg.DB, // use default DB }) - pong, err := client.Ping().Result() + pong, err := client.Ping(context.Background()).Result() if err != nil { global.GVA_LOG.Error("redis connect ping failed, err:", zap.Any("err", err)) } else { diff --git a/server/service/jwt_black_list.go b/server/service/jwt_black_list.go index 507a76ff..9b242875 100644 --- a/server/service/jwt_black_list.go +++ b/server/service/jwt_black_list.go @@ -1,11 +1,13 @@ package service import ( + "context" "errors" "gin-vue-admin/global" "gin-vue-admin/model" - "gorm.io/gorm" "time" + + "gorm.io/gorm" ) //@author: [piexlmax](https://github.com/piexlmax) @@ -38,7 +40,7 @@ func IsBlacklist(jwt string) bool { //@return: err error, redisJWT string func GetRedisJWT(userName string) (err error, redisJWT string) { - redisJWT, err = global.GVA_REDIS.Get(userName).Result() + redisJWT, err = global.GVA_REDIS.Get(context.Background(), userName).Result() return err, redisJWT } @@ -51,6 +53,6 @@ func GetRedisJWT(userName string) (err error, redisJWT string) { func SetRedisJWT(jwt string, userName string) (err error) { // 此处过期时间等于jwt过期时间 timer := time.Duration(global.GVA_CONFIG.JWT.ExpiresTime) * time.Second - err = global.GVA_REDIS.Set(userName, jwt, timer).Err() + err = global.GVA_REDIS.Set(context.Background(), userName, jwt, timer).Err() return err } From b129ae85c4a9f18c63c52c1583c64834345dac28 Mon Sep 17 00:00:00 2001 From: SliverHorn <45428434+SliverHorn@users.noreply.github.com> Date: Mon, 12 Jul 2021 20:18:45 +0800 Subject: [PATCH 2/2] fix: web/Dockerfile cnpm install error update file - web/Dockerfile fixed: - cnpm install error --- web/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/Dockerfile b/web/Dockerfile index d616262d..b40db4ac 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -3,8 +3,7 @@ FROM node:12.16.1 WORKDIR /gva_web/ COPY . . -RUN npm install -g cnpm --registry=https://registry.npm.taobao.org -RUN cnpm install || npm install +RUN npm install RUN npm run build FROM nginx:alpine