package com.its.api.its.repository.vms;

import com.its.api.its.model.entity.vms.TbVmsIfsc;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface TbVmsIfscRepository extends JpaRepository<TbVmsIfsc, Long>, JpaSpecificationExecutor<TbVmsIfsc> {

    @Query("select count(p.detrId) from TbVmsIfsc p where p.detrId = :vmsIfscId and p.vmsIfscId <> :vmsIfscId")
    Integer findUsageCountByVmsIfscId(@Param("vmsIfscId") Long vmsIfscId);

    @Query(value = "SELECT NVL(MAX(VMS_IFSC_ID), 0) + 1 FROM TB_VMS_IFSC", nativeQuery = true)
    Long getNewVmsIfscId();

    @Query("select count(p.vmsIfscId) from TbVmsIfsc p")
    Integer findAllCount();


}
