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

import com.ssj.bean.weixin.zyb.domain.ZuoybScoringContent;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;


/** 
 * @author  ZhangCaibao 
 * @version 2017年7月4日 上午11:30:59 
 * 类说明 
 */
@Repository
public interface ZuoybScoringContentDao extends JpaRepository<ZuoybScoringContent, String>{

	 public Page<ZuoybScoringContent> findAll(Specification<ZuoybScoringContent> specification, Pageable page);
	 
	 public List<ZuoybScoringContent> findByLibId(String libId);
	 /*
	  * 科目结构
	  */
	 @Query(nativeQuery = true, value =" select  *   from  zyb_scoring_content  where lib_id=?1 and zyb_course_id =?2  and num between 1 and 99 ")
	 public List<ZuoybScoringContent> findByLibIdListKm(String libId,String zybCourseId);
	 /**
	  *  总体
	  */
	 @Query(nativeQuery = true, value =" select  *   from  zyb_scoring_content  where lib_id=?1 and zyb_course_id =?2  and num >= 100 ")
	 public List<ZuoybScoringContent> findByLibIdListZt(String libId,String zybCourseId);
	 

	 
	 @Query(nativeQuery = true, value =" select  count(1)  from  zyb_scoring_content  where lib_id=?1 and zyb_course_id =?2  ")
	 public Integer getLibIdCount(String libId,String zybCourseId);
	 
	 
	 @Query(nativeQuery = true, value =" select  count(1)  from  zyb_scoring_content  where lib_id=?1 and pid =?2  and zyb_course_id =?3   ")
	 public Integer getLibIdAndPidAndZybCourseId(String libId,String pid ,String zybCourseId);
	 @Query(nativeQuery = true, value =" select  *   from  zyb_scoring_content  where lib_id=?1 and zyb_course_id =?2 order by num asc  ")
	 public  List<ZuoybScoringContent>  findByLibIdAndZybCourseId(String libId,String zybCourseId);
}
