forked from xiongyuxing/tiku-backend.net
- Added tags to BrowserAuthController for browser authentication endpoints. - Added tags to CatalogController for public catalog access. - Added tags to CommerceController for student transaction operations. - Added tags to CommissionController for tenant commission management. - Added tags to CrmController for tenant CRM functionalities. - Added tags to HealthController for system health checks. - Added tags to LearningController for student learning resources. - Added tags to MeController for current user information. - Added tags to PlatformAdminController for platform management. - Introduced PlatformBackofficeController for backend permissions management. - Added tags to PlatformBillingCallbackController for billing callbacks. - Added tags to PlatformPaymentSettingsController for payment settings management. - Added tags to PlatformSaasController for SaaS package management. - Added tags to PlatformTenantCapabilitiesController for tenant capabilities. - Added tags to PointsController for student points management. - Added tags to ProfileController for student profile management. - Added tags to QuestionVideosController for question video resources. - Added tags to ReferralController for referral growth management. - Added tags to RuntimeController for runtime configurations. - Added tags to ScorelineController for scoreline management. - Added tags to TaxonomyController for category management. - Added tags to TenantAdminDirectController for tenant operations management. - Introduced TenantBackofficeController for tenant backend permissions. - Added tags to TenantBillingController for tenant billing operations. - Added tags to TenantCommerceController for tenant commerce operations. - Added tags to TenantContentController for tenant content management. - Added tags to TenantContentDirectController for direct content management. - Added tags to TenantFrontendConfigController for frontend configurations. - Added tags to TenantOnboardingController for onboarding guidance. - Added tags to TenantPublicController for public tenant configurations. - Added tags to TenantsController for current tenant information. - Added tags to VideosController for student video resources.
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Tiku.Application.Security;
|
|
using Tiku.Application.Tenancy;
|
|
|
|
namespace Tiku.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Tags("租户端-运行时配置")]
|
|
[AllowAnonymous]
|
|
[Produces("application/json")]
|
|
[Route("api/runtime")]
|
|
public sealed class RuntimeController(
|
|
ITenantContext tenantContext,
|
|
ITenantFrontendConfigService frontendConfigService) : ControllerBase
|
|
{
|
|
[HttpGet("bootstrap")]
|
|
[EndpointSummary("获取租户前端运行时配置")]
|
|
[ProducesResponseType<TenantRuntimeBootstrap>(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status304NotModified)]
|
|
[ProducesResponseType<ProblemDetails>(StatusCodes.Status404NotFound)]
|
|
public async Task<ActionResult<TenantRuntimeBootstrap>> Bootstrap(CancellationToken cancellationToken)
|
|
{
|
|
if (!tenantContext.TenantId.HasValue)
|
|
{
|
|
return NotFound(new ProblemDetails
|
|
{
|
|
Title = "Tenant was not found.",
|
|
Status = StatusCodes.Status404NotFound
|
|
});
|
|
}
|
|
|
|
var runtime = await frontendConfigService.GetRuntimeAsync(
|
|
tenantContext.TenantId.Value,
|
|
cancellationToken);
|
|
var etag = $"\"{runtime.TenantCode}-{runtime.ConfigVersion}\"";
|
|
if (Request.Headers.IfNoneMatch.Any(value => string.Equals(value, etag, StringComparison.Ordinal)))
|
|
{
|
|
return StatusCode(StatusCodes.Status304NotModified);
|
|
}
|
|
|
|
Response.Headers.ETag = etag;
|
|
Response.Headers.CacheControl = "public,max-age=60,must-revalidate";
|
|
return Ok(runtime);
|
|
}
|
|
}
|