Files
tiku-backend.net/Tiku.Api/Controllers/PlatformTenantCapabilitiesController.cs
xiong 4bea745b79 feat: Add tags and endpoint summaries to various controllers for better API documentation
- Added tags to BrowserAuthController for browser authentication endpoints.
- Added tags to CatalogController for public catalog access.
- Added tags to CommerceController for student transaction operations.
- Added tags to CommissionController for tenant commission management.
- Added tags to CrmController for tenant CRM functionalities.
- Added tags to HealthController for system health checks.
- Added tags to LearningController for student learning resources.
- Added tags to MeController for current user information.
- Added tags to PlatformAdminController for platform management.
- Introduced PlatformBackofficeController for backend permissions management.
- Added tags to PlatformBillingCallbackController for billing callbacks.
- Added tags to PlatformPaymentSettingsController for payment settings management.
- Added tags to PlatformSaasController for SaaS package management.
- Added tags to PlatformTenantCapabilitiesController for tenant capabilities.
- Added tags to PointsController for student points management.
- Added tags to ProfileController for student profile management.
- Added tags to QuestionVideosController for question video resources.
- Added tags to ReferralController for referral growth management.
- Added tags to RuntimeController for runtime configurations.
- Added tags to ScorelineController for scoreline management.
- Added tags to TaxonomyController for category management.
- Added tags to TenantAdminDirectController for tenant operations management.
- Introduced TenantBackofficeController for tenant backend permissions.
- Added tags to TenantBillingController for tenant billing operations.
- Added tags to TenantCommerceController for tenant commerce operations.
- Added tags to TenantContentController for tenant content management.
- Added tags to TenantContentDirectController for direct content management.
- Added tags to TenantFrontendConfigController for frontend configurations.
- Added tags to TenantOnboardingController for onboarding guidance.
- Added tags to TenantPublicController for public tenant configurations.
- Added tags to TenantsController for current tenant information.
- Added tags to VideosController for student video resources.
2026-07-29 16:16:27 +08:00

