package com.huimv.environ.env.environ.dao.repo;

import com.huimv.environ.env.environ.dao.entity.EnvHourEntity;
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;
import java.util.Optional;

public interface EnvHourRepo extends JpaRepository<EnvHourEntity, Integer>, JpaSpecificationExecutor<EnvHourEntity> {

    //
    @Query(nativeQuery = true,value ="SELECT * FROM env_hour where farm_id=?1 ORDER BY add_time DESC LIMIT 1")
    Optional<EnvHourEntity> findLastOne(Integer farmId);

    @Query(nativeQuery = true,value ="SELECT * FROM env_hour where farm_id=?1 ORDER BY add_time DESC LIMIT 1")
    EnvHourEntity findLastOne2(Integer farmId);
}