using System.ComponentModel.DataAnnotations;
using ERPCore.Domain.Enums;

namespace ERPCore.Dtos.Rbac;

public sealed record RoleDto(
    int RoleId, string Code, string Name, bool IsSystemRole, EntityStatus Status,
    DateTime CreatedAt, DateTime? UpdatedAt);

public sealed class CreateRoleRequest
{
    [Required, StringLength(50)] public string Code { get; set; } = string.Empty;
    [Required, StringLength(200)] public string Name { get; set; } = string.Empty;
}

public sealed class UpdateRoleRequest
{
    [Required, StringLength(50)] public string Code { get; set; } = string.Empty;
    [Required, StringLength(200)] public string Name { get; set; } = string.Empty;
}

public sealed class UpdateRoleStatusRequest
{
    [Required, EnumDataType(typeof(EntityStatus))] public EntityStatus Status { get; set; }
}

/// <summary>Replaces a role's full permission set (checkbox-tree save from the frontend).</summary>
public sealed class AssignRolePermissionsRequest
{
    public List<int> NavItemIds { get; set; } = new();
    public List<int> SubNavItemIds { get; set; } = new();
}

public sealed record RolePermissionsDto(int RoleId, List<int> NavItemIds, List<int> SubNavItemIds);