149 lines
7.8 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tiku.Api.Contracts;
using Tiku.Application.PlatformAdmin;
using Tiku.Application.Security;
using Tiku.Application.Tenancy;
using Tiku.Domain.Growth;
using Tiku.Domain.Tenancy;
namespace Tiku.Api.Controllers;
[ApiController]
[Tags("平台端-租户 CRM 能力")]
[Authorize(Policy = TikuPolicies.PlatformBackofficeBootstrap)]
[Produces("application/json")]
[Route("api/platform-admin/tenant-capabilities/crm")]
public sealed class PlatformAdminCrmController(
IPlatformCrmAdminService crmService,
ICurrentUser currentUser) : ControllerBase
{
[HttpGet("configs")]
[EndpointSummary("查询租户 CRM 配置")]
[Authorize(Policy = BackendPermissions.PlatformCrmRead)]
public Task<PlatformTenantCapabilityList<PlatformCrmConfigItem>> Configs([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
crmService.GetConfigsAsync(Actor(), query.ToQuery(), cancellationToken);
[HttpPut("configs")]
[EndpointSummary("新增或更新租户 CRM 配置")]
[Authorize(Policy = BackendPermissions.PlatformCrmWrite)]
public Task<PlatformCrmConfigItem> UpsertConfig(UpsertPlatformCrmConfigDto request, CancellationToken cancellationToken) =>
crmService.UpsertConfigAsync(Actor(), request.ToCommand(), cancellationToken);
[HttpGet("leads")]
[EndpointSummary("查询租户 CRM 线索队列")]
[Authorize(Policy = BackendPermissions.PlatformCrmRead)]
public Task<PlatformTenantCapabilityList<CrmWebhookQueueItem>> Leads([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
crmService.GetLeadsAsync(Actor(), query.ToQuery(), cancellationToken);
[HttpPost("leads/retry")]
[EndpointSummary("重试租户 CRM 线索推送")]
[Authorize(Policy = BackendPermissions.PlatformCrmWrite)]
public Task<CrmWebhookQueueItem> RetryLead(RetryPlatformCrmLeadDto request, CancellationToken cancellationToken) =>
crmService.RetryLeadAsync(Actor(), request.ToCommand(), cancellationToken);
[HttpGet("logs")]
[EndpointSummary("查询租户 CRM 推送日志")]
[Authorize(Policy = BackendPermissions.PlatformCrmRead)]
public Task<PlatformTenantCapabilityList<CrmWebhookLog>> Logs([FromQuery] PlatformCrmLogQueryDto query, CancellationToken cancellationToken) =>
crmService.GetLogsAsync(Actor(), query.TenantId, query.QueueId, query.Limit, cancellationToken);
private PlatformCapabilityActor Actor() => currentUser.UserId is { } userId
? new PlatformCapabilityActor(userId)
: throw new PlatformCapabilityException("Platform actor was not resolved.", "platform_access_denied");
}
[ApiController]
[Tags("平台端-租户短信能力")]
[Authorize(Policy = TikuPolicies.PlatformBackofficeBootstrap)]
[Produces("application/json")]
[Route("api/platform-admin/tenant-capabilities/sms")]
public sealed class PlatformAdminSmsController(
IPlatformSmsAdminService smsService,
ICurrentUser currentUser) : ControllerBase
{
[HttpGet("channels")]
[EndpointSummary("查询租户短信渠道")]
[Authorize(Policy = BackendPermissions.PlatformSmsRead)]
public Task<PlatformTenantCapabilityList<PlatformSmsChannelItem>> Channels([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
smsService.GetChannelsAsync(Actor(), query.ToQuery(), cancellationToken);
[HttpPut("channels")]
[EndpointSummary("新增或更新租户短信渠道")]
[Authorize(Policy = BackendPermissions.PlatformSmsWrite)]
public Task<PlatformSmsChannelItem> UpsertChannel(UpsertPlatformSmsChannelDto request, CancellationToken cancellationToken) =>
smsService.UpsertChannelAsync(Actor(), request.ToCommand(), cancellationToken);
[HttpPost("channels/{id:guid}/disable")]
[EndpointSummary("禁用租户短信渠道")]
[Authorize(Policy = BackendPermissions.PlatformSmsWrite)]
public Task<PlatformSmsChannelItem> DisableChannel(Guid id, CancellationToken cancellationToken) =>
smsService.DisableChannelAsync(Actor(), id, cancellationToken);
[HttpGet("templates")]
[EndpointSummary("查询租户短信模板")]
[Authorize(Policy = BackendPermissions.PlatformSmsRead)]
public Task<PlatformTenantCapabilityList<PlatformSmsTemplateItem>> Templates([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
smsService.GetTemplatesAsync(Actor(), query.ToQuery(), cancellationToken);
[HttpPut("templates")]
[EndpointSummary("新增或更新租户短信模板")]
[Authorize(Policy = BackendPermissions.PlatformSmsWrite)]
public Task<PlatformSmsTemplateItem> UpsertTemplate(UpsertPlatformSmsTemplateDto request, CancellationToken cancellationToken) =>
smsService.UpsertTemplateAsync(Actor(), request.ToCommand(), cancellationToken);
[HttpPost("templates/{id:guid}/submit-review")]
[EndpointSummary("提交租户短信模板审核")]
[Authorize(Policy = BackendPermissions.PlatformSmsWrite)]
public Task<PlatformSmsTemplateItem> SubmitTemplateReview(Guid id, CancellationToken cancellationToken) =>
smsService.SubmitTemplateReviewAsync(Actor(), id, cancellationToken);
[HttpPost("templates/{id:guid}/disable")]
[EndpointSummary("禁用租户短信模板")]
[Authorize(Policy = BackendPermissions.PlatformSmsWrite)]
public Task<PlatformSmsTemplateItem> DisableTemplate(Guid id, CancellationToken cancellationToken) =>
smsService.DisableTemplateAsync(Actor(), id, cancellationToken);
[HttpGet("logs")]
[EndpointSummary("查询租户短信发送日志")]
[Authorize(Policy = BackendPermissions.PlatformSmsRead)]
public Task<PlatformTenantCapabilityList<SmsSendLog>> Logs([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
smsService.GetLogsAsync(Actor(), query.ToQuery(), cancellationToken);
private PlatformCapabilityActor Actor() => currentUser.UserId is { } userId
? new PlatformCapabilityActor(userId)
: throw new PlatformCapabilityException("Platform actor was not resolved.", "platform_access_denied");
}
[ApiController]
[Tags("平台端-租户支付能力")]
[Authorize(Policy = TikuPolicies.PlatformBackofficeBootstrap)]
[Produces("application/json")]
[Route("api/platform-admin/tenant-capabilities/payments")]
public sealed class PlatformAdminTenantPaymentSettingsController(
IPlatformTenantPaymentAdminService paymentService,
ICurrentUser currentUser) : ControllerBase
{
[HttpGet("apps")]
[EndpointSummary("查询租户支付应用")]
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
public Task<PlatformTenantCapabilityList<TenantExternalProviderItem>> Apps([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
paymentService.GetAppsAsync(Actor(), query.ToQuery(), cancellationToken);
[HttpPut("apps")]
[EndpointSummary("新增或更新租户支付应用")]
[Authorize(Policy = BackendPermissions.PlatformPaymentWrite)]
public Task<TenantExternalProviderItem> UpsertApp(UpsertPlatformTenantPaymentAppDto request, CancellationToken cancellationToken) =>
paymentService.UpsertAppAsync(Actor(), request.TenantId, request.ToCommand(), cancellationToken);
[HttpGet("events")]
[EndpointSummary("查询租户支付事件")]
[Authorize(Policy = BackendPermissions.PlatformPaymentRead)]
public Task<PlatformTenantCapabilityList<object>> Events([FromQuery] PlatformCapabilityQueryDto query, CancellationToken cancellationToken) =>
paymentService.GetEventsAsync(Actor(), query.ToQuery(), cancellationToken);
private PlatformCapabilityActor Actor() => currentUser.UserId is { } userId
? new PlatformCapabilityActor(userId)
: throw new PlatformCapabilityException("Platform actor was not resolved.", "platform_access_denied");
}