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 : 자신이 등록한 상품에 네고 못하도록 예외 추가 #216

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum ErrorCode {
NO_TRANSFER_PENDING_NEGO(BAD_REQUEST, "양도 대기중인 네고가 없습니다."),
NO_REGISTERED_ACCOUNT(NOT_FOUND, "등록된 계좌가 없습니다"),
TRANSFER_PENDING_NEGO(BAD_REQUEST,"양도 대기 중인 상품이 있어 결제할 수 없습니다."),
CANNOT_NEGOTIATE_SELF_PRODUCT(BAD_REQUEST, "자신의 상품에는 네고를 할 수 없습니다."),


// Auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public PriceProposeResponse proposePrice(Long productId, PriceProposeRequest req
.orElseThrow(() -> new NoSuchElementException("Nego not found with id: " + userId));

Product product = productService.getProduct(productId);
Long productUserId = product.getUserId();

if(userId.equals(productUserId)){
throw new CustomException("자신의 상품에는 네고를 할 수 없습니다.", ErrorCode.CANNOT_NEGOTIATE_SELF_PRODUCT);
}

List<Nego> allNegosForProduct = negoRepository.findAllByProduct(product);
for (Nego nego : allNegosForProduct) {
Expand Down