package com.yihu.jw.hospital.prescription.dao;

import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
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;

import java.util.List;

/**
 * Created by Trick on 2019/5/17.
 */
public interface PrescriptionDiagnosisDao extends PagingAndSortingRepository<WlyyPrescriptionDiagnosisDO, String>, JpaSpecificationExecutor<WlyyPrescriptionDiagnosisDO> {

    @Query("select a from WlyyPrescriptionDiagnosisDO a where a.prescriptionId = ?1 and a.del=?2 ")
    List<WlyyPrescriptionDiagnosisDO> findByPrescriptionId(String prescriptionId,Integer del);

    @Modifying
    @Query("update WlyyPrescriptionDiagnosisDO p set p.del=0 where p.id=?1")
    void deleteById(String id);

    @Modifying
    @Query("update WlyyPrescriptionDiagnosisDO p set p.del=0 where p.prescriptionId=?1")
    void deleteByPrescriptionId(String prescriptionId);
}
