using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Tiku.Api.Contracts; using Tiku.Application.Learning; using Tiku.Application.Security; namespace Tiku.Api.Controllers; [ApiController] [Tags("平台端-学习授权配置")] [Authorize(Policy = BackendPermissions.PlatformConfigurationManage)] [Produces("application/json")] [Route("api/platform/learning-access")] public sealed class PlatformLearningAccessController( IPlatformLearningAccessAdministrationService service) : ControllerBase { [HttpGet("business-lines")] public Task> BusinessLines(CancellationToken cancellationToken) => service.GetBusinessLinesAsync(cancellationToken); [HttpPut("business-lines")] public Task UpsertBusinessLine( UpsertBusinessLineDto request, CancellationToken cancellationToken) => service.UpsertBusinessLineAsync(request.ToCommand(), cancellationToken); [HttpGet("market-regions")] public Task> MarketRegions(CancellationToken cancellationToken) => service.GetMarketRegionsAsync(cancellationToken); [HttpPut("market-regions")] public Task UpsertMarketRegion( UpsertMarketRegionDto request, CancellationToken cancellationToken) => service.UpsertMarketRegionAsync(request.ToCommand(), cancellationToken); [HttpGet("tenants/{tenantId:guid}/license")] public Task TenantLicense( Guid tenantId, CancellationToken cancellationToken) => service.GetTenantLicenseAsync(tenantId, cancellationToken); [HttpPut("tenants/{tenantId:guid}/license")] public Task UpsertTenantLicense( Guid tenantId, UpsertTenantLearningLicenseDto request, CancellationToken cancellationToken) => service.UpsertTenantLicenseAsync(request.ToCommand(tenantId), cancellationToken); [HttpGet("tenants/{tenantId:guid}/content-slices")] public Task> ContentSlices( Guid tenantId, CancellationToken cancellationToken) => service.GetContentSlicesAsync(tenantId, cancellationToken); [HttpPut("tenants/{tenantId:guid}/content-slices")] public Task UpsertContentSlice( Guid tenantId, UpsertContentSliceDto request, CancellationToken cancellationToken) => service.UpsertContentSliceAsync(request.ToCommand(tenantId), cancellationToken); [HttpGet("tenants/{tenantId:guid}/products")] public Task> Products( Guid tenantId, CancellationToken cancellationToken) => service.GetProductsAsync(tenantId, cancellationToken); [HttpPut("tenants/{tenantId:guid}/products")] public Task UpsertProduct( Guid tenantId, UpsertLearningProductDto request, CancellationToken cancellationToken) => service.UpsertProductAsync(request.ToCommand(tenantId), cancellationToken); }