package cn.com.qmth.examcloud.core.questions.dao;

import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.repository.query.QueryByExampleExecutor;

import java.util.List;
import java.util.Set;

/**
 * @author weiwenhai
 * @describle 课程属性repo
 * @date 2017.11.2
 */
public interface CoursePropertyRepo extends MongoRepository<CourseProperty, String>, QueryByExampleExecutor<CourseProperty> {

    //根据属性名查询
    CourseProperty findByOrgIdAndName(Long orgId, String name);

    //根据课程id查询
    List<CourseProperty> findByCourseId(Long courseId);

    List<CourseProperty> findByCourseCode(String courseCode);

    //根据课程代码查询已开启的课程属性
    List<CourseProperty> findByCourseCodeAndEnable(String courseCode, Boolean enable);
    List<CourseProperty> findByOrgIdAndCourseCodeAndEnable(Long orgId,String courseCode, Boolean enable);

    //根据课程id查询已经开启的课程属性
    List<CourseProperty> findByCourseIdAndEnable(Long courseId, Boolean enable);

    //根据id集合查询
    List<CourseProperty> findByIdIn(List<String> ids);

	CourseProperty findByOrgIdAndCourseIdAndName(Long rootOrgId, Long courseId, String propertyName);

	List<CourseProperty> findByOrgIdAndCourseIdIn(Long orgId, Set<Long> refIds);

	List<CourseProperty> findByOrgId(Long orgId);

	void deleteByOrgIdAndBatch(Long rootOrgId, String batch);
	
	CourseProperty findByOrgIdAndCourseIdAndBatch(Long rootOrgId,Long courseId, String batch);

}