From 7abcfadd9388dce9cd8a538b347ddecc60818239 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Fri, 8 Sep 2023 18:19:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=AE=BE=E7=BD=AE=E5=BD=93=E5=89=8Dlogo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/userlogosetlogic.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/home-user-auth/internal/logic/userlogosetlogic.go b/server/home-user-auth/internal/logic/userlogosetlogic.go index 45d5dbf7..cca077ca 100644 --- a/server/home-user-auth/internal/logic/userlogosetlogic.go +++ b/server/home-user-auth/internal/logic/userlogosetlogic.go @@ -150,8 +150,16 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth } userInfo.Metadata = &metadataBUserInfo userInfo.Utime = &nowTime - resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo) - err = resUpdates.Error + if userInfo.Id == 0 { + // 新增 + resCreate := tx.Model(&userInfo).Create(&userInfo) + err = resCreate.Error + } else { + // 更新 + resUpdates := tx.Model(&userInfo).Select("metadata").Where("id = ?", userInfo.Id).Updates(&userInfo) + err = resUpdates.Error + } + if err != nil { if err != gorm.ErrRecordNotFound { logc.Errorf(l.ctx, "FsUserInfo Updates err:%+v", err)