package cn.teammodel.repository;

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

import java.util.List;

/**
 * @author winter
 * @create 2024-01-03 15:18
 */
@Repository
public interface DutyRepository extends CosmosRepository<WeekDuty, String> {
    WeekDuty findBySchoolIdAndCode(String schoolId, String code);

    @Query("select value n from c join n in c.nodes where c.schoolId = @schoolId and c.code = 'Duty' and n.id = @nodeId")
    List<WeekDuty.DutyTreeNode> findDutyNodeById(String nodeId, String schoolId);


}
