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

import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
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.Date;
import java.util.List;

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

    @Query("from WlyyPrescriptionExpressageDO p where p.mailno=?1")
    WlyyPrescriptionExpressageDO findByPrescriptionExpressMailno(String mailno);

    @Query("from WlyyPrescriptionExpressageDO p where p.outpatientId=?1 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByOutpatientId(String outpatientId);

    @Modifying
    @Query("update WlyyPrescriptionExpressageDO p set p.mailno=?2  where p.id=?1")
    void updateMailNoById(String id, String mailno);

    @Query("from WlyyPrescriptionExpressageDO p where p.outpatientId=?1 and p.oneselfPickupFlg = 1 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByOutpatientIdAndOneSelfPick(String outpatientId);
}
