wxd 1 year ago
parent
commit
f0520268f8
  1. 6
      src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
  2. 2
      src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelAnswerConfigure.cs
  3. 16
      src/Shentun.WebPeis.HttpApi.Host/Controllers/WeChatController.cs

6
src/Shentun.WebPeis.Application/Persons/PersonAppService.cs

@ -198,8 +198,6 @@ namespace Shentun.WebPeis.Persons
}
person.WechatOpenId = input.WechatOpenId;
await _repository.UpdateAsync(person);
await unitOfWork.SaveChangesAsync();
await unitOfWork.CompleteAsync();
}
else
{
@ -216,10 +214,10 @@ namespace Shentun.WebPeis.Persons
(await _userManager.AddPasswordAsync(userWithPerson.User, Shentun.Utilities.
Encrypt.RandomHelper.CreateRandom(Utilities.Enums.RandomType.NumAndChar, 10) + "0Cz*")).CheckErrors();
await unitOfWork.SaveChangesAsync();
await unitOfWork.CompleteAsync();
}
await unitOfWork.CompleteAsync();
}
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))

2
src/Shentun.WebPeis.EntityFrameworkCore/Configures/DiseaseRiskLevelAnswerConfigure.cs

@ -15,7 +15,7 @@ namespace Shentun.WebPeis.Configures
{
entity.HasKey(e => new { e.DiseaseRiskLevelId, e.QuestionAnswerId }).HasName("pk_disease_risk_level_answer");
entity.ToTable("medical_package_detail", tb => tb.HasComment("疾病风险对应的答案"));
entity.ToTable("disease_risk_level_answer", tb => tb.HasComment("疾病风险对应的答案"));
}
}
}

16
src/Shentun.WebPeis.HttpApi.Host/Controllers/WeChatController.cs

@ -41,7 +41,7 @@ namespace Shentun.WebPeis.Controllers
}
[IgnoreAntiforgeryToken]
[ApiExplorerSettings(IgnoreApi = true)]
public class WeChatController : AbpOpenIdDictControllerBase, ITokenExtensionGrant, IWeChatController,ITransientDependency
public class WeChatController : AbpOpenIdDictControllerBase, ITokenExtensionGrant, IWeChatController, ITransientDependency
{
private readonly IConfiguration _configuration;
@ -83,7 +83,7 @@ namespace Shentun.WebPeis.Controllers
ClientSecret = context.Request.GetParameter("client_secret").ToString(),
};
var clientCredentialsResult = await httpClient.RequestClientCredentialsTokenAsync(request);
if(clientCredentialsResult.IsError)
if (clientCredentialsResult.IsError)
{
throw new Exception("应用程序没有权限" + clientCredentialsResult.ErrorDescription);
}
@ -121,11 +121,11 @@ namespace Shentun.WebPeis.Controllers
{
throw new Exception("用户不存在");
}
if(!user.IsActive)
if (!user.IsActive)
{
throw new Exception("用户已被禁用");
}
principal = await SignInManager.CreateUserPrincipalAsync(user);
if (principal == null)
{
@ -177,13 +177,15 @@ namespace Shentun.WebPeis.Controllers
});
await _unitOfWorkManager.Current.CompleteAsync();
var authenticationProperties = new AuthenticationProperties();
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
//return SignIn(principal, authenticationProperties, wechatSession.OpenId);
return SignIn(principal, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
var result = SignIn(principal, OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
await unitOfWork.CompleteAsync();
return result;
}
}
catch (Exception ex)
{

Loading…
Cancel
Save