Skip to content

Comments

판매 입찰 등록 및 수정 분기 수정#61

Open
LSH0809 wants to merge 3 commits intoprgrms-be-devcourse:developfrom
LSH0809:refactor/modify-SellingController
Open

판매 입찰 등록 및 수정 분기 수정#61
LSH0809 wants to merge 3 commits intoprgrms-be-devcourse:developfrom
LSH0809:refactor/modify-SellingController

Conversation

@LSH0809
Copy link
Collaborator

@LSH0809 LSH0809 commented Nov 15, 2021

  • 기존의 컨트롤러의 분기 -> 서비스 레이어에서 분기 발생하도록 수정
  • 서비스레이어에서 분기 발생할 수 있도록 메소드 정리

- 기존의 컨트롤러의 분기 -> 서비스 레이어에서 분기 발생하도록 수정

- 서비스레이어에서 분기 발생할 수 있도록 메소드 정리
Copy link
Collaborator

@samkimuel samkimuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리팩토링 하셨군요👍🏻
코멘트 하나 남겼으니 확인해주세욥!!

Comment on lines 94 to 100
if (existsSameBid(id, size, bidRequest.userId(), DealStatus.BIDDING.getStatus())) {
SellingBid sellingBid = findSellingBid(id, size, bidRequest.userId());
sellingBid.updateSellingBid(bidRequest.price(), bidRequest.deadline());

return sellingBid.toBidResponse(bidRequest);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 업데이트 로직인가용??

구매 입찰 내역을 업데이트 하게 되면 최저가 업데이트도 필요하다고 생각됩니다!
예를 들어, 지금 업데이트 하는 구매 입찰 내역이 최저가였는데, 더 높은 가격으로 수정하게 되면 최저가도 바뀌게 될 것 같아용

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8ce85a3 : 아! 제가 수정하면서 이 부분을 놓쳤군요.. 알려주셔서 감사합니다!!! 이렇게 작성하니 일단 서비스 레이어에서 분기가 발생하도록 수정했는데 코드가 분리될 부분이 또 보이네요.. 이 부분도 나중에 한번 고쳐보겠습니다!!!

Copy link
Collaborator

@buri-1029 buri-1029 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

꾸준한 리팩토링 좋네유 >0<

Comment on lines -38 to -48
if (sellingService.existsSameBid(
id,
size,
bidRequest.userId(),
DealStatus.BIDDING.getStatus())
) {
return ResponseEntity.ok(ApiResponse.of(
sellingService.updateSellingBid(id, size, bidRequest)));
}
return ResponseEntity.ok(ApiResponse.of(
sellingService.registerSellingBid(id, size, bidRequest)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상태에 따른 서비스 로직을 구별해 준 부분을 컨트롤러 단이 아닌 서비스 단에서 해주는 게 맞는 것 같고 리팩토링 하니 가독성도 좋아 보이네요 굳굳

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9874916
8ce85a3 : 감사합니다! 명환님 피드백대로 이 부분 수정했습니다! 코드가 중복된 부분도 있어서 개선의 여지가 있어보이는데 일단은 서비스에서 분기 발생했으니 이 부분은 추후!!! 수정하겠습니닿ㅎㅎㅎ

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳굳!👍🏻

- 기존의 최저가 변경 메소드 위치를 메소드 최하단으로 변경
- 위 로직이 모두 정상적으로 진행될 때 업데이트가 되도록 수정
- return 으로 인해 최저가 갱신이 되지 않는 것을 수정
- updateLowestPrice 메소드를 추가
@LSH0809 LSH0809 requested a review from samkimuel November 21, 2021 06:12
Copy link
Collaborator

@samkimuel samkimuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조금(?) 늦게 리뷰를 남기네요 ㅎ,,, 파이팅입니다!

@ApiOperation(value = "판매입찰등록 및 수정", notes = "상품Id와 신발사이즈,입찰정보(dto)를 통해 입찰을 등록 혹은 갱신합니다.")
@PutMapping("/{id}")
public ResponseEntity<ApiResponse<BidResponse>> registerSellingBid(
public ResponseEntity<ApiResponse<BidResponse>> registerSellingBidRefactor(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깃에서 버전컨트롤이 되기 떄문에 메서드명은 그대로 가셔도 좋을 것 같아욥!

Comment on lines -38 to -48
if (sellingService.existsSameBid(
id,
size,
bidRequest.userId(),
DealStatus.BIDDING.getStatus())
) {
return ResponseEntity.ok(ApiResponse.of(
sellingService.updateSellingBid(id, size, bidRequest)));
}
return ResponseEntity.ok(ApiResponse.of(
sellingService.registerSellingBid(id, size, bidRequest)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굳굳!👍🏻

Comment on lines +93 to 99
if (existsSameBid(id, size, bidRequest.userId(), DealStatus.BIDDING.getStatus())) {
SellingBid sellingBid = findSellingBid(id, size, bidRequest.userId());
sellingBid.updateSellingBid(bidRequest.price(), bidRequest.deadline());
updateLowestPrice(bidRequest, productOption);
return sellingBid.toBidResponse(bidRequest);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

existsSameBid의 매개변수들을 이용해서 find + ~ 쿼리 메서드를 만든다면 Optional로 반환받을 수 있을 것 같고, 그렇게 되면 if문은 사용하지 않아도 될 것 같습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants