添加工作单元测试
This commit is contained in:
@@ -111,11 +111,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
public async Task<Result> TestUnitOfWork()
|
||||
{
|
||||
var userId = await _iUserService.AddInfo(new DTOModel.UserInfoDto { User = new UserEntity { Address = "", UserName = "lisi", Password = "123456" }.BuildPassword() });
|
||||
throw new ApplicationException("测试uow");
|
||||
await _iRoleService._repository.InsertReturnSnowflakeIdAsync(new RoleEntity { RoleName = "测试", RoleCode = "tt" });
|
||||
await _iRoleService.UowTest();
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -15,6 +15,12 @@ namespace Yi.Framework.Interface
|
||||
/// <returns></returns>
|
||||
Task<List<RoleEntity>> DbTest();
|
||||
|
||||
/// <summary>
|
||||
/// 工作单元测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> UowTest();
|
||||
|
||||
/// <summary>
|
||||
/// 通过角色id获取角色实体包含菜单
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,7 @@ using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Uow.Interceptors;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
@@ -17,6 +18,15 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
return await _repository._Db.Queryable<RoleEntity>().ToListAsync();
|
||||
}
|
||||
//添加工作单元特性
|
||||
[UnitOfWork]
|
||||
public async Task<bool> UowTest()
|
||||
{
|
||||
var res = await _repository.InsertReturnSnowflakeIdAsync(new RoleEntity { RoleName = "测试", RoleCode = "tt" });
|
||||
throw new ApplicationException("测试uow");
|
||||
return res>0;
|
||||
}
|
||||
|
||||
public async Task<bool> GiveRoleSetMenu(List<long> roleIds, List<long> menuIds)
|
||||
{
|
||||
var _repositoryRoleMenu = _repository.ChangeRepository<Repository<RoleMenuEntity>>();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Uow\Yi.Framework.Uow.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Yi.Framework.WebCore.AutoFacExtend
|
||||
.AsImplementedInterfaces()
|
||||
.InstancePerLifetimeScope()
|
||||
.EnableInterfaceInterceptors()
|
||||
//开启工作单元拦截
|
||||
.InterceptedBy(typeof(UnitOfWorkInterceptor));
|
||||
|
||||
///反射注册任务调度层
|
||||
|
||||
Reference in New Issue
Block a user