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

import com.its.api.its.model.entity.vms.TbVmsDsplHs;
import com.its.api.its.model.entity.vms.TbVmsDsplHsKey;
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;

import java.util.List;

@Repository
public interface TbVmsDsplHsRepository extends JpaRepository<TbVmsDsplHs, TbVmsDsplHsKey>, JpaSpecificationExecutor<TbVmsDsplHs> {

    @Query("select p from TbVmsDsplHs p inner join fetch p.vms where p.dsplDt between :fromDt and :toDt and p.vmsCtlrNmbr in :ids")
    List<TbVmsDsplHs> findAllByDateRange(@Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("ids") List<Long> ids);

    @Query("select p from TbVmsDsplHs p inner join fetch p.vms where p.vmsCtlrNmbr = :id and p.dsplDt = :dsplDt order by p.dsplPhaseNum")
    List<TbVmsDsplHs> findAllImageByDateRange(@Param("id") Long id, @Param("dsplDt") String dsplDt);
}
