package com.cirle.scientific.dao;/*
 *24901
 *2022/12/26
 *16:02
 */

import com.cirle.scientific.po.QkjLungReportApp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * @author 24901
 */
public interface QkjLungReportAppDao extends PagingAndSortingRepository<QkjLungReportApp, Long>, JpaSpecificationExecutor<QkjLungReportApp> {


    @Query(value = "select * from qkj_lung_report_app where id= ?1 and status = 0 ", nativeQuery = true)
    QkjLungReportApp findAllByIdAndStatus(Long id);

    @Query(value = "select * from qkj_lung_report_app where mem_card= ?1 and status = 0 ", nativeQuery = true)
    List<QkjLungReportApp> findAllByMemCardAndStatus(String memCard);

    @Query(value = "select * from qkj_lung_report_app where mem_card = ?1 and  user_name = ?2 and status = 0 order by id desc limit 1", nativeQuery = true)
    QkjLungReportApp findAllByMemCardAndUserNameAndStatus(String memCard,String userName);

    @Query(value = "select count(*) from qkj_lung_report_app where mem_card= ?1 and create_time > ?2  and create_time < ?3 and status = 0 ", nativeQuery = true)
    int findAllByMemCardAndStatusAAndCreateTime(String memCard, String firstday, String lastday);

}
