using HoneyBox.Admin.Models.Permission;

namespace HoneyBox.Admin.Services;

/// <summary>
/// 权限服务接口
/// </summary>
public interface IPermissionService
{
    /// <summary>
    /// 获取用户权限列表
    /// </summary>
    /// <param name="adminUserId">管理员ID</param>
    /// <returns>权限编码列表</returns>
    Task<List<string>> GetUserPermissionsAsync(long adminUserId);

    /// <summary>
    /// 检查用户是否拥有指定权限
    /// </summary>
    /// <param name="adminUserId">管理员ID</param>
    /// <param name="permissionCode">权限编码</param>
    /// <returns>是否拥有权限</returns>
    Task<bool> HasPermissionAsync(long adminUserId, string permissionCode);

    /// <summary>
    /// 使用户权限缓存失效
    /// </summary>
    /// <param name="adminUserId">管理员ID</param>
    void InvalidateCache(long adminUserId);

    /// <summary>
    /// 获取所有权限列表
    /// </summary>
    /// <returns>权限列表</returns>
    Task<List<PermissionDto>> GetAllPermissionsAsync();

    /// <summary>
    /// 按模块分组获取权限列表
    /// </summary>
    /// <returns>按模块分组的权限列表</returns>
    Task<Dictionary<string, List<PermissionDto>>> GetPermissionsByModuleAsync();

    /// <summary>
    /// 获取权限详情
    /// </summary>
    /// <param name="id">权限ID</param>
    /// <returns>权限详情</returns>
    Task<PermissionDto?> GetByIdAsync(long id);

    /// <summary>
    /// 创建权限
    /// </summary>
    /// <param name="request">创建请求</param>
    /// <returns>创建的权限</returns>
    Task<PermissionDto> CreateAsync(CreatePermissionRequest request);

    /// <summary>
    /// 更新权限
    /// </summary>
    /// <param name="id">权限ID</param>
    /// <param name="request">更新请求</param>
    /// <returns>更新后的权限</returns>
    Task<PermissionDto?> UpdateAsync(long id, UpdatePermissionRequest request);

    /// <summary>
    /// 删除权限
    /// </summary>
    /// <param name="id">权限ID</param>
    /// <returns>是否删除成功</returns>
    Task<bool> DeleteAsync(long id);

    /// <summary>
    /// 检查权限编码是否存在
    /// </summary>
    /// <param name="code">权限编码</param>
    /// <param name="excludeId">排除的ID</param>
    /// <returns>是否存在</returns>
    Task<bool> CodeExistsAsync(string code, long? excludeId = null);
}
