package com.ssj.dao.weixin.zuoyb.dao;

import com.ssj.bean.weixin.zyb.domain.ZuoybStudentWorkHowDetails;
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;


/** 
 * @author  ZhangCaibao 
 * @version 2017年11月1日 下午2:33:03 
 * 类说明 
 */
@Repository
public interface ZuoybStudentWorkHowDetailsDao extends JpaRepository<ZuoybStudentWorkHowDetails, String> {

	@Query(nativeQuery = true, value = "delete from  zyb_student_work_how_details  where student_work_id = ?1 ")
    @Modifying
	public void deleteByStudentWorkId(String studentWorkId);
	
	@Query(nativeQuery = true, value = "SELECT \n" +
			"			d.*\n" +
			"			  from  \n" +
			"			zyb_student_work  k  JOIN \n" +
			"			     zyb_student_work_how  h  on k.id = h.student_work_id\n" +
			"      JOIN zyb_student_work_how_details d on h.id = d.work_how_id \n" +
			"			where k.vip_id=?1 and k.stat = 3 \n" +
			"			and TO_DAYS(k.scoring_time) >= TO_DAYS(?2) and TO_DAYS(k.scoring_time) <=TO_DAYS(?3) and k.course_name=?4 \n" +
			"			ORDER BY  k.num asc , k.scoring_time asc , h.num asc")
	public List<ZuoybStudentWorkHowDetails> getStartAndEndWorkHowAndCourse(String vipId,String start,String end,String course);
	
	public List<ZuoybStudentWorkHowDetails> findByStudentWorkIdIn(List<String> studentWorkIds);

	public List<ZuoybStudentWorkHowDetails> findByStudentWorkIdAndType (String studentWorkId, int type);


	public List<ZuoybStudentWorkHowDetails> findByStudentWorkIdAndTypeAndHowDetailsIdIn(String workId, int type, List<String> howDetailIds);

}
