2023-12-14 14:15:56 +08:00
|
|
|
|
using Volo.Abp.Application.Services;
|
2024-01-25 01:43:00 +08:00
|
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
|
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
|
|
|
|
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
2023-12-14 14:15:56 +08:00
|
|
|
|
|
2023-12-15 23:44:35 +08:00
|
|
|
|
namespace Yi.Abp.Application.Services
|
2023-12-14 14:15:56 +08:00
|
|
|
|
{
|
2024-01-25 01:43:00 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 这是一个示例
|
|
|
|
|
|
/// </summary>
|
2023-12-14 14:15:56 +08:00
|
|
|
|
public class TestService : ApplicationService
|
|
|
|
|
|
{
|
2024-01-25 01:43:00 +08:00
|
|
|
|
public ISqlSugarRepository<BannerEntity> sqlSugarRepository { get; set; }
|
2023-12-14 14:15:56 +08:00
|
|
|
|
/// <summary>
|
2024-01-25 01:43:00 +08:00
|
|
|
|
/// 你好世界,动态Api
|
2023-12-14 14:15:56 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public string GetHelloWorld(string? name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return name ?? "HelloWord";
|
|
|
|
|
|
}
|
2024-01-25 01:43:00 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 工作单元魔改
|
2024-01-25 01:43:43 +08:00
|
|
|
|
/// 用户体验优先,万金油模式,支持高并发。支持单、多线程并发安全,支持多线程工作单元,支持多线程无工作单元,支持。。。
|
2024-01-25 01:43:00 +08:00
|
|
|
|
/// 自动在各个情况处理db客户端最优解之一
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public async Task GetUowAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 10;
|
|
|
|
|
|
List<Task> tasks = new List<Task>();
|
|
|
|
|
|
|
|
|
|
|
|
while (i > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
tasks.Add(Task.Run(async () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var uow = UnitOfWorkManager.Begin(true, true))
|
|
|
|
|
|
{
|
|
|
|
|
|
await sqlSugarRepository.InsertAsync(new BannerEntity { Name = "插入1" });
|
|
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
await sqlSugarRepository.InsertAsync(new BannerEntity { Name = "插入2" });
|
|
|
|
|
|
}));
|
|
|
|
|
|
await sqlSugarRepository.InsertAsync(new BannerEntity { Name = "插入3" });
|
|
|
|
|
|
i--;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await Task.WhenAll(tasks);
|
|
|
|
|
|
}
|
2023-12-14 14:15:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|