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

import com.huimv.receiver.farm.dao.entity.ProdDayWeightEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.Optional;

public interface ProdDayWeightRepo extends JpaRepository<ProdDayWeightEntity, Integer>, JpaSpecificationExecutor<ProdDayWeightEntity> {

    @Query(nativeQuery = true,value = "SELECT * FROM prod_day_weight WHERE DATE_FORMAT(add_time,'%Y-%m-%d') = DATE_FORMAT(?1,'%Y-%m-%d') AND farm_id=?2")
    Optional<ProdDayWeightEntity> findByDateAndFarmId(Date date, Integer farmId);
}