forked from gongxuegit/tiku-backend.net
feat(security): complete capability messaging workflows
This commit is contained in:
@@ -45,6 +45,16 @@ public sealed class HealthController(
|
||||
var outboxPending = database
|
||||
? await dbContext.Set<OutboxMessage>().CountAsync(cancellationToken)
|
||||
: -1;
|
||||
var outboxOldestSentTime = database
|
||||
? await dbContext.Set<OutboxMessage>()
|
||||
.Select(message => (DateTime?)message.SentTime)
|
||||
.MinAsync(cancellationToken)
|
||||
: null;
|
||||
var outboxOldestAgeSeconds = outboxOldestSentTime is null
|
||||
? 0
|
||||
: Math.Max(0, (DateTimeOffset.UtcNow - new DateTimeOffset(outboxOldestSentTime.Value)).TotalSeconds);
|
||||
var outboxAlert = outboxPending >= messagingOptions.OutboxBacklogAlertCount ||
|
||||
outboxOldestAgeSeconds >= messagingOptions.OutboxOldestMessageAlertSeconds;
|
||||
var ready = database && redis && rabbitMq;
|
||||
var response = new
|
||||
{
|
||||
@@ -52,7 +62,14 @@ public sealed class HealthController(
|
||||
database,
|
||||
redis = new { configured = redisSecurityStore.IsConfigured, ready = redis },
|
||||
rabbitMq = new { configured = messagingOptions.IsConfigured, ready = rabbitMq },
|
||||
outbox = new { pending = outboxPending },
|
||||
outbox = new
|
||||
{
|
||||
pending = outboxPending,
|
||||
oldestAgeSeconds = Math.Round(outboxOldestAgeSeconds, 1),
|
||||
alert = outboxAlert,
|
||||
backlogAlertCount = messagingOptions.OutboxBacklogAlertCount,
|
||||
oldestMessageAlertSeconds = messagingOptions.OutboxOldestMessageAlertSeconds
|
||||
},
|
||||
checkedAt = DateTimeOffset.UtcNow
|
||||
};
|
||||
return ready ? Ok(response) : StatusCode(StatusCodes.Status503ServiceUnavailable, response);
|
||||
|
||||
@@ -89,6 +89,19 @@ public sealed class PlatformAdminController(
|
||||
return Ok(await platformAdminService.GetPlansAsync(ResolveActor(), query.ToQuery(), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpPut("plans/{planCode}/modules")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformTenantManage)]
|
||||
[EndpointSummary("替换 SaaS 套餐模块权益")]
|
||||
[ProducesResponseType<PlatformPlanModuleEntitlements>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<PlatformPlanModuleEntitlements>> ReplacePlanModules(
|
||||
string planCode,
|
||||
ReplacePlatformPlanModulesDto request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await platformAdminService.ReplacePlanModulesAsync(
|
||||
ResolveActor(), request.ToCommand(planCode), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpPost("subscriptions")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformTenantManage)]
|
||||
[EndpointSummary("创建或调整租户订阅")]
|
||||
@@ -100,6 +113,20 @@ public sealed class PlatformAdminController(
|
||||
return Ok(await platformAdminService.UpsertSubscriptionAsync(ResolveActor(), request.ToCommand(), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpPut("tenants/{tenantId:guid}/module-overrides/{moduleCode}")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformTenantManage)]
|
||||
[EndpointSummary("设置租户模块覆盖")]
|
||||
[ProducesResponseType<PlatformTenantModuleOverrideItem>(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<PlatformTenantModuleOverrideItem>> UpsertTenantModuleOverride(
|
||||
Guid tenantId,
|
||||
string moduleCode,
|
||||
UpsertPlatformTenantModuleOverrideDto request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return Ok(await platformAdminService.UpsertTenantModuleOverrideAsync(
|
||||
ResolveActor(), request.ToCommand(tenantId, moduleCode), cancellationToken));
|
||||
}
|
||||
|
||||
[HttpGet("domains")]
|
||||
[Authorize(Policy = BackendPermissions.PlatformTenantManage)]
|
||||
[EndpointSummary("查询租户域名状态")]
|
||||
|
||||
Reference in New Issue
Block a user