Register all active platform services and base features in core DB so admin can manage them, add delivery/hospitality/sports-center backend phases, update apps catalog and production deploy tooling. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
"""Delivery settings APIs — Phase 10.0."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_db, get_pagination, require_tenant
|
|
from app.api.permissions import require_permissions
|
|
from app.permissions.definitions import SETTINGS_MANAGE, SETTINGS_VIEW
|
|
from app.schemas.foundation import DeliverySettingRead, DeliverySettingUpsert
|
|
from app.services.foundation import DeliverySettingService
|
|
from shared.pagination import PaginationParams
|
|
from shared.security import CurrentUser
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.put("", response_model=DeliverySettingRead, status_code=status.HTTP_200_OK)
|
|
async def upsert_setting(
|
|
body: DeliverySettingUpsert,
|
|
tenant_id: UUID = Depends(require_tenant),
|
|
db: AsyncSession = Depends(get_db),
|
|
user: CurrentUser = Depends(require_permissions(SETTINGS_MANAGE)),
|
|
):
|
|
return await DeliverySettingService(db).upsert(tenant_id, body, actor=user)
|
|
|
|
|
|
@router.get("", response_model=list[DeliverySettingRead])
|
|
async def list_settings(
|
|
tenant_id: UUID = Depends(require_tenant),
|
|
pagination: PaginationParams = Depends(get_pagination),
|
|
db: AsyncSession = Depends(get_db),
|
|
_user: CurrentUser = Depends(require_permissions(SETTINGS_VIEW)),
|
|
):
|
|
return await DeliverySettingService(db).list(
|
|
tenant_id, offset=pagination.offset, limit=pagination.page_size
|
|
)
|