package com.saas.admin.service;

import com.saas.admin.dto.response.AuditLogResponse;
import com.saas.shared.dto.common.PageResponse;

import java.time.LocalDate;
import java.util.Map;

/**
 * Audit Log Service Interface
 * 
 * Defines contract for audit log query and analysis operations.
 * Implements Separation of Concerns by separating business logic from controllers.
 */
public interface AuditLogService {

    /**
     * Get paginated audit logs with dynamic filtering
     * 
     * @param page Page number (0-indexed)
     * @param size Page size
     * @param action Optional action filter
     * @param entityType Optional entity type filter
     * @param userId Optional user ID filter
     * @param tenantId Optional tenant ID filter
     * @param startDate Optional start date for range filter
     * @param endDate Optional end date for range filter
     * @return Paginated audit log responses
     */
    PageResponse<AuditLogResponse> getAuditLogs(
        int page, int size, String action, String entityType, 
        Long userId, String tenantId, LocalDate startDate, LocalDate endDate
    );

    /**
     * Get a single audit log by ID
     */
    AuditLogResponse getAuditLogById(Long id);

    /**
     * Get paginated audit logs for a specific tenant
     */
    PageResponse<AuditLogResponse> getTenantAuditLogs(String tenantId, int page, int size);

    /**
     * Get paginated audit logs for a specific user
     */
    PageResponse<AuditLogResponse> getUserAuditLogs(Long userId, int page, int size);

    /**
     * Get aggregated audit log statistics
     * 
     * @return Map containing:
     *         - actionCounts: Map of action type -> count
     *         - entityTypeCounts: Map of entity type -> count
     *         - tenantCounts: Map of tenant -> count
     *         - userCounts: Top 10 users by action count
     *         - logsLast24h: Count of logs in last 24 hours
     *         - totalLogs: Total count of all logs
     */
    Map<String, Object> getAuditLogStatistics();
}
