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)