forked from xiongyuxing/tiku-backend.net
- 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.
78 lines
3.4 KiB
C#
78 lines
3.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Tiku.Api.Contracts;
|
|
using Tiku.Application.Backoffice;
|
|
using Tiku.Application.Security;
|
|
|
|
namespace Tiku.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Tags("租户端-后台权限")]
|
|
[Route("api/backoffice/tenant")]
|
|
public sealed class TenantBackofficeController(
|
|
IBackofficeService backofficeService,
|
|
ICurrentAccessContext currentAccessContext) : ControllerBase
|
|
{
|
|
[HttpGet("ui-bootstrap")]
|
|
[Authorize(Policy = TikuPolicies.TenantBackofficeBootstrap)]
|
|
[EndpointSummary("查询租户后台菜单与权限")]
|
|
[EndpointDescription("返回当前租户管理员可见的后台菜单、权限和模块启用状态。")]
|
|
[ProducesResponseType<BackofficeUiBootstrap>(StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<BackofficeUiBootstrap>> GetUiBootstrap(CancellationToken cancellationToken)
|
|
{
|
|
return Ok(await backofficeService.GetTenantUiBootstrapAsync(
|
|
await currentAccessContext.GetAsync(cancellationToken),
|
|
cancellationToken));
|
|
}
|
|
|
|
[HttpGet("bootstrap")]
|
|
[Authorize(Policy = BackendPermissions.TenantRoleManage)]
|
|
[EndpointSummary("查询租户角色管理初始化数据")]
|
|
[ProducesResponseType<BackofficeBootstrap>(StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<BackofficeBootstrap>> GetBootstrap(CancellationToken cancellationToken)
|
|
{
|
|
return Ok(await backofficeService.GetTenantBootstrapAsync(await ResolveActorAsync(cancellationToken), cancellationToken));
|
|
}
|
|
|
|
[HttpPost("roles")]
|
|
[Authorize(Policy = BackendPermissions.TenantRoleManage)]
|
|
[EndpointSummary("创建或更新租户后台角色")]
|
|
[ProducesResponseType<BackofficeRoleItem>(StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<BackofficeRoleItem>> UpsertRole(
|
|
UpsertBackofficeRoleDto request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
return Ok(await backofficeService.UpsertTenantRoleAsync(await ResolveActorAsync(cancellationToken), request.ToCommand(), cancellationToken));
|
|
}
|
|
|
|
[HttpPut("roles/{roleId:guid}/bindings")]
|
|
[Authorize(Policy = BackendPermissions.TenantRoleManage)]
|
|
[EndpointSummary("替换租户后台角色权限绑定")]
|
|
[ProducesResponseType<BackofficeRoleItem>(StatusCodes.Status200OK)]
|
|
public async Task<ActionResult<BackofficeRoleItem>> ReplaceRoleBindings(
|
|
Guid roleId,
|
|
ReplaceRoleBindingsDto request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
return Ok(await backofficeService.ReplaceTenantRoleBindingsAsync(await ResolveActorAsync(cancellationToken), request.ToCommand(roleId), cancellationToken));
|
|
}
|
|
|
|
[HttpPut("users/{userId:guid}/roles")]
|
|
[Authorize(Policy = BackendPermissions.TenantRoleManage)]
|
|
[EndpointSummary("替换租户用户后台角色")]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
public async Task<IActionResult> ReplaceUserRoles(
|
|
Guid userId,
|
|
ReplaceUserRolesDto request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
await backofficeService.ReplaceTenantUserRolesAsync(await ResolveActorAsync(cancellationToken), request.ToCommand(userId), cancellationToken);
|
|
return NoContent();
|
|
}
|
|
|
|
private async Task<BackofficeActor> ResolveActorAsync(CancellationToken cancellationToken)
|
|
{
|
|
return BackofficeActor.FromTenantAccess(await currentAccessContext.GetAsync(cancellationToken));
|
|
}
|
|
}
|