package cn.novalon.manage.sys.audit.repository;

import cn.novalon.manage.sys.audit.domain.AuditLog;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

/**
 * 审计日志仓储接口
 * 
 * @author 张翔
 * @date 2026-04-01
 */
@Repository
public interface IAuditLogRepository extends R2dbcRepository<AuditLog, Long> {

    Flux<AuditLog> findByEntityType(String entityType);

    Flux<AuditLog> findByEntityId(Long entityId);

    Flux<AuditLog> findByEntityTypeAndEntityId(String entityType, Long entityId);

    Flux<AuditLog> findByOperator(String operator);

    Flux<AuditLog> findByOperationType(String operationType);

    Flux<AuditLog> findByOperationTimeBetween(LocalDateTime startTime, LocalDateTime endTime);

    Flux<AuditLog> findByEntityTypeAndOperationTimeBetween(
        String entityType, 
        LocalDateTime startTime, 
        LocalDateTime endTime
    );

    Flux<AuditLog> findByOperatorAndOperationTimeBetween(
        String operator, 
        LocalDateTime startTime, 
        LocalDateTime endTime
    );

    Mono<Long> countByEntityType(String entityType);

    Mono<Long> countByOperationType(String operationType);

    Mono<Long> countByOperator(String operator);

    Mono<Long> countByOperationTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
}
