From 94799ee189e60f09a5cc658dcfe4951c5cfbccab Mon Sep 17 00:00:00 2001 From: glz <694770232@qq.com> Date: Mon, 15 Jun 2026 09:38:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=9C=8D=E5=8A=A1=E7=9A=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除冗余的用户ID赋值步骤,直接使用插入后返回的主键值填充日志,简化代码逻辑 --- QYZH.InteractiveMagazine.Service/WeChatAuthService.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/QYZH.InteractiveMagazine.Service/WeChatAuthService.cs b/QYZH.InteractiveMagazine.Service/WeChatAuthService.cs index 26802c8..86e37e1 100644 --- a/QYZH.InteractiveMagazine.Service/WeChatAuthService.cs +++ b/QYZH.InteractiveMagazine.Service/WeChatAuthService.cs @@ -236,7 +236,7 @@ public class WeChatAuthService( // 校验 WxUser 是否存在 var wxUser = await wxUserRepository.Context.Queryable() - .Where(w => w.Id == wxUserId ) + .Where(w => w.Id == wxUserId) .FirstAsync(); if (wxUser == null) @@ -260,11 +260,10 @@ public class WeChatAuthService( UpdatedAt = DateTime.Now }; - var userId = await wxUserRepository.Context.Insertable(newUser).ExecuteReturnIdentityAsync(); - newUser.Id = userId; + await wxUserRepository.Context.Insertable(newUser).ExecuteReturnIdentityAsync(); logger.LogInformation("新用户创建成功,UserId: {UserId}, WxUserId: {WxUserId}, Name: {Name}", - userId, wxUserId, input.Name); + newUser.Id, wxUserId, input.Name); // 为新用户创建默认宠物 try { await petService.CreateDefaultPetAsync(newUser.Id); }