This commit is contained in:
Thanakarn Klangkasame
2025-09-30 11:01:02 +07:00
commit 92e614674c
182 changed files with 9596 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
using System.Data;
using AMREZ.EOP.Abstractions.Applications.Tenancy;
namespace AMREZ.EOP.Abstractions.Infrastructures.Common;
public interface IUnitOfWork
{
Task BeginAsync(ITenantContext tenant, IsolationLevel isolation = IsolationLevel.ReadCommitted, CancellationToken ct = default);
Task CommitAsync(CancellationToken ct = default);
Task RollbackAsync(CancellationToken ct = default);
string Backend { get; } // "ef" | "redis"
}

View File

@@ -0,0 +1,21 @@
using AMREZ.EOP.Domain.Entities.Tenancy;
namespace AMREZ.EOP.Abstractions.Infrastructures.Repositories;
public interface ITenantRepository
{
Task<bool> TenantExistsAsync(string tenantKey, CancellationToken ct = default);
Task<TenantConfig?> GetAsync(string tenantKey, CancellationToken ct = default);
Task<IReadOnlyList<TenantConfig>> ListTenantsAsync(CancellationToken ct = default);
Task<bool> CreateAsync(TenantConfig row, CancellationToken ct = default);
Task<bool> UpdateAsync(TenantConfig row, DateTimeOffset? ifUnmodifiedSince, CancellationToken ct = default);
Task<bool> DeleteAsync(string tenantKey, CancellationToken ct = default);
Task<bool> MapDomainAsync(string domain, string tenantKey, CancellationToken ct = default);
Task<bool> UnmapDomainAsync(string domain, CancellationToken ct = default);
Task<IReadOnlyList<TenantDomain>> ListDomainsAsync(string? tenantKey, CancellationToken ct = default);
Task<bool> AddBaseDomainAsync(string baseDomain, CancellationToken ct = default);
Task<bool> RemoveBaseDomainAsync(string baseDomain, CancellationToken ct = default);
}

View File

@@ -0,0 +1,21 @@
using AMREZ.EOP.Domain.Entities.HumanResources;
namespace AMREZ.EOP.Abstractions.Infrastructures.Repositories;
public interface IUserProfileRepository
{
Task<UserProfile?> GetByUserIdAsync(Guid userId, CancellationToken ct = default);
Task UpsertAsync(UserProfile profile, CancellationToken ct = default);
Task<Employment> AddEmploymentAsync(Employment e, CancellationToken ct = default);
Task EndEmploymentAsync(Guid employmentId, DateTime endDate, CancellationToken ct = default);
Task<EmployeeAddress> AddAddressAsync(EmployeeAddress a, CancellationToken ct = default);
Task SetPrimaryAddressAsync(Guid userProfileId, Guid addressId, CancellationToken ct = default);
Task<EmergencyContact> AddEmergencyContactAsync(EmergencyContact c, CancellationToken ct = default);
Task SetPrimaryEmergencyContactAsync(Guid userProfileId, Guid contactId, CancellationToken ct = default);
Task<EmployeeBankAccount> AddBankAccountAsync(EmployeeBankAccount b, CancellationToken ct = default);
Task SetPrimaryBankAccountAsync(Guid userProfileId, Guid bankAccountId, CancellationToken ct = default);
}

View File

@@ -0,0 +1,31 @@
using AMREZ.EOP.Domain.Entities.Authentications;
using AMREZ.EOP.Domain.Shared._Users;
namespace AMREZ.EOP.Abstractions.Infrastructures.Repositories;
public interface IUserRepository
{
Task<User?> FindByIdAsync(Guid userId, CancellationToken ct = default);
Task<User?> FindActiveByEmailAsync(string email, CancellationToken ct = default);
Task<bool> EmailExistsAsync(string email, CancellationToken ct = default);
Task AddAsync(User user, CancellationToken ct = default);
// Identities
Task AddIdentityAsync(Guid userId, IdentityType type, string identifier, bool isPrimary, CancellationToken ct = default);
Task VerifyIdentityAsync(Guid userId, IdentityType type, string identifier, DateTimeOffset verifiedAt, CancellationToken ct = default);
Task<UserIdentity?> GetPrimaryIdentityAsync(Guid userId, IdentityType type, CancellationToken ct = default);
// Password
Task ChangePasswordAsync(Guid userId, string newPasswordHash, CancellationToken ct = default);
Task AddPasswordHistoryAsync(Guid userId, string passwordHash, CancellationToken ct = default);
// MFA
Task<UserMfaFactor> AddTotpFactorAsync(Guid userId, string label, string secret, CancellationToken ct = default);
Task DisableMfaFactorAsync(Guid factorId, CancellationToken ct = default);
Task<bool> HasAnyMfaAsync(Guid userId, CancellationToken ct = default);
// Sessions
Task<UserSession> CreateSessionAsync(UserSession session, CancellationToken ct = default);
Task<int> RevokeSessionAsync(Guid userId, Guid sessionId, CancellationToken ct = default);
Task<int> RevokeAllSessionsAsync(Guid userId, CancellationToken ct = default);
}