package com.devjob.repository;

import com.devjob.domain.Member;
import com.devjob.domain.Role;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

/**
 * EP10: JpaRepository 상속만으로 기본 CRUD(save/findById/findAll/delete 등)를 제공받고,
 * 메서드 이름 규칙으로 쿼리 메서드를 추가한다.
 */
public interface MemberRepository extends JpaRepository<Member, Long> {

    Optional<Member> findByEmail(String email);

    boolean existsByEmail(String email);

    List<Member> findByRoleOrderByCreatedAtDesc(Role role);

    List<Member> findByEmailContainingIgnoreCase(String keyword);

    Optional<Member> findByEmailAndRole(String email, Role role);
}
