Files
meezi/src/Meezi.API/Controllers/CafePlatformController.cs
T

40 lines
1.2 KiB
C#
Raw Normal View History

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));
}
}