package com.yihu.wlyy.repository.doctor;

import com.yihu.wlyy.entity.doctor.survey.SurveyLabelInfo;
import com.yihu.wlyy.entity.doctor.survey.SurveyTemplates;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by Reece on 2017/3/9.
 */
public interface SurveyLabelInfoDao extends PagingAndSortingRepository<SurveyLabelInfo, Long> {

    @Query("select t.label from SurveyLabelInfo t where t.relationCode = ?1 ")
    int[] findByRelationCode(String code);

    @Query("select t from SurveyLabelInfo t where t.relationCode = ?1 ")
    List<SurveyLabelInfo> findByCode(String code);

    @Query("select distinct t.label from SurveyLabelInfo t where  t.useType=?1 ")
    List<Object> findByUseType(int useType);

    @Query("select t from SurveyLabelInfo s,SurveyTemplates t where t.del = 1 and s.relationCode = t.code and s.useType=0 and s.label = ?1 ")
    List<SurveyTemplates> findByLabel(int label);

    @Modifying
    @Query("update SurveyLabelInfo s set s.label=?2 where s.relationCode = ?1 ")
    void modifyLabel(String code,int label);

}
