package com.dbnt.faisp.main.fipTarget.repository;


import com.dbnt.faisp.main.fipTarget.model.ShipInfo;

import java.util.List;


import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;




public interface ShipInfoRepository extends JpaRepository<ShipInfo, ShipInfo.ShipInfoId> {

	ShipInfo findTopBySiTypeOrderBySiSeqDesc(String siType);

	List<ShipInfo> findBySiSeqAndSiTypeOrderByVersionNoDesc(Integer siSeq, String siType);

	void deleteBySiSeqAndSiType(Integer siSeq, String siType);

	@Query(value = "SELECT wrt_user_seq FROM ship_info WHERE si_seq=:siSeq AND si_type=:siType order by version_no asc limit 1", nativeQuery = true)
	Integer getWrtUserSeq(@Param("siSeq") Integer siSeq,@Param("siType") String siType);
}
