21 changed files with 79 additions and 204 deletions
@ -1,12 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="4.4.0" /> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="4.4.0" /> |
|||
<PackageReference Include="Volo.Abp.ObjectMapping" Version="4.4.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,13 +0,0 @@ |
|||
using Volo.Abp.Domain; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectMapping; |
|||
|
|||
namespace Lion.Abp.Domain |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpDddDomainModule), |
|||
typeof(AbpObjectMappingModule))] |
|||
public class LionAbpDomainModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Domain.Services; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace CompanyName.ProjectName.DataDictionaryManagement |
|||
{ |
|||
public abstract class DataDictionaryDomainService : DomainService |
|||
{ |
|||
protected Type ObjectMapperContext { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 工作单元管理器
|
|||
/// </summary>
|
|||
protected IUnitOfWorkManager UnitOfWorkManager => |
|||
LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>(); |
|||
|
|||
/// <summary>
|
|||
/// 分布式事件总线
|
|||
/// </summary>
|
|||
protected IDistributedEventBus DistributedEventBus => |
|||
LazyServiceProvider.LazyGetRequiredService<IDistributedEventBus>(); |
|||
|
|||
/// <summary>
|
|||
/// 对象映射器
|
|||
/// </summary>
|
|||
protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>( |
|||
provider => |
|||
ObjectMapperContext == null |
|||
? provider.GetRequiredService<IObjectMapper>() |
|||
: (IObjectMapper)provider.GetRequiredService( |
|||
typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext))); |
|||
} |
|||
} |
|||
@ -1,13 +1,36 @@ |
|||
using System; |
|||
using Lion.Abp.Domain; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Domain.Services; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace CompanyName.ProjectName.NotificationManagement |
|||
{ |
|||
public abstract class NotificationManagementDomainService : LionAbpDomainService |
|||
public abstract class NotificationManagementDomainService : DomainService |
|||
{ |
|||
protected NotificationManagementDomainService() |
|||
{ |
|||
ObjectMapperContext = typeof(NotificationManagementDomainModule); |
|||
} |
|||
protected Type ObjectMapperContext { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 工作单元管理器
|
|||
/// </summary>
|
|||
protected IUnitOfWorkManager UnitOfWorkManager => |
|||
LazyServiceProvider.LazyGetRequiredService<IUnitOfWorkManager>(); |
|||
|
|||
/// <summary>
|
|||
/// 分布式事件总线
|
|||
/// </summary>
|
|||
protected IDistributedEventBus DistributedEventBus => |
|||
LazyServiceProvider.LazyGetRequiredService<IDistributedEventBus>(); |
|||
|
|||
/// <summary>
|
|||
/// 对象映射器
|
|||
/// </summary>
|
|||
protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetService<IObjectMapper>( |
|||
provider => |
|||
ObjectMapperContext == null |
|||
? provider.GetRequiredService<IObjectMapper>() |
|||
: (IObjectMapper)provider.GetRequiredService( |
|||
typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext))); |
|||
} |
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace CompanyName.ProjectName.Users |
|||
{ |
|||
/* This entity shares the same table/collection ("AbpUsers" by default) with the |
|||
* IdentityUser entity of the Identity module. |
|||
* |
|||
* - You can define your custom properties into this class. |
|||
* - You never create or delete this entity, because it is Identity module's job. |
|||
* - You can query users from database with this entity. |
|||
* - You can update values of your custom properties. |
|||
*/ |
|||
public class AppUser : FullAuditedAggregateRoot<Guid>, IUser |
|||
{ |
|||
#region Base properties
|
|||
|
|||
/* These properties are shared with the IdentityUser entity of the Identity module. |
|||
* Do not change these properties through this class. Instead, use Identity module |
|||
* services (like IdentityUserManager) to change them. |
|||
* So, this properties are designed as read only! |
|||
*/ |
|||
|
|||
public virtual Guid? TenantId { get; private set; } |
|||
|
|||
public virtual string UserName { get; private set; } |
|||
|
|||
public virtual string Name { get; private set; } |
|||
|
|||
public virtual string Surname { get; private set; } |
|||
|
|||
public virtual string Email { get; private set; } |
|||
|
|||
public virtual bool EmailConfirmed { get; private set; } |
|||
|
|||
public virtual string PhoneNumber { get; private set; } |
|||
|
|||
public virtual bool PhoneNumberConfirmed { get; private set; } |
|||
|
|||
#endregion
|
|||
|
|||
/* Add your own properties here. Example: |
|||
* |
|||
* public string MyProperty { get; set; } |
|||
* |
|||
* If you add a property and using the EF Core, remember these; |
|||
* |
|||
* 1. Update ProjectNameDbContext.OnModelCreating |
|||
* to configure the mapping for your new property |
|||
* 2. Update ProjectNameEfCoreEntityExtensionMappings to extend the IdentityUser entity |
|||
* and add your new property to the migration. |
|||
* 3. Use the Add-Migration to add a new database migration. |
|||
* 4. Run the .DbMigrator project (or use the Update-Database command) to apply |
|||
* schema change to the database. |
|||
*/ |
|||
|
|||
private AppUser() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,44 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using CompanyName.ProjectName.Users; |
|||
using Shouldly; |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Xunit; |
|||
|
|||
namespace CompanyName.ProjectName.EntityFrameworkCore.Samples |
|||
{ |
|||
/* This is just an example test class. |
|||
* Normally, you don't test ABP framework code |
|||
* (like default AppUser repository IRepository<AppUser, Guid> here). |
|||
* Only test your custom repository methods. |
|||
*/ |
|||
public class SampleRepositoryTests : ProjectNameEntityFrameworkCoreTestBase |
|||
{ |
|||
private readonly IRepository<AppUser, Guid> _appUserRepository; |
|||
|
|||
public SampleRepositoryTests() |
|||
{ |
|||
_appUserRepository = GetRequiredService<IRepository<AppUser, Guid>>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Query_AppUser() |
|||
{ |
|||
/* Need to manually start Unit Of Work because |
|||
* FirstOrDefaultAsync should be executed while db connection / context is available. |
|||
*/ |
|||
await WithUnitOfWorkAsync(async () => |
|||
{ |
|||
//Act
|
|||
var adminUser = await (await _appUserRepository.GetQueryableAsync()) |
|||
.Where(u => u.UserName == "admin") |
|||
.FirstOrDefaultAsync(); |
|||
|
|||
//Assert
|
|||
adminUser.ShouldNotBeNull(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue