using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Tiku.Domain.Catalog;
using Tiku.Domain.Commerce;
using Tiku.Domain.Content;
using Tiku.Domain.Growth;
using Tiku.Domain.Identity;
using Tiku.Domain.Import;
using Tiku.Domain.Learning;
using Tiku.Domain.Operations;
using Tiku.Domain.Platform;
using Tiku.Domain.QuestionBanks;
using Tiku.Domain.Tenancy;
namespace Tiku.Infrastructure.Persistence;
///
/// Technical unit-of-work surface shared by the module persistence capabilities.
/// Business services must consume one or more owned module capabilities instead of TikuDbContext.
///
public interface IModulePersistence
{
long SaveVersion { get; }
DatabaseFacade Database { get; }
ChangeTracker ChangeTracker { get; }
DbSet Set() where TEntity : class;
EntityEntry Entry(object entity);
EntityEntry Entry(TEntity entity) where TEntity : class;
int SaveChanges();
Task SaveChangesAsync(CancellationToken cancellationToken = default);
}
public interface IIdentityPersistence : IModulePersistence
{
DbSet Users { get; }
DbSet UserIdentities { get; }
DbSet TenantMemberships { get; }
DbSet SmsVerificationCodes { get; }
DbSet SmsChannels { get; }
DbSet SmsTemplates { get; }
DbSet SmsSendLogs { get; }
DbSet AuthLoginEvents { get; }
DbSet AuthSessions { get; }
DbSet AuthChallenges { get; }
DbSet SmsSendRateLimits { get; }
}
public interface ITenancyPersistence : IModulePersistence
{
DbSet Tenants { get; }
DbSet TenantDomains { get; }
DbSet TenantBrandings { get; }
DbSet TenantSettings { get; }
DbSet TenantAuthPolicies { get; }
DbSet TenantFrontendConfigs { get; }
DbSet TenantExternalProviders { get; }
DbSet TenantSecrets { get; }
}
public interface ITenantAdministrationPersistence : IModulePersistence
{
DbSet TenantClasses { get; }
DbSet TenantClassMembers { get; }
DbSet TenantStudentNotes { get; }
DbSet TenantStudentFollowups { get; }
DbSet StudentProfiles { get; }
DbSet Badges { get; }
DbSet UserBadges { get; }
DbSet TenantContentNotifications { get; }
DbSet TenantThemeTemplates { get; }
DbSet TenantThemeConfigs { get; }
DbSet TenantBillingProfiles { get; }
DbSet TenantBillingPolicies { get; }
DbSet TenantOwnerActivationGrants { get; }
}
public interface ICatalogPersistence : IModulePersistence
{
DbSet Regions { get; }
DbSet RegionModules { get; }
DbSet ModuleNodes { get; }
DbSet Schools { get; }
DbSet Majors { get; }
DbSet Subjects { get; }
DbSet Categories { get; }
DbSet TaxonomyNodes { get; }
DbSet QuestionTaxonomyAssignments { get; }
DbSet ScorelineFields { get; }
DbSet ScorelineRecords { get; }
}
public interface IQuestionBankPersistence : IModulePersistence
{
DbSet QuestionBanks { get; }
DbSet Questions { get; }
DbSet QuestionVersions { get; }
DbSet ContentEntries { get; }
DbSet ContentNodes { get; }
DbSet QuestionCollections { get; }
DbSet QuestionCollectionItems { get; }
DbSet PracticeBlueprints { get; }
DbSet QuestionTypeGroups { get; }
DbSet SubjectShares { get; }
DbSet ContentImportJobs { get; }
DbSet ContentImportItems { get; }
DbSet ContentImportIssues { get; }
DbSet TenantQuestionBankPreferences { get; }
DbSet TenantQuestionReferences { get; }
}
public interface IContentAssetPersistence : IModulePersistence
{
DbSet VocabularyUnits { get; }
DbSet VocabularyWords { get; }
DbSet HandbookSubjects { get; }
DbSet HandbookChapters { get; }
DbSet HandbookEntries { get; }
DbSet ContentAssets { get; }
DbSet ContentAssetAccessEvents { get; }
DbSet ContentAssetSecurityScanEvents { get; }
DbSet Images { get; }
DbSet AppAssets { get; }
DbSet VideoExplanations { get; }
DbSet QuestionVideos { get; }
DbSet VideoPlaybackProgress { get; }
}
public interface ILearningPersistence : IModulePersistence
{
DbSet UserWordProgress { get; }
DbSet UserWordFavorites { get; }
DbSet AiRecommendationReports { get; }
DbSet PracticeSessions { get; }
DbSet PracticeSessionQuestions { get; }
DbSet AnswerRecords { get; }
DbSet LearningOperationIdempotencies { get; }
DbSet FavoriteQuestions { get; }
DbSet WrongQuestions { get; }
DbSet RecentPractices { get; }
DbSet ExamDates { get; }
DbSet Reports { get; }
DbSet ReportStatusEvents { get; }
DbSet UserScoreEvents { get; }
DbSet PracticeDailyUsages { get; }
DbSet PracticeAccessEvents { get; }
DbSet PracticeSessionReports { get; }
DbSet PracticeSessionReportSections { get; }
DbSet DashboardDailyStats { get; }
DbSet RevenueDailyStats { get; }
}
public interface ICommercePersistence : IModulePersistence
{
DbSet Products { get; }
DbSet SvipPlans { get; }
DbSet Orders { get; }
DbSet OrderItems { get; }
DbSet Payments { get; }
DbSet PaymentEvents { get; }
DbSet Entitlements { get; }
DbSet CodeBatches { get; }
DbSet ActivationCodes { get; }
DbSet Coupons { get; }
DbSet CouponRedemptions { get; }
DbSet CommerceRefundRequests { get; }
DbSet CommerceRefundEvents { get; }
DbSet CommerceReconciliationBatches { get; }
DbSet CommerceReconciliationItems { get; }
DbSet CommerceReconciliationIssues { get; }
DbSet CommerceReconciliationIssueEvents { get; }
DbSet CommerceAdjustmentVouchers { get; }
DbSet CommerceAdjustmentVoucherEvents { get; }
}
public interface IPointsPersistence : IModulePersistence
{
DbSet PointActivityTasks { get; }
DbSet PointActivityClaims { get; }
DbSet PointExchangeItems { get; }
DbSet PointExchangeOrders { get; }
}
public interface IGrowthPersistence : IModulePersistence
{
DbSet ReferralTracks { get; }
DbSet ReferralCodes { get; }
DbSet ReferralLeads { get; }
DbSet ReferralTeamEdges { get; }
DbSet ReferralQrcodes { get; }
DbSet CrmConfigs { get; }
DbSet CrmWebhookQueue { get; }
DbSet CrmWebhookLogs { get; }
DbSet TenantCommissionSettings { get; }
DbSet CommissionSettlements { get; }
DbSet CommissionSettlementItems { get; }
DbSet CommissionSettlementProofs { get; }
DbSet CommissionSettlementExportEvents { get; }
}
public interface IJobsOperationsPersistence : IModulePersistence
{
DbSet Banners { get; }
DbSet Faqs { get; }
DbSet Announcements { get; }
DbSet AuditLogs { get; }
DbSet BackendPermissions { get; }
DbSet BackendMenus { get; }
DbSet TenantBackendRoles { get; }
DbSet TenantBackendRolePermissions { get; }
DbSet TenantBackendRoleMenus { get; }
DbSet TenantBackendUserRoles { get; }
DbSet PlatformBackendRoles { get; }
DbSet PlatformBackendRolePermissions { get; }
DbSet PlatformBackendRoleMenus { get; }
DbSet PlatformBackendUserRoles { get; }
DbSet AuthorizationScopeVersions { get; }
DbSet AuthorizationCacheInvalidations { get; }
DbSet BackgroundJobs { get; }
DbSet TenantLifecycleOperations { get; }
DbSet WorkerHeartbeats { get; }
DbSet UserNotifications { get; }
}
public interface IPlatformControlPlanePersistence : IModulePersistence
{
DbSet PlatformOperationIdempotencies { get; }
DbSet PlatformBillingInvoiceReminders { get; }
DbSet PlatformAuditAlertRules { get; }
DbSet PlatformAuditAlerts { get; }
DbSet PlatformBillingDunningNotificationChannels { get; }
DbSet PlatformBillingDunningNotificationEvents { get; }
DbSet PlatformPaymentApps { get; }
DbSet PlatformPaymentChannels { get; }
DbSet PlatformApprovalPolicies { get; }
DbSet PlatformApprovalRequests { get; }
DbSet PlatformConfigurationDefinitions { get; }
DbSet PlatformConfigurationVersions { get; }
DbSet PlatformNotificationTemplates { get; }
DbSet PlatformNotificationDeliveries { get; }
DbSet SaasFeatures { get; }
DbSet PermissionModules { get; }
DbSet SaasOfferings { get; }
DbSet SaasOfferingVersions { get; }
DbSet SaasOfferingVersionFeatures { get; }
DbSet SaasFeatureLimitDefinitions { get; }
DbSet SaasOfferingVersionLimits { get; }
DbSet TenantSaasSubscriptions { get; }
DbSet TenantSaasSubscriptionItems { get; }
DbSet TenantFeatureOverrides { get; }
DbSet TenantFeatureUsages { get; }
DbSet PlatformBillingQuotes { get; }
DbSet PlatformBillingQuoteItems { get; }
DbSet PlatformBillingOrders { get; }
DbSet PlatformBillingOrderItems { get; }
DbSet PlatformBillingPayments { get; }
DbSet PlatformBillingPaymentEvents { get; }
DbSet PlatformBillingRefunds { get; }
DbSet PlatformBillingInvoices { get; }
DbSet PocketBaseImportRuns { get; }
DbSet PocketBaseRawRecords { get; }
DbSet PocketBaseImportIssues { get; }
}
// Explicit orchestration capabilities. These are intentionally limited to control-plane and bootstrap workflows;
// feature modules must consume the owned interfaces above directly.
public interface IPlatformAdministrationPersistence : IIdentityPersistence, ITenancyPersistence,
ITenantAdministrationPersistence, IJobsOperationsPersistence, IPlatformControlPlanePersistence
{
}
public interface IPlatformQuestionBankAdministrationPersistence : IQuestionBankPersistence,
IContentAssetPersistence, ITenancyPersistence, IJobsOperationsPersistence
{
}
public interface IPlatformTenantCapabilitiesPersistence : IIdentityPersistence, ITenancyPersistence,
ICommercePersistence, IGrowthPersistence, IJobsOperationsPersistence, IPlatformControlPlanePersistence
{
}
public interface IPlatformBillingPersistence : ITenancyPersistence, ITenantAdministrationPersistence,
IJobsOperationsPersistence, IPlatformControlPlanePersistence
{
}
public interface IOwnerActivationPersistence : IIdentityPersistence, ITenancyPersistence,
ITenantAdministrationPersistence, IJobsOperationsPersistence
{
}
public interface IBootstrapPersistence : IIdentityPersistence, ITenancyPersistence,
ITenantAdministrationPersistence, ICommercePersistence, IGrowthPersistence, IJobsOperationsPersistence,
IPlatformControlPlanePersistence
{
}