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); }