package com.yihu.wlyy.repository.template;

import com.yihu.wlyy.entity.template.DoctorTeamGuidanceDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

/**
 * Created by Reece on 2017/6/8.
 */
public interface DoctorTeamGuidanceDetailDao extends PagingAndSortingRepository<DoctorTeamGuidanceDetail, Long>, JpaSpecificationExecutor<DoctorTeamGuidanceDetail> {
    //根据模板编码获取有效的模板详情
    @Query("select distinct t from DoctorTeamGuidanceDetail t,DoctorTeamGuidanceTemplate a where t.code = a.teamTemplateCode and a.del = 1 and t.code = ?1 ")
    DoctorTeamGuidanceDetail findGuidanceDetail(String guidanceCode);

    //根据模板编码更改模板详情
    @Modifying
    @Query("update DoctorTeamGuidanceDetail t set t.title = ?1,t.content = ?2,t.imagesUrl = ?3 where t.code = ?4 ")
    int modifyTeamGuidanceDetail(String title,String content,String image,String guidance);

}
