feat(learning): harden access and practice sessions

This commit is contained in:
2026-08-05 14:01:36 +08:00
parent 603bc24c26
commit df31c3a669
88 changed files with 72411 additions and 543 deletions

View File

@@ -0,0 +1,75 @@
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<IReadOnlyCollection<LearningDictionaryItem>> BusinessLines(CancellationToken cancellationToken) =>
service.GetBusinessLinesAsync(cancellationToken);
[HttpPut("business-lines")]
public Task<LearningDictionaryItem> UpsertBusinessLine(
UpsertBusinessLineDto request,
CancellationToken cancellationToken) =>
service.UpsertBusinessLineAsync(request.ToCommand(), cancellationToken);
[HttpGet("market-regions")]
public Task<IReadOnlyCollection<LearningDictionaryItem>> MarketRegions(CancellationToken cancellationToken) =>
service.GetMarketRegionsAsync(cancellationToken);
[HttpPut("market-regions")]
public Task<LearningDictionaryItem> UpsertMarketRegion(
UpsertMarketRegionDto request,
CancellationToken cancellationToken) =>
service.UpsertMarketRegionAsync(request.ToCommand(), cancellationToken);
[HttpGet("tenants/{tenantId:guid}/license")]
public Task<TenantLearningLicenseItem?> TenantLicense(
Guid tenantId,
CancellationToken cancellationToken) =>
service.GetTenantLicenseAsync(tenantId, cancellationToken);
[HttpPut("tenants/{tenantId:guid}/license")]
public Task<TenantLearningLicenseItem> UpsertTenantLicense(
Guid tenantId,
UpsertTenantLearningLicenseDto request,
CancellationToken cancellationToken) =>
service.UpsertTenantLicenseAsync(request.ToCommand(tenantId), cancellationToken);
[HttpGet("tenants/{tenantId:guid}/content-slices")]
public Task<IReadOnlyCollection<ContentSliceItem>> ContentSlices(
Guid tenantId,
CancellationToken cancellationToken) =>
service.GetContentSlicesAsync(tenantId, cancellationToken);
[HttpPut("tenants/{tenantId:guid}/content-slices")]
public Task<ContentSliceItem> UpsertContentSlice(
Guid tenantId,
UpsertContentSliceDto request,
CancellationToken cancellationToken) =>
service.UpsertContentSliceAsync(request.ToCommand(tenantId), cancellationToken);
[HttpGet("tenants/{tenantId:guid}/products")]
public Task<IReadOnlyCollection<LearningProductItem>> Products(
Guid tenantId,
CancellationToken cancellationToken) =>
service.GetProductsAsync(tenantId, cancellationToken);
[HttpPut("tenants/{tenantId:guid}/products")]
public Task<LearningProductItem> UpsertProduct(
Guid tenantId,
UpsertLearningProductDto request,
CancellationToken cancellationToken) =>
service.UpsertProductAsync(request.ToCommand(tenantId), cancellationToken);
}