package com.izouma.dingdong.repo.merchant;

import com.izouma.dingdong.domain.merchant.AutomaticResponse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface AutomaticResponseRepo extends JpaRepository<AutomaticResponse, Long>, JpaSpecificationExecutor<AutomaticResponse> {

    //查找商户下的所有自动回复
   // List<AutomaticResponse> findAllByMerchantId(Long merchantId);

    //查找商户下的自动回复
    AutomaticResponse findByUserId(Long userId);

    @Query("update AutomaticResponse t set t.enabled = false where t.id = ?1")
    @Modifying
    @Transactional
    void deleteById(Long id);
}