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

import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
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/9/30.
 */
public interface WlyyInspectionDao extends PagingAndSortingRepository<WlyyInspectionDO, String>, JpaSpecificationExecutor<WlyyInspectionDO> {

    List<WlyyInspectionDO> findByOutpatientId(String outpatientId);

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


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


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


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