package com.its.api.its.repository.cctv;

import com.its.api.its.model.entity.cctv.TbCctvCtlr;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TbCctvCtlrRepository extends JpaRepository<TbCctvCtlr, Long>, JpaSpecificationExecutor<TbCctvCtlr> {

    @Query("select p from TbCctvCtlr p left outer join fetch p.state")
    List<TbCctvCtlr> findAll();

    @Query("select p from TbCctvCtlr p left outer join fetch p.state where p.delYn = 'N'")
    List<TbCctvCtlr> findAllList();

    @Query("select count(p.cctvMngmNmbr) as total from TbCctvCtlr p where p.delYn = 'N'")
    Integer findAllListCount();

}
