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

import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
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;
import java.util.Set;

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

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

    List<WlyyPrescriptionInfoDO> queryAllByPrescriptionIdInAndDel(Set ids,Integer del);


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


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