package cn.teammodel.repository;

import cn.teammodel.model.entity.school.PaperSchool;
import com.azure.spring.data.cosmos.repository.CosmosRepository;
import com.azure.spring.data.cosmos.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
public interface PaperSchoolRepository extends CosmosRepository<PaperSchool, String> {
    @Query("select value count(1) from c where c.pk='Paper' and c.code= @code " +
            "and ((IS_DEFINED(c.secret) = false or c.secret=0 ) or (c.secret=1 and c.creatorId=@id )) " +
            "and (IS_NULL(@grade) OR ARRAY_CONTAINS(c.gradeIds, @grade)) " +
            "and c.scope = @scope " +
            "and c.periodId = @periodId " )
    int getPaperCount(String code, String id,String grade,String scope,String periodId);
}
