forked from xiongyuxing/tiku-backend.net
78 lines
1.9 KiB
C#
78 lines
1.9 KiB
C#
using System.Text.Json;
|
|
using Tiku.Application.Backoffice;
|
|
using Tiku.Domain.Operations;
|
|
|
|
namespace Tiku.Api.Contracts;
|
|
|
|
/// <summary>
|
|
/// 创建或更新后台角色请求。
|
|
/// </summary>
|
|
public sealed class UpsertBackofficeRoleDto
|
|
{
|
|
/// <summary>
|
|
/// ID。
|
|
/// </summary>
|
|
public Guid? Id { get; set; }
|
|
/// <summary>
|
|
/// 编码。
|
|
/// </summary>
|
|
public string Code { get; set; } = string.Empty;
|
|
/// <summary>
|
|
/// 名称。
|
|
/// </summary>
|
|
public string Name { get; set; } = string.Empty;
|
|
/// <summary>
|
|
/// 状态。
|
|
/// </summary>
|
|
public BackendRoleStatus Status { get; set; } = BackendRoleStatus.Active;
|
|
/// <summary>
|
|
/// 说明。
|
|
/// </summary>
|
|
public string? Description { get; set; }
|
|
/// <summary>
|
|
/// 数据范围配置。
|
|
/// </summary>
|
|
public JsonElement? DataScope { get; set; }
|
|
|
|
public UpsertBackofficeRoleCommand ToCommand()
|
|
{
|
|
return new UpsertBackofficeRoleCommand(Id, Code, Name, Status, Description, DataScope);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 替换角色权限绑定请求。
|
|
/// </summary>
|
|
public sealed class ReplaceRoleBindingsDto
|
|
{
|
|
/// <summary>
|
|
/// 权限编码列表。
|
|
/// </summary>
|
|
public IReadOnlyCollection<string> PermissionCodes { get; set; } = [];
|
|
/// <summary>
|
|
/// 菜单编码列表。
|
|
/// </summary>
|
|
public IReadOnlyCollection<string> MenuCodes { get; set; } = [];
|
|
|
|
public ReplaceRoleBindingsCommand ToCommand(Guid roleId)
|
|
{
|
|
return new ReplaceRoleBindingsCommand(roleId, PermissionCodes, MenuCodes);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 替换用户角色请求。
|
|
/// </summary>
|
|
public sealed class ReplaceUserRolesDto
|
|
{
|
|
/// <summary>
|
|
/// 角色 ID 列表。
|
|
/// </summary>
|
|
public IReadOnlyCollection<Guid> RoleIds { get; set; } = [];
|
|
|
|
public ReplaceUserRolesCommand ToCommand(Guid userId)
|
|
{
|
|
return new ReplaceUserRolesCommand(userId, RoleIds);
|
|
}
|
|
}
|