2026-05-27 21:33:48 +03:30
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Meezi.Infrastructure.Services.Platform;
|
|
|
|
|
using Meezi.Core.Interfaces;
|
|
|
|
|
using Meezi.Shared;
|
|
|
|
|
|
|
|
|
|
namespace Meezi.API.Controllers;
|
|
|
|
|
|
|
|
|
|
[Route("api/cafes/{cafeId}/platform")]
|
|
|
|
|
public class CafePlatformController : CafeApiControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IPlatformCatalogService _catalog;
|
|
|
|
|
|
|
|
|
|
public CafePlatformController(IPlatformCatalogService catalog)
|
|
|
|
|
{
|
|
|
|
|
_catalog = catalog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("features")]
|
|
|
|
|
public async Task<IActionResult> GetFeatures(string cafeId, ITenantContext tenant, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (EnsureCafeAccess(cafeId, tenant) is { } denied) return denied;
|
|
|
|
|
if (tenant.PlanTier is null)
|
|
|
|
|
return Ok(new ApiResponse<object>(true, new Dictionary<string, bool>()));
|
|
|
|
|
|
|
|
|
|
var features = await _catalog.GetEffectiveFeaturesForCafeAsync(
|
|
|
|
|
cafeId,
|
|
|
|
|
tenant.PlanTier.Value,
|
|
|
|
|
cancellationToken);
|
|
|
|
|
|
|
|
|
|
return Ok(new ApiResponse<object>(true, features));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("plans")]
|
|
|
|
|
public async Task<IActionResult> GetPublicPlans(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var plans = await _catalog.GetPlansAsync(cancellationToken);
|
|
|
|
|
return Ok(new ApiResponse<object>(true, plans));
|
|
|
|
|
}
|
2026-06-12 08:16:29 +03:30
|
|
|
|
|
|
|
|
/// <summary>Feature catalog (key → display name / module group) so clients can
|
|
|
|
|
/// label the FeatureKeys returned by the plans endpoint.</summary>
|
|
|
|
|
[HttpGet("features-catalog")]
|
|
|
|
|
public async Task<IActionResult> GetFeaturesCatalog(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var features = await _catalog.GetFeaturesAsync(cancellationToken);
|
|
|
|
|
return Ok(new ApiResponse<object>(true, features));
|
|
|
|
|
}
|
2026-05-27 21:33:48 +03:30
|
|
|
}
|