Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 음식 상품 수량 수정 #108

Merged
merged 23 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3414520
[feat] MenuRepository 수정
kimhyun5u Aug 18, 2024
8e0cc9e
[test] UpdateMenuStockServiceTest 구현
kimhyun5u Aug 18, 2024
40507a9
[feat] UpdateMenuStockService 구현
kimhyun5u Aug 18, 2024
6d9ce65
[feat] UpdateMenuStockCommand 구현
kimhyun5u Aug 18, 2024
9fa5676
[feat] StoreNotOpenException 구현
kimhyun5u Aug 18, 2024
d39462c
[feat] NotEqualsOwnerException 구현
kimhyun5u Aug 18, 2024
2ec51f3
[feat] InvalidMenuStockUpdateException 구현
kimhyun5u Aug 18, 2024
76d638d
[feat] MenuErrorCode 수정
kimhyun5u Aug 18, 2024
ef93db6
[fix] MenuRepository 수정
kimhyun5u Aug 18, 2024
ff2ba69
[fix] UpdateMenuStockService 수정
kimhyun5u Aug 18, 2024
311b1b3
[fix] MenuErrorCode 수정
kimhyun5u Aug 18, 2024
bdf6698
[fix] NotUpdatableTimeException 구현
kimhyun5u Aug 18, 2024
14a7cd8
[test] MenuApiControllerTest 구현
kimhyun5u Aug 18, 2024
43f2777
[feat] MenuApiController 구현
kimhyun5u Aug 18, 2024
ef191b6
[feat] MenuExceptionHandler 구현
kimhyun5u Aug 18, 2024
2c8851f
[feat] UpdateMenuStockRequest 구현
kimhyun5u Aug 18, 2024
c58293e
[feat] UpdateMenuStockResponse 구현
kimhyun5u Aug 18, 2024
14ab35d
[docs] UpdateMenuStockResponse 수정
kimhyun5u Aug 18, 2024
9b4a2a2
[fix] Http Method 수정
kimhyun5u Aug 18, 2024
9b0e736
[fix] Http Method 수정
kimhyun5u Aug 18, 2024
460088f
[merge] remote-tracking branch 'origin/main' into feature/101_kimhyun…
kimhyun5u Aug 18, 2024
394301f
[docs] UpdateMenuStockService 수정
kimhyun5u Aug 18, 2024
7b52d4b
[merge] remote-tracking branch 'origin/main' into feature/101_kimhyun…
kimhyun5u Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/camp/woowak/lab/menu/repository/MenuRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

Expand All @@ -18,4 +19,17 @@ public interface MenuRepository extends JpaRepository<Menu, Long> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
@Query("SELECT m FROM Menu m where m.id in :ids")
List<Menu> findAllByIdForUpdate(List<Long> ids);

june-777 marked this conversation as resolved.
Show resolved Hide resolved
@Lock(LockModeType.PESSIMISTIC_WRITE)
Optional<Menu> findByIdForUpdate(Long id);

/**
*
* 메뉴의 재고를 변경합니다.
* TODO: [논의] @Transactional을 Respository 단에 안둬도되는가?
* Repository 에서 직접 접근할 때 사용자가 실수해서 @Transactional 을 빼먹을 수도 있다.
*/
@Modifying
@Query("UPDATE Menu m SET m.stockCount = :stock WHERE m.id = :id")
int updateStock(@Param("id") Long id, @Param("stock") int stock);
}