完成工作单元模块

This commit is contained in:
橙子
2023-01-17 23:33:14 +08:00
parent da2cf2acc5
commit 2fa3570f85
11 changed files with 134 additions and 102 deletions

View File

@@ -14,6 +14,7 @@ using Yi.Framework.Application.Contracts.Student.Dtos;
using Yi.Framework.Domain.Student.Entities;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Core.Attributes;
using Yi.Framework.Uow;
namespace Yi.Framework.Application.Student
{
@@ -23,24 +24,31 @@ namespace Yi.Framework.Application.Student
[AppService]
public class StudentService : CrudAppService<StudentEntity, StudentGetOutputDto, StudentGetListOutputDto, long, StudentGetListInputVo, StudentCreateInputVo, StudentUpdateInputVo>,
IStudentService,IAutoApiService
IStudentService, IAutoApiService
{
private readonly IStudentRepository _studentRepository;
private readonly StudentManager _studentManager;
public StudentService(IStudentRepository studentRepository, StudentManager studentManager)
private readonly IUnitOfWorkManager _unitOfWorkManager;
public StudentService(IStudentRepository studentRepository, StudentManager studentManager, IUnitOfWorkManager unitOfWorkManager)
{
_studentRepository = studentRepository;
_studentManager = studentManager;
_unitOfWorkManager = unitOfWorkManager;
}
/// <summary>
/// 你好世界
/// Uow
/// </summary>
/// <returns></returns>
public async Task<List<StudentGetListOutputDto>> PostShijie()
public async Task<StudentGetOutputDto> PostUow()
{
throw new NotImplementedException();
var entities = await _studentRepository.GetMyListAsync();
return await MapToGetListOutputDtosAsync(entities);
StudentGetOutputDto res = new();
using (var uow = _unitOfWorkManager.CreateContext())
{
res = await base.CreateAsync(new StudentCreateInputVo { Name = $"老杰哥{DateTime.Now.ToString("ffff")}", Number = 2023 });
if (new Random().Next(0, 2) == 0) throw new NotImplementedException();
uow.Commit();
}
return res;
}
}
}

View File

@@ -8,7 +8,7 @@ TimeTest.Start();
var builder = WebApplication.CreateBuilder(args);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>url
builder.WebHost.UseStartUrlsServer(builder.Configuration, "StartUrl");
builder.WebHost.UseStartUrlsServer(builder.Configuration);
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
builder.UseYiModules(typeof(YiFrameworkWebModule));

View File

@@ -30,3 +30,5 @@
2023:01:17-22:43:56本次运行启动时间为2023毫秒
2023:01:17-22:45:25本次运行启动时间为1803毫秒
2023:01:17-22:45:52本次运行启动时间为1877毫秒
2023:01:17-23:24:07本次运行启动时间为1836毫秒
2023:01:17-23:29:20本次运行启动时间为1958毫秒