mirror of
https://github.com/hmaxnl/DotBased.git
synced 2025-02-22 22:55:01 +01:00
DBContext & repository
This commit is contained in:
parent
5b4509cac3
commit
0f6b2fec88
|
@ -9,4 +9,13 @@ public class AuthorityContext : DbContext
|
|||
public DbSet<AuthorityGroup> Groups { get; set; }
|
||||
public DbSet<AuthorityRole> Roles { get; set; }
|
||||
public DbSet<AuthorityUser> Users { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<AuthorityAttribute>().ToTable("authority_attributes");
|
||||
modelBuilder.Entity<AuthorityGroup>().ToTable("authority_groups");
|
||||
modelBuilder.Entity<AuthorityRole>().ToTable("authority_roles");
|
||||
modelBuilder.Entity<AuthorityUser>().ToTable("authority_users");
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
using DotBased.AspNet.Authority.EFCore.Repositories;
|
||||
using DotBased.AspNet.Authority.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
@ -8,6 +10,10 @@ public static class DI
|
|||
public static IServiceCollection AddAuthorityContext(this IServiceCollection services, Action<DbContextOptionsBuilder> options)
|
||||
{
|
||||
services.AddDbContextFactory<AuthorityContext>(options);
|
||||
services.AddScoped<IAttributeRepository, AttributeRepository>();
|
||||
services.AddScoped<IGroupRepository, GroupRepository>();
|
||||
services.AddScoped<IRoleRepository, RoleRepository>();
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
return services;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.12" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
using DotBased.AspNet.Authority.Models.Authority;
|
||||
using DotBased.AspNet.Authority.Repositories;
|
||||
|
||||
namespace DotBased.AspNet.Authority.EFCore.Repositories;
|
||||
|
||||
public class UserRepository : IUserRepository
|
||||
{
|
||||
public Task<ListResult<AuthorityUserItem>> GetAuthorityUsersAsync(int limit = 20, int offset = 0, string search = "",
|
||||
CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<AuthorityUser>> GetAuthorityUserByIdAsync(string id, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<AuthorityUser>> CreateUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<AuthorityUser>> UpdateUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result> DeleteUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<AuthorityUser>> GetUserByEmailAsync(string email, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result> SetVersionAsync(AuthorityUser user, long version, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<long>> GetVersionAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result> SetSecurityVersionAsync(AuthorityUser user, long version, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Result<long>> GetSecurityVersionAsync(AuthorityUser user, CancellationToken? cancellationToken = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public interface IUserRepository
|
|||
public Task<Result<AuthorityUser>> CreateUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null);
|
||||
public Task<Result<AuthorityUser>> UpdateUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null);
|
||||
public Task<Result> DeleteUserAsync(AuthorityUser user, CancellationToken? cancellationToken = null);
|
||||
public Task<Result<AuthorityUser>> GetAuthorityUserByEmailAsync(string email, CancellationToken? cancellationToken = null);
|
||||
public Task<Result<AuthorityUser>> GetUserByEmailAsync(string email, CancellationToken? cancellationToken = null);
|
||||
public Task<Result> SetVersionAsync(AuthorityUser user, long version, CancellationToken? cancellationToken = null);
|
||||
public Task<Result<long>> GetVersionAsync(AuthorityUser user, CancellationToken? cancellationToken = null);
|
||||
public Task<Result> SetSecurityVersionAsync(AuthorityUser user, long version, CancellationToken? cancellationToken = null);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class UserValidator : IUserValidator
|
|||
}
|
||||
else
|
||||
{
|
||||
var userEmailResult = await manager.UserRepository.GetAuthorityUserByEmailAsync(user.EmailAddress);
|
||||
var userEmailResult = await manager.UserRepository.GetUserByEmailAsync(user.EmailAddress);
|
||||
if (userEmailResult != null)
|
||||
{
|
||||
errors.Add(new ValidationError(ValidatorId, $"{ValidationBase}.EmailExists",
|
||||
|
|
Loading…
Reference in New Issue
Block a user