Skip to content

Commit

Permalink
fix Cap Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyunchong committed May 16, 2024
1 parent 43407b2 commit 42d659a
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.815" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.822" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
<PackageReference Include="IGeekFan.AspNetCore.RapiDoc" Version="0.0.7" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.6.1" />
<PackageReference Include="IGeekFan.AspNetCore.RapiDoc" Version="0.0.8" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 10 additions & 2 deletions src/LinCms.Application/CapUnitOfWorkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ public static ICapTransaction BeginTransaction(this IUnitOfWork unitOfWork, ICap
{
//看了源码,换了新的写法,换不同的数据库,就需要手动修改这段代码了(MySqlCapTransaction)
//publisher.Transaction.Value = (ICapTransaction)publisher.ServiceProvider.GetService(typeof(ICapTransaction));新版本只能得到null
publisher.Transaction.Value = ActivatorUtilities.CreateInstance<MySqlCapTransaction>(publisher.ServiceProvider);
return publisher.Transaction.Value.Begin(unitOfWork.GetOrBeginTransaction(), autoCommit);

// publisher.Transaction.Value = ActivatorUtilities.CreateInstance<MySqlCapTransaction>(publisher.ServiceProvider);
// return publisher.Transaction.Value.Begin(unitOfWork.GetOrBeginTransaction(), autoCommit);

//第2次接口变化,适配CAP
var dbTransaction = unitOfWork.GetOrBeginTransaction();
publisher.Transaction = ActivatorUtilities.CreateInstance<MySqlCapTransaction>(publisher.ServiceProvider);
publisher.Transaction.DbTransaction = dbTransaction;
publisher.Transaction.AutoCommit = autoCommit;
return publisher.Transaction;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/LinCms.Application/Cms/Account/IdentityServer4Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task<UserAccessToken> LoginAsync(LoginInputDto loginInputDto)
throw new LinCmsException(response.ErrorDescription);
}

JsonElement jsonElement = response.Json;
var jsonElement = response.Json;

_logger.LogInformation($"用户{loginInputDto.Username},登录成功,{JsonConvert.SerializeObject(jsonElement)}");
return new UserAccessToken(jsonElement.GetProperty("access_token").ToString(), jsonElement.GetProperty("refresh_token").ToString(), 7200, "Bearer", 24 * 60 * 60 * 7);
Expand Down Expand Up @@ -115,7 +115,7 @@ public async Task<UserAccessToken> GetRefreshTokenAsync(string refreshToken)
throw new LinCmsException("请重新登录", ErrorCode.RefreshTokenError);
}

JsonElement jsonElement = response.Json;
var jsonElement = response.Json;

return new UserAccessToken(jsonElement.GetProperty("access_token").ToString(), jsonElement.GetProperty("refresh_token").ToString(), 7200, "Bearer", 24 * 60 * 60 * 7);
}
Expand Down
14 changes: 7 additions & 7 deletions src/LinCms.Application/LinCms.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="8.0.0" />
<PackageReference Include="AspNet.Security.OAuth.QQ" Version="8.0.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="DotNetCore.CAP.MySql" Version="8.0.1" />
<PackageReference Include="DotNetCore.CAP.MySql" Version="8.1.2" />
<!--<PackageReference Include="DotNetCore.CAP.SqlServer" Version="6.1.1-preview-176300030" />-->
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="8.0.1" />
<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.0.1" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="8.0.1" />
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="8.1.2" />
<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.1.2" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="8.1.2" />
<PackageReference Include="IdentityServer4" Version="4.1.2" />
<PackageReference Include="IdentityModel" Version="6.2.0" />
<PackageReference Include="IGeekFan.Localization.FreeSql" Version="0.0.539" />
<PackageReference Include="IdentityModel" Version="7.0.0" />
<PackageReference Include="IGeekFan.Localization.FreeSql" Version="0.0.540" />
<PackageReference Include="MQiniu.Core" Version="1.0.1" />
<PackageReference Include="FreeRedis" Version="1.2.14" />
<PackageReference Include="FreeRedis" Version="1.2.15" />
<PackageReference Include="FreeRedis.DistributedCache" Version="1.2.5" />
</ItemGroup>

Expand Down
13 changes: 7 additions & 6 deletions src/LinCms.Core/LinCms.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="IGeekFan.FreeKit.Extras" Version="0.0.539" />
<PackageReference Include="IGeekFan.FreeKit.Extras" Version="0.0.540" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="DotNetCore.Security" Version="17.3.0" />
<PackageReference Include="IGeekFan.FreeKit.Email" Version="0.0.539" />
<PackageReference Include="FreeSql.Extensions.JsonMap" Version="3.2.815" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" />
<PackageReference Include="IGeekFan.FreeKit.Email" Version="0.0.540" />
<PackageReference Include="FreeSql.Extensions.JsonMap" Version="3.2.822" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.5" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.7" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.8" />
<PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.4.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>


</Project>
20 changes: 0 additions & 20 deletions src/LinCms.Core/LinCms.Core.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 0 additions & 50 deletions src/LinCms.Core/LinCms/Core/NameValue.cs

This file was deleted.

114 changes: 0 additions & 114 deletions src/LinCms.Core/LinCms/Core/ValueObject.cs

This file was deleted.

12 changes: 6 additions & 6 deletions src/LinCms.Infrastructure/LinCms.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<ItemGroup>

<ProjectReference Include="..\LinCms.Core\LinCms.Core.csproj" />
<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.PostgreSQL" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.Oracle" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.Odbc" Version="3.2.815" />
<PackageReference Include="FreeSql.Provider.MySqlConnector" Version="3.2.822" />
<PackageReference Include="FreeSql.Provider.PostgreSQL" Version="3.2.822" />
<PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.822" />
<PackageReference Include="FreeSql.Provider.SqlServer" Version="3.2.822" />
<PackageReference Include="FreeSql.Provider.Oracle" Version="3.2.822" />
<PackageReference Include="FreeSql.Provider.Odbc" Version="3.2.822" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions src/LinCms.Plugins/LinCms.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand All @@ -19,6 +15,7 @@

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
</ItemGroup>

</Project>
18 changes: 9 additions & 9 deletions src/LinCms.Web/LinCms.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@

<ItemGroup>
<PackageReference Include="Yitter.IdGenerator" Version="1.0.14" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="8.0.1" />
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="7.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.16" />
<PackageReference Include="IGeekFan.AspNetCore.RapiDoc" Version="0.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="IGeekFan.AspNetCore.RapiDoc" Version="0.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Owl.reCAPTCHA" Version="7.0.0" />
<PackageReference Include="Owl.reCAPTCHA" Version="8.0.0" />
<PackageReference Include="Savorboard.CAP.InMemoryMessageQueue" Version="8.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.MariaDB" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.MSSqlServer" Version="6.6.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.1" />
<PackageReference Include="ToolGood.Words" Version="3.1.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions test/LinCms.Test/LinCms.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.5" />
<PackageReference Include="Microsoft.DependencyValidation.Analyzers" Version="0.11.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="Xunit.DependencyInjection" Version="8.9.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="Xunit.DependencyInjection" Version="9.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 42d659a

Please sign in to comment.