feat: plan limits, café location, nearby API, Iran map section
CI/CD / CI · API (dotnet build + test) (push) Successful in 56s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 49s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m4s
CI/CD / CI · Admin Web (tsc) (push) Successful in 34s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 50s
CI/CD / Deploy · all services (push) Successful in 3m15s
CI/CD / CI · API (dotnet build + test) (push) Successful in 56s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 49s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m4s
CI/CD / CI · Admin Web (tsc) (push) Successful in 34s
CI/CD / CI · Website (tsc) (push) Successful in 44s
CI/CD / CI · Koja (tsc) (push) Successful in 50s
CI/CD / Deploy · all services (push) Successful in 3m15s
• PlanLimits: add MaxMenuCategories (Free→3), MaxMenuItems (Free→30), CanAccessCrm and CanAccessStatistics (Pro+ only) • MenuController: enforce category/item limits before create (403 + PLAN_LIMIT_REACHED) • Cafe entity + EF migration: Latitude/Longitude (double?, nullable) • CafeSettingsController: PATCH accepts lat/lng with range validation • PublicController: GET /api/public/map-markers (marketing SVG map feed) and GET /api/public/nearby (Koja nearby-cafés with Haversine sort) • Dashboard settings: location card with OSM iframe preview + Neshan link • Website homepage: IranMapSection — stylised SVG silhouette with SMIL-animated blinking dots at real café coordinates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Meezi.API.Models.Menu;
|
||||
using Meezi.API.Services;
|
||||
using Meezi.Core.Constants;
|
||||
using Meezi.Core.Enums;
|
||||
using Meezi.Core.Interfaces;
|
||||
using Meezi.Infrastructure.Data;
|
||||
using Meezi.Shared;
|
||||
|
||||
namespace Meezi.API.Controllers;
|
||||
@@ -15,17 +18,25 @@ public class MenuController : CafeApiControllerBase
|
||||
private readonly IMenuAi3dGenerationService _menuAi3d;
|
||||
private readonly IValidator<CreateMenuCategoryRequest> _createCategoryValidator;
|
||||
private readonly IValidator<CreateMenuItemRequest> _createItemValidator;
|
||||
private readonly AppDbContext _db;
|
||||
|
||||
private const string CategoryLimitMessage =
|
||||
"محدودیت دستهبندی پلن رایگان (۳ دسته). برای افزودن دستهبندی بیشتر، پلن خود را ارتقا دهید.";
|
||||
private const string ItemLimitMessage =
|
||||
"محدودیت آیتم منو پلن رایگان (۳۰ آیتم). برای افزودن آیتم بیشتر، پلن خود را ارتقا دهید.";
|
||||
|
||||
public MenuController(
|
||||
IMenuService menuService,
|
||||
IMenuAi3dGenerationService menuAi3d,
|
||||
IValidator<CreateMenuCategoryRequest> createCategoryValidator,
|
||||
IValidator<CreateMenuItemRequest> createItemValidator)
|
||||
IValidator<CreateMenuItemRequest> createItemValidator,
|
||||
AppDbContext db)
|
||||
{
|
||||
_menuService = menuService;
|
||||
_menuAi3d = menuAi3d;
|
||||
_createCategoryValidator = createCategoryValidator;
|
||||
_createItemValidator = createItemValidator;
|
||||
_db = db;
|
||||
}
|
||||
|
||||
[HttpGet("categories")]
|
||||
@@ -47,6 +58,17 @@ public class MenuController : CafeApiControllerBase
|
||||
var validation = await _createCategoryValidator.ValidateAsync(request, cancellationToken);
|
||||
if (!validation.IsValid) return BadRequest(ValidationError(validation));
|
||||
|
||||
var tier = tenant.PlanTier ?? PlanTier.Free;
|
||||
var max = PlanLimits.MaxMenuCategories(tier);
|
||||
if (max != int.MaxValue)
|
||||
{
|
||||
var count = await _db.MenuCategories.CountAsync(
|
||||
c => c.CafeId == cafeId && c.DeletedAt == null, cancellationToken);
|
||||
if (count >= max)
|
||||
return StatusCode(403, new ApiResponse<object>(false, null,
|
||||
new ApiError("PLAN_LIMIT_REACHED", CategoryLimitMessage)));
|
||||
}
|
||||
|
||||
var data = await _menuService.CreateCategoryAsync(cafeId, request, cancellationToken);
|
||||
return Ok(new ApiResponse<MenuCategoryDto>(true, data));
|
||||
}
|
||||
@@ -97,6 +119,17 @@ public class MenuController : CafeApiControllerBase
|
||||
var validation = await _createItemValidator.ValidateAsync(request, cancellationToken);
|
||||
if (!validation.IsValid) return BadRequest(ValidationError(validation));
|
||||
|
||||
var tier = tenant.PlanTier ?? PlanTier.Free;
|
||||
var max = PlanLimits.MaxMenuItems(tier);
|
||||
if (max != int.MaxValue)
|
||||
{
|
||||
var count = await _db.MenuItems.CountAsync(
|
||||
i => i.CafeId == cafeId && i.DeletedAt == null, cancellationToken);
|
||||
if (count >= max)
|
||||
return StatusCode(403, new ApiResponse<object>(false, null,
|
||||
new ApiError("PLAN_LIMIT_REACHED", ItemLimitMessage)));
|
||||
}
|
||||
|
||||
var data = await _menuService.CreateItemAsync(cafeId, request, cancellationToken);
|
||||
if (data is null) return NotFoundError("Category not found.");
|
||||
return Ok(new ApiResponse<MenuItemDto>(true, data));
|
||||
|
||||
Reference in New Issue
Block a user