package com.qmth.qrzk.dao.repositories;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.qmth.qrzk.repository.user.model.PrintLog;

public interface PrintLogRepo extends JpaRepository<PrintLog, Long> {

	List<PrintLog> findByBatchIdAndUserId(int batchId,int userId,Sort sort);

	@Query("select p from PrintLog p where p.batchId = ?1 and p.createdTime between ?2 and ?3")
	List<PrintLog> findByBatchIdAndPrintTime(int batchId, Date from, Date to, Sort sort);
	
	@Query(value="SELECT DISTINCT DATE_FORMAT(created_time, '%Y-%m-%d') AS printDate FROM `qr_print_log` WHERE batch_id = ?1 ORDER BY printDate desc", nativeQuery=true)
	List<String> queryPrintDates(int batchId);
}