package cn.novalon.gym.manage.db.dao;

import cn.novalon.gym.manage.db.entity.SysLoginLogEntity;
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;

@Repository
public interface SysLoginLogDao extends R2dbcRepository<SysLoginLogEntity, Long> {

    Flux<SysLoginLogEntity> findByUsername(String username);

    Flux<SysLoginLogEntity> findByUsernameOrderByLoginTimeDesc(String username);

    Flux<SysLoginLogEntity> findByLoginTimeBetweenOrderByLoginTimeDesc(LocalDateTime startTime, LocalDateTime endTime);

    Flux<SysLoginLogEntity> findAllByOrderByLoginTimeDesc();

    Mono<Long> count();

    Mono<Long> countByUsername(String username);

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