package cn.teammodel.repository;

import cn.teammodel.model.dto.admin.teacher.IdCodePair;
import cn.teammodel.model.entity.teacher.PtTeacherInfo;
import com.azure.spring.data.cosmos.repository.CosmosRepository;
import com.azure.spring.data.cosmos.repository.Query;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

@Repository
public interface PtTeacherRepository extends CosmosRepository<PtTeacherInfo, String>  {
    PtTeacherInfo findByIdAndCode(String id, String code);

    @Query(value = "SELECT * FROM c WHERE ARRAY_CONTAINS(@pairs, {id: c.id, code: c.code}, true) and c.pk = 'PtTeacher' and c.state = 1 and c.status != 'delete'" )
    List<PtTeacherInfo> findByIdCodePairs(@Param("pairs") List<IdCodePair> pairs);
    @Query(value = "SELECT * FROM c WHERE c.pk = 'PtTeacher' and c.school = @school and c.code = @code and c.state = 1 and c.status != 'delete' ")
    List<PtTeacherInfo> findAllTeacher(String school,String code);
    @Query(value = "SELECT * FROM c WHERE c.pk = 'PtTeacher' and c.code = @code and c.state = 1 and c.status != 'delete' ")
    List<PtTeacherInfo> findByCode(String code);

}
