package com.rf.psychological.plan.dao.repository;

import com.rf.psychological.base.repository.BaseRepository;
import com.rf.psychological.plan.dao.model.PlanGroupEntry;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.List;

public interface PlanGroupRepository extends BaseRepository<PlanGroupEntry,String> {
    /**
     * 分组id===》分组计划
     * @param gId
     * @return
     */

    @Query(value="select id ,group_id ,plan_id from t_plan_group where group_id = :groupId",nativeQuery = true)
    List<PlanGroupEntry> findByGroupId(@Param("groupId") String gId);

    @Transactional
    @Modifying
    @Query(value="delete from t_plan_group where plan_id = :planId",nativeQuery = true)
    void deleteByPlanId(@Param("planId") String testPlanId);
}
