未验证 提交 4afbfb9c 编写于 作者: Mr.奇淼('s avatar Mr.奇淼( 提交者: GitHub

Merge pull request #675 from flipped-aurora/gva-vue3

修复字典逻辑bug
...@@ -2,6 +2,7 @@ package system ...@@ -2,6 +2,7 @@ package system
import ( import (
"context" "context"
"go.uber.org/zap"
"time" "time"
"github.com/flipped-aurora/gin-vue-admin/server/global" "github.com/flipped-aurora/gin-vue-admin/server/global"
...@@ -22,8 +23,7 @@ func (jwtService *JwtService) JsonInBlacklist(jwtList system.JwtBlacklist) (err ...@@ -22,8 +23,7 @@ func (jwtService *JwtService) JsonInBlacklist(jwtList system.JwtBlacklist) (err
if err != nil { if err != nil {
return return
} }
global.BlackCache.SetDefault(jwtList.Jwt, struct { global.BlackCache.SetDefault(jwtList.Jwt, struct{}{})
}{})
return return
} }
...@@ -67,12 +67,12 @@ func (jwtService *JwtService) SetRedisJWT(jwt string, userName string) (err erro ...@@ -67,12 +67,12 @@ func (jwtService *JwtService) SetRedisJWT(jwt string, userName string) (err erro
func LoadAll() { func LoadAll() {
var data []string var data []string
err := global.GVA_DB.Find(&system.JwtBlacklist{}).Select("jwt").Find(&data).Error err := global.GVA_DB.Model(&system.JwtBlacklist{}).Select("jwt").Find(&data).Error
if err != nil { if err != nil {
// 从db加载jwt数据 global.GVA_LOG.Error("加载数据库jwt黑名单失败!", zap.Error(err))
for i := range data { return
global.BlackCache.SetDefault(data[i], struct {
}{})
}
} }
for i := 0; i < len(data); i++ {
global.BlackCache.SetDefault(data[i], struct{}{})
} // jwt黑名单 加入 BlackCache 中
} }
...@@ -52,15 +52,12 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s ...@@ -52,15 +52,12 @@ func (dictionaryService *DictionaryService) UpdateSysDictionary(sysDictionary *s
"Desc": sysDictionary.Desc, "Desc": sysDictionary.Desc,
} }
db := global.GVA_DB.Where("id = ?", sysDictionary.ID).First(&dict) db := global.GVA_DB.Where("id = ?", sysDictionary.ID).First(&dict)
if dict.Type == sysDictionary.Type { if dict.Type != sysDictionary.Type {
err = db.Updates(sysDictionaryMap).Error if !errors.Is(global.GVA_DB.First(&system.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound) {
} else {
if (!errors.Is(global.GVA_DB.First(&system.SysDictionary{}, "type = ?", sysDictionary.Type).Error, gorm.ErrRecordNotFound)) {
return errors.New("存在相同的type,不允许创建") return errors.New("存在相同的type,不允许创建")
} }
err = db.Updates(sysDictionaryMap).Error
} }
err = db.Updates(sysDictionaryMap).Error
return err return err
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册