diff --git a/server/global/global.go b/server/global/global.go index 829714b07b69f8bc33b0b5eb4ae2f24b4af8bde5..404bb8ae8e608d67d48d135b4963c47869e63539 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 6eb7497df35e8589eda8a6193fdf0ebf574614e2..df07108b81f70871dfef1b22018a7383fb7f92b9 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 f9571ddfa4730f00e343b483f74641d00d34f703..6ecc5a8e1fefdbef458daf0c18567103a6cf4bb1 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 507a76ff2533d89872db7705cd0d8a2b57916a51..9b242875feecc35ed69dce2f072ab4efa3fbd1eb 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 } diff --git a/web/Dockerfile b/web/Dockerfile index d616262d737134eb363222832dbd25829767e104..b40db4acb76d59d5b85e9a5fca54831b86056ba8 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