package com.ssj.dao.sys.train.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.ssj.bean.sys.train.bean.VideoInfo;


@Repository
public interface VideoInfoDao extends JpaRepository<VideoInfo, String> {

	@Query(nativeQuery = true,value =  "SELECT * FROM tr_video_info t WHERE t.`status`=1 AND t.role_type=?1 AND t.indes>( SELECT v.indes from `tr_video_info` v WHERE v.id=?2 ) ORDER BY t.indes ASC LIMIT 1 ")
	public VideoInfo getVideoInfoByMax(Integer roleType,String id);
	
	@Query(nativeQuery = true,value =  "SELECT * FROM tr_video_info t WHERE t.role_type=?1 AND t.indes=?2 LIMIT 1 ")
	public VideoInfo getVideoInfoByIndes(Integer roleType,Integer indes);
	
	@Query(nativeQuery = true,value =  "SELECT * from tr_video_info t WHERE t.role_type=?1 ORDER BY t.indes desc LIMIT 1 ")
	public VideoInfo getVideoInfoByMaxIndes(Integer roleType);
}
