package com.yihu.jw.base.dao.team;

import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
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 yeshijie on 2021/4/7.
 */
public interface WlyyPatientLabelDao extends PagingAndSortingRepository<WlyyPatientLabelDO, String>, JpaSpecificationExecutor<WlyyPatientLabelDO> {

    @Modifying
    @Query("delete WlyyPatientLabelDO a where a.patient=?1 and a.labelType=?2")
    int deleteByPatientAndLabelType(String patient, String labelType) throws Exception;

    @Query("from WlyyPatientLabelDO w where  w.patient=?1 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatient(String patient);
}
