From 7e4fe14871f5d1f1d705fbdaf9b038cfa518774c Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Fri, 29 Dec 2023 00:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=BC=93=E5=AD=98=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/user.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/model/user.go b/model/user.go index 155cabe..30d09e5 100644 --- a/model/user.go +++ b/model/user.go @@ -6,6 +6,7 @@ import ( "gorm.io/gorm" "one-api/common" "strings" + "time" ) // User if you add sensitive fields, don't forget to clean them in setupLogin function. @@ -202,9 +203,13 @@ func (user *User) Update(updatePassword bool) error { } } newUser := *user - DB.First(&user, user.Id) err = DB.Model(user).Updates(newUser).Error + if err == nil { + if common.RedisEnabled { + _ = common.RedisSet(fmt.Sprintf("user_group:%d", user.Id), user.Group, time.Duration(UserId2GroupCacheSeconds)*time.Second) + } + } return err }