package cn.teammodel.repository;

import cn.teammodel.model.entity.school.LessonRecord;
import cn.teammodel.model.vo.appraise.RecordVo;
import com.azure.spring.data.cosmos.repository.CosmosRepository;
import com.azure.spring.data.cosmos.repository.Query;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface LessonRecordRepository extends CosmosRepository<LessonRecord, String> {
    @Query("select * from LessonRecord as c where " +
            "c.code = @code and " +
            "(IS_NULL(@startTime) or c.startTime >= @startTime) and " +
            "(IS_NULL(@endTime) or c.startTime <= @endTime) and" +
            " c.tmdid = @tmdId")
    List<LessonRecord> getLessonsByConditions(String code, Long startTime, Long endTime,String tmdId);

    @Query("select * from LessonRecord as c where c.code = @code and c.expire<=0  and c.status<>404 and c.tmdid = @tmdId ")
    Slice<LessonRecord> findAllByAcademicYearId(String code, String tmdId,Pageable pageable);
    @Query("select * from LessonRecord as c where c.code = @code and c.expire<=0  and c.status<>404 and array_contains(c.grade,@grade) ")
    Slice<LessonRecord> findAllByGrade(String code, String grade,Pageable pageable);
    @Query("select * from LessonRecord as c where c.code = @code and c.expire<=0  and c.status<>404 ")
    Slice<LessonRecord> findAll(String code,Pageable pageable);

}
