package com.codenetworkz.blog.repositories;

import com.codenetworkz.blog.models.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, Long> {

    User findByEmail(String email);
    boolean existsByEmail(String email);
    boolean existsByUsernameOrEmail(String username, String email);
    boolean existsByUsernameAndEmail(String username, String email);

    List<User> findAllByIsActiveAndIsDeleteAndDeleteAtIsBefore(String active, String isDeleted, LocalDateTime last30Day);

    User findByUsernameAndIsActive(String username, String active);
    User findByEmailAndIsActive(String email, String active);

    Optional<User> findById(Long userId);

    Optional<User> findByIdAndIsActive(Long userId, String active);

    // List<User> findAllByIsActiveAndIsDelete(String active, LocalDateTime last30Day);
}
