package com.huimv.produce.produce.repo;

import com.huimv.produce.produce.entity.ProdWeightDayEntity;
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 ProdWeightDayRepo extends JpaRepository<ProdWeightDayEntity, Integer>, JpaSpecificationExecutor<ProdWeightDayEntity> {

    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight_day WHERE DATE_FORMAT(add_date,'%Y-%m-%d')=DATE_FORMAT(?1,'%Y-%m-%d')")
    List<ProdWeightDayEntity> getDayWeightList(String todayDate);

    @Query(nativeQuery = true,value = "SELECT * FROM prod_weight_day WHERE pound_type=?2 ORDER BY add_date DESC LIMIT ?1")
    List<ProdWeightDayEntity> findDayWeight(Integer days, String poundType);
}