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