feat(saas): implement marketplace and tenant onboarding

This commit is contained in:
2026-07-29 13:58:59 +08:00
parent 76606029e2
commit 6db200a2fc
145 changed files with 16862 additions and 94529 deletions

View File

@@ -0,0 +1,26 @@
namespace Tiku.Application.Security;
public static class FeatureQuotaConsumptionExtensions
{
public static async Task<bool> ConsumeQuotaIfConfiguredAsync(
this IFeatureAccessService featureAccessService,
Guid tenantId,
string metricCode,
long amount = 1,
CancellationToken cancellationToken = default)
{
var configured = (await featureAccessService.GetQuotaSummaryAsync(tenantId, cancellationToken))
.Any(item => string.Equals(item.MetricCode, metricCode, StringComparison.Ordinal));
if (!configured)
{
return false;
}
if (!await featureAccessService.TryConsumeQuotaAsync(tenantId, metricCode, amount, cancellationToken))
{
throw new FeatureAccessException("The tenant feature quota has been exhausted.", "feature_quota_exhausted");
}
return true;
}
}