refactor: 管理端去租户过滤并Portal化RBAC菜单

This commit is contained in:
2026-01-29 10:46:49 +00:00
parent ea9c20d8a9
commit b3639ff34b
115 changed files with 1106 additions and 1092 deletions

View File

@@ -76,7 +76,8 @@ public sealed class CreateIdentityUserCommandHandler(
// 5. 校验角色合法性
if (roleIds.Length > 0)
{
var roles = await roleRepository.GetByIdsAsync(tenantId, roleIds, cancellationToken);
var portal = PortalType.Tenant;
var roles = await roleRepository.GetByIdsAsync(portal, tenantId, roleIds, cancellationToken);
if (roles.Count != roleIds.Length)
{
throw new BusinessException(ErrorCodes.BadRequest, "角色列表包含无效项");
@@ -84,9 +85,11 @@ public sealed class CreateIdentityUserCommandHandler(
}
// 6. 创建用户实体
var userPortal = PortalType.Tenant;
var user = new IdentityUser
{
Id = idGenerator.NextId(),
Portal = userPortal,
TenantId = tenantId,
Account = account,
DisplayName = displayName,
@@ -139,7 +142,7 @@ public sealed class CreateIdentityUserCommandHandler(
// 9. 绑定角色
if (roleIds.Length > 0)
{
await userRoleRepository.ReplaceUserRolesAsync(tenantId, user.Id, roleIds, cancellationToken);
await userRoleRepository.ReplaceUserRolesAsync(userPortal, tenantId, user.Id, roleIds, cancellationToken);
}
// 10. 返回用户详情
@@ -147,6 +150,7 @@ public sealed class CreateIdentityUserCommandHandler(
return detail ?? new UserDetailDto
{
UserId = user.Id,
Portal = user.Portal,
TenantId = user.TenantId,
MerchantId = user.MerchantId,
Account = user.Account,