using LogCentral.Server.Models;

namespace LogCentral.Server.Services;

public interface ILogService
{
    Task AddLogsAsync(List<LogEntry> entries);
    Task<LogEntry?> GetLogByIdAsync(string id);
    Task<PagedResult<LogEntry>> GetLogsAsync(LogQueryParams queryParams);
    Task<Dictionary<string, object>> GetStatsAsync(string? app, string? env);
    Task<bool> ValidateApiKeyAsync(string apiKey);
}

public class LogQueryParams
{
    public string? Search { get; set; }
    public string? Application { get; set; }
    public string? Environment { get; set; }
    public int? Level { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public int Page { get; set; } = 1;
    public int PageSize { get; set; } = 50;
}

public class PagedResult<T>
{
    public List<T> Items { get; set; } = new();
    public int TotalCount { get; set; }
    public int Page { get; set; }
    public int PageSize { get; set; }
    public int TotalPages => (int)Math.Ceiling((double)TotalCount / PageSize);
}