2025-02-02 01:06:36 +01:00
|
|
|
using DotBased.AspNet.Authority.Models.Authority;
|
|
|
|
using DotBased.AspNet.Authority.Repositories;
|
2025-02-10 02:40:27 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2025-02-02 01:06:36 +01:00
|
|
|
|
|
|
|
namespace DotBased.AspNet.Authority.EFCore.Repositories;
|
|
|
|
|
2025-02-10 02:40:27 +01:00
|
|
|
public class UserRepository(IDbContextFactory<AuthorityContext> contextFactory) : IUserRepository
|
2025-02-02 01:06:36 +01:00
|
|
|
{
|
2025-02-10 02:40:27 +01:00
|
|
|
public async Task<ListResult<AuthorityUserItem>> GetAuthorityUsersAsync(int limit = 20, int offset = 0, string search = "", CancellationToken? cancellationToken = null)
|
2025-02-02 01:06:36 +01:00
|
|
|
{
|
2025-02-10 02:40:27 +01:00
|
|
|
await using var context = await contextFactory.CreateDbContextAsync();
|
|
|
|
var query = context.Users.AsQueryable();
|
|
|
|
if (!string.IsNullOrWhiteSpace(search))
|
|
|
|
{
|
|
|
|
query = query.Where(u => $"{u.Id} {u.Name} {u.UserName} {u.EmailAddress} {u.PhoneNumber}".Contains(search, StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
}
|
|
|
|
var totalCount = query.Count();
|
|
|
|
var selected = query.Skip(offset).Take(limit).Select(u => new AuthorityUserItem()
|
|
|
|
{
|
|
|
|
Id = u.Id,
|
|
|
|
UserName = u.UserName,
|
|
|
|
EmailAddress = u.EmailAddress,
|
|
|
|
PhoneNumber = u.PhoneNumber
|
|
|
|
});
|
|
|
|
return ListResult<AuthorityUserItem>.Ok(selected, totalCount, limit, offset);
|
2025-02-02 01:06:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|