package com.dne.ems.repository;

import java.util.List;
import java.util.Optional;

import com.dne.ems.model.UserAccount;
import com.dne.ems.model.enums.Role;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * Repository interface for accessing UserAccount data.
 * This acts as an abstraction layer over the data source.
 */
public interface UserAccountRepository {

    Optional<UserAccount> findByEmail(String email);

    Optional<UserAccount> findByPhone(String phone);
    
    Optional<UserAccount> findById(Long id);
    
    List<UserAccount> findByRole(Role role);

    List<UserAccount> findGridWorkersByCoordinates(Integer gridX, Integer gridY);

    Optional<UserAccount> findByGridXAndGridY(Integer gridX, Integer gridY);

    List<UserAccount> findAll();

    UserAccount save(UserAccount userAccount);
    
    List<UserAccount> saveAll(Iterable<UserAccount> entities);

    long countByRole(Role role);
    
    long count();
    
    void deleteById(Long id);

    Page<UserAccount> findUsers(Role role, String name, Pageable pageable);
} 