Skip to content

Commit

Permalink
Merge branch 'main' into test/order
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseogi0218 committed Mar 19, 2024
2 parents 4e7f34e + 53828cc commit 445383e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.laser.ordermanage.ingredient.repository;

import com.laser.ordermanage.ingredient.domain.IngredientPrice;
import jakarta.persistence.LockModeType;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.repository.CrudRepository;

import java.time.LocalDate;
import java.util.Optional;

public interface IngredientPriceRepository extends CrudRepository<IngredientPrice, Long> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
Optional<IngredientPrice> findByIngredientIdAndCreatedAt(Long ingredientId, LocalDate date);

IngredientPrice findFirstByIngredientIdOrderByCreatedAtDesc(Long ingredientId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public IngredientStock findPreviousByIngredientIdAndDate(Long ingredientId, Loca
.join(ingredientStock.ingredient, ingredient)
.where(
ingredient.id.eq(ingredientId),
ingredientStock.createdAt.loe(date)
ingredientStock.createdAt.before(date)
)
.orderBy(ingredientStock.createdAt.desc())
.fetchFirst();
Expand Down

0 comments on commit 445383e

Please sign in to comment.