package com.crm.email.dao.repository;

import com.crm.rely.backend.core.pojo.table.SysEmailUnsubscribeTable;
import com.crm.rely.backend.dao.repository.BaseRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

@Repository
public interface SysEmailUnsubscribeRepository extends BaseRepository<SysEmailUnsubscribeTable> {

    SysEmailUnsubscribeTable findFirstByFromAccountAndToAccount(String fromAccount, String toAccount);

    SysEmailUnsubscribeTable getFirstById(Long id);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<SysEmailUnsubscribeTable> findAllByIdIn(List<Long> ids);

    boolean existsByFromAccountAndToAccount(String fromAccount, String toAccount);
}