package com.ywt.mg.domain.entities;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.ywt.mg.domain.entities.DownloadRecord;
import org.springframework.data.jpa.repository.Query;

public interface DownloadRecordRepository extends JpaRepository<DownloadRecord, Integer>, JpaSpecificationExecutor<DownloadRecord> {

    @Query(value = "select * from download_record where admin_id = ? and param_md5 = ? and param_url = ? and status = 0 and deleted = 0 order by id desc limit 1;",nativeQuery = true)
    DownloadRecord findCreatingLeastOne(int currentAdminId, String paramMd5, String paramUrl);

    @Query(value = "select * from download_record where id = ? and deleted = 0 limit 1;",nativeQuery = true)
    DownloadRecord findOne(int id);
}