package com.its.api.its.repository.link;

import com.its.api.its.model.entity.link.TbLinkParaClctSyst;
import com.its.api.its.model.entity.link.TbLinkParaClctSystKey;
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.stereotype.Repository;

import java.util.List;

@Repository
public interface TbLinkParaClctSystRepository extends JpaRepository<TbLinkParaClctSyst, TbLinkParaClctSystKey> {

    @Query(value = "select distinct p from TbLinkParaClctSyst p where p.LINK_ID = :link_id")
    List<TbLinkParaClctSyst> findListById(@Param("link_id") Long link_id);

    @Modifying // select 문이 아님을 나타낸다
    @Query(value = "delete from TB_LINK_PARA_CLCT_SYST", nativeQuery = true)
    void deleteDataAll() throws Exception;

    @Modifying // select 문이 아님을 나타낸다
    @Query(value = "delete from TB_LINK_PARA_CLCT_SYST where LINK_ID = :link_id", nativeQuery = true)
    void deleteListById(@Param("link_id")Long link_id) throws Exception;
}
