package com.icomsys.main_vm.db.jpa.repo.system;

import com.icomsys.main_vm.db.jpa.entity.conversation.TbIntentMaster;
import com.icomsys.main_vm.db.jpa.repo.system.dsl.TbIntentMasterRepoDsl;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TbIntentMasterRepo extends JpaRepository<TbIntentMaster, Long>, TbIntentMasterRepoDsl {

    List<TbIntentMaster> findByUseYnAndOprMngCode(String use, String opr);

    @Modifying
    @Transactional
    @Query(
            value = "UPDATE TB_INTENT_MASTER " +
                    "set USE_YN = :useYn " +
                    "where SEQ = :seq "
            ,nativeQuery = true
    )
    int deleteDictionary(@Param("useYn") String useYn, @Param("seq") Long seq);

    boolean existsByIntentNameAndUseYn(String intentName, String use);
}
