package com.ssj.dao.kmt.kmt.dao;

import com.ssj.bean.kmt.kmt.domain.KmtArrangeTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface KmtArrangeTemplateDao extends JpaRepository<KmtArrangeTemplate, String> {

    @Modifying
    @Query(nativeQuery = true, value = " update kmt_arrange_template set active_num = ?1 , update_time=now() ")
    public void updateKmtArrangeTemplateByActiveNum(int activeNum);
    
    
    @Query(nativeQuery = true, value = " SELECT * FROM `kmt_arrange_template` t where t.`status`=1 ORDER BY t.start_interval asc ")
	List<KmtArrangeTemplate> findKmtArrangeTemplateList();
    
    
    @Query(nativeQuery = true, value = " SELECT * from kmt_arrange_template t where t.start_interval>=DATE_FORMAT(NOW(),'%H:%i') ORDER BY t.start_interval ASC LIMIT 1 ")
    KmtArrangeTemplate getKmtArrangeDetailByCurTime();
		
	

    
}
