package com.huimv.manage.eartag.dao.repo;

import com.huimv.manage.eartag.dao.entity.EtApplyEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface EtApplyRepo extends JpaRepository<EtApplyEntity, Integer>, JpaSpecificationExecutor<EtApplyEntity> {

    //
    @Query(nativeQuery = true, value = "SELECT * FROM et_apply ORDER BY id DESC")
    List<EtApplyEntity> listApply();

    //
    @Query(nativeQuery = true, value = "SELECT * FROM et_apply ORDER BY id DESC")
    List<EtApplyEntity> listApply(Pageable pageable, Specification specification);

    //
    @Query(nativeQuery = true, value = "SELECT * FROM et_apply WHERE apply_id =?1 ORDER BY id DESC",
            countQuery = "SELECT count(*) FROM et_apply WHERE apply_id =?1")
    Page<EtApplyEntity> listApply(Pageable pageable,int applyId);
}