import type { AuditService } from "./audit-service"
import type {
  AuditLog,
  AuditOverviewStats,
  AuditRetentionConfig,
  AuditTrendPoint,
  DataChangeActionStat,
  DataChangeLog,
  DataChangeStat,
  LoginLog,
  PaginatedResult,
  PurgeResult,
} from "@/modules/audit/types"

/**
 * 空数据 Mock 实现（用于测试）。
 *
 * 所有方法返回空数据或默认值，不触发任何 DB 调用。
 * 通过为每个方法添加显式返回类型标注，避免 `as` 类型断言。
 *
 * @example
 * ```tsx
 * <AuditServiceProvider service={mockAuditService}>
 *   <AuditOverviewView ... />
 * </AuditServiceProvider>
 * ```
 */
export const mockAuditService: AuditService = {
  getAuditLogs: async (): Promise<PaginatedResult<AuditLog>> => ({
    items: [],
    total: 0,
    page: 1,
    pageSize: 20,
    totalPages: 0,
  }),
  getLoginLogs: async (): Promise<PaginatedResult<LoginLog>> => ({
    items: [],
    total: 0,
    page: 1,
    pageSize: 20,
    totalPages: 0,
  }),
  getDataChangeLogs: async (): Promise<PaginatedResult<DataChangeLog>> => ({
    items: [],
    total: 0,
    page: 1,
    pageSize: 20,
    totalPages: 0,
  }),

  getAuditModuleOptions: async (): Promise<string[]> => [],
  getDataChangeStats: async (): Promise<DataChangeStat[]> => [],
  getDataChangeTableOptions: async (): Promise<string[]> => [],

  getAuditOverviewStats: async (): Promise<AuditOverviewStats> => ({
    auditEventsToday: 0,
    failedLoginsToday: 0,
    dataChangesToday: 0,
    totalAuditLogs: 0,
  }),
  getAuditTrend: async (): Promise<AuditTrendPoint[]> => [],
  getDataChangeActionStats: async (): Promise<DataChangeActionStat[]> => [],

  getAuditRetentionConfig: async (): Promise<AuditRetentionConfig> => ({
    retentionDays: 180,
    loginLogRetentionDays: 365,
    autoCleanupEnabled: false,
  }),
  saveAuditRetentionConfig: async (): Promise<void> => undefined,
  purgeExpiredAuditLogs: async (): Promise<PurgeResult> => ({
    auditLogsDeleted: 0,
    loginLogsDeleted: 0,
    dataChangeLogsDeleted: 0,
  }),
}
