package com.huimv.receiver.farm.dao.repo;

import com.huimv.receiver.farm.dao.entity.FarmDeviceEntity;
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 FarmDeviceRepo extends JpaRepository<FarmDeviceEntity, Integer>, JpaSpecificationExecutor<FarmDeviceEntity> {

    //查询*
    @Query(nativeQuery = true,value = "SELECT * FROM farm_device WHERE data_id=?1")
    Optional<FarmDeviceEntity> getByDataId(Long dataId);

    //查询ID
    @Query(nativeQuery = true,value = "SELECT id FROM farm_device WHERE data_id=?1")
    List<Object[]> getDevice(Long dataId);
}